<commit_before>/* Copyright 2014 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MockHTTP_H
#define MockHTTP_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* TODO: define defaults, eg HTTP/1.1 in req/resp */
/* TODO: use requests only once, use them in order, use best matching first */
/* TODO: any method, raw requests + responses */
/* TODO: add delay time for accept skt, response */

/* Note: the variadic macro's used here require C99. Such macro's require at
   least one argument, otherwise compilation will fail. */
#define InitMockHTTP(mh)\
            {\
                mh = mhInit();
#define   WithHTTPserver(...)\
                mhInitHTTPserver(mh, __VA_ARGS__, NULL);
#define   WithHTTPSserver(...)
#define   WithHTTPproxy(...)
#define     WithPort(port)\
                mhConstructServerPortSetter(mh, port)
#define EndInit\
            }

#define Given(mh)\
            {\
                MockHTTP *__mh = mh;\
                mhResponse_t *__resp;\
                mhRequestMatcher_t *__rm;
/*        Requests and high level tests */
#define   GetRequest(...)\
                __rm = mhGetRequest(__mh, __VA_ARGS__, NULL);\
                mhPushRequest(__mh, __rm);
#define   PostRequest(...)\
                __rm = mhPostRequest(__mh, __VA_ARGS__, NULL);\
                mhPushRequest(__mh, __rm);
#define     URLEqualTo(x)\
                mhMatchURLEqualTo(__mh, (x))
#define     BodyEqualTo(x)\
                mhMatchBodyEqualTo(__mh, (x))
#define     HeaderEqualTo(h, v)\
                mhMatchHeaderEqualTo(__mh, (h), (v))
#define     HeaderNotSet(h)\
                mhMatchHeaderEqualTo(__mh, (h), NULL)
/*          Network-level tests */<commit_msg>Fix variable declaration in macro's.<commit_after>/* Copyright 2014 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MockHTTP_H
#define MockHTTP_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* TODO: define defaults, eg HTTP/1.1 in req/resp */
/* TODO: use requests only once, use them in order, use best matching first */
/* TODO: any method, raw requests + responses */
/* TODO: add delay time for accept skt, response */

/* Note: the variadic macro's used here require C99. Such macro's require at
   least one argument, otherwise compilation will fail. */
#define InitMockHTTP(mh)\
            {\
                MockHTTP *__mh = (mh) = mhInit();
#define   WithHTTPserver(...)\
                mhInitHTTPserver(__mh, __VA_ARGS__, NULL);
#define   WithHTTPSserver(...)
#define   WithHTTPproxy(...)
#define     WithPort(port)\
                mhConstructServerPortSetter(__mh, port)
#define EndInit\
            }

#define Given(mh)\
            {\
                MockHTTP *__mh = mh;\
                mhResponse_t *__resp;\
                mhRequestMatcher_t *__rm;
/*        Requests and high level tests */
#define   GetRequest(...)\
                __rm = mhGetRequest(__mh, __VA_ARGS__, NULL);\
                mhPushRequest(__mh, __rm);
#define   PostRequest(...)\
                __rm = mhPostRequest(__mh, __VA_ARGS__, NULL);\
                mhPushRequest(__mh, __rm);
#define     URLEqualTo(x)\
                mhMatchURLEqualTo(__mh, (x))
#define     BodyEqualTo(x)\
                mhMatchBodyEqualTo(__mh, (x))
#define     HeaderEqualTo(h, v)\
                mhMatchHeaderEqualTo(__mh, (h), (v))
#define     HeaderNotSet(h)\
                mhMatchHeaderEqualTo(__mh, (h), NULL)
/*          Network-level tests */
{'fraction_non_alphanumeric': 0.10790408525754884, 'fraction_numerical': 0.0053285968028419185, 'mean_word_length': 2.4363081617086193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1583356', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1247, 'n_words': 436}