diff options
Diffstat (limited to 'src/testzzuf/test_long_header.c')
-rw-r--r-- | src/testzzuf/test_long_header.c | 164 |
1 files changed, 83 insertions, 81 deletions
diff --git a/src/testzzuf/test_long_header.c b/src/testzzuf/test_long_header.c index 12a396bb..5ffaf272 100644 --- a/src/testzzuf/test_long_header.c +++ b/src/testzzuf/test_long_header.c | |||
@@ -43,14 +43,14 @@ | |||
43 | * half of this value, so the actual value does not have | 43 | * half of this value, so the actual value does not have |
44 | * to be big at all... | 44 | * to be big at all... |
45 | */ | 45 | */ |
46 | #define VERY_LONG (1024*10) | 46 | #define VERY_LONG (1024 * 10) |
47 | 47 | ||
48 | static int oneone; | 48 | static int oneone; |
49 | 49 | ||
50 | static int | 50 | static int |
51 | apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) | 51 | apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
52 | { | 52 | { |
53 | (void)cls;(void)addr;(void)addrlen; /* Unused. Silent compiler warning. */ | 53 | (void) cls; (void) addr; (void) addrlen; /* Unused. Silent compiler warning. */ |
54 | return MHD_YES; | 54 | return MHD_YES; |
55 | } | 55 | } |
56 | 56 | ||
@@ -64,7 +64,7 @@ struct CBC | |||
64 | static size_t | 64 | static size_t |
65 | copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) | 65 | copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) |
66 | { | 66 | { |
67 | (void)ptr;(void)ctx; /* Unused. Silent compiler warning. */ | 67 | (void) ptr; (void) ctx; /* Unused. Silent compiler warning. */ |
68 | return size * nmemb; | 68 | return size * nmemb; |
69 | } | 69 | } |
70 | 70 | ||
@@ -80,14 +80,14 @@ ahc_echo (void *cls, | |||
80 | const char *me = cls; | 80 | const char *me = cls; |
81 | struct MHD_Response *response; | 81 | struct MHD_Response *response; |
82 | int ret; | 82 | int ret; |
83 | (void)version;(void)upload_data; /* Unused. Silent compiler warning. */ | 83 | (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ |
84 | (void)upload_data_size;(void)unused; /* Unused. Silent compiler warning. */ | 84 | (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */ |
85 | 85 | ||
86 | if (0 != strcmp (me, method)) | 86 | if (0 != strcmp (me, method)) |
87 | return MHD_NO; /* unexpected method */ | 87 | return MHD_NO; /* unexpected method */ |
88 | response = MHD_create_response_from_buffer (strlen (url), | 88 | response = MHD_create_response_from_buffer (strlen (url), |
89 | (void *) url, | 89 | (void *) url, |
90 | MHD_RESPMEM_MUST_COPY); | 90 | MHD_RESPMEM_MUST_COPY); |
91 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 91 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
92 | MHD_destroy_response (response); | 92 | MHD_destroy_response (response); |
93 | return ret; | 93 | return ret; |
@@ -107,46 +107,47 @@ testLongUrlGet () | |||
107 | cbc.buf = buf; | 107 | cbc.buf = buf; |
108 | cbc.size = 2048; | 108 | cbc.size = 2048; |
109 | cbc.pos = 0; | 109 | cbc.pos = 0; |
110 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , | 110 | d = MHD_start_daemon ( |
111 | 11080, | 111 | MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */, |
112 | &apc_all, | 112 | 11080, |
113 | NULL, | 113 | &apc_all, |
114 | &ahc_echo, | 114 | NULL, |
115 | "GET", | 115 | &ahc_echo, |
116 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 116 | "GET", |
117 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); | 117 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
118 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); | ||
118 | 119 | ||
119 | if (d == NULL) | 120 | if (d == NULL) |
120 | return 1; | 121 | return 1; |
121 | zzuf_socat_start (); | 122 | zzuf_socat_start (); |
122 | for (i = 0; i < LOOP_COUNT; i++) | 123 | for (i = 0; i < LOOP_COUNT; i++) |
123 | { | 124 | { |
124 | fprintf (stderr, "."); | 125 | fprintf (stderr, "."); |
125 | 126 | ||
126 | c = curl_easy_init (); | 127 | c = curl_easy_init (); |
127 | url = malloc (VERY_LONG); | 128 | url = malloc (VERY_LONG); |
128 | memset (url, 'a', VERY_LONG); | 129 | memset (url, 'a', VERY_LONG); |
129 | url[VERY_LONG - 1] = '\0'; | 130 | url[VERY_LONG - 1] = '\0'; |
130 | memcpy (url, "http://127.0.0.1:11081/", | 131 | memcpy (url, "http://127.0.0.1:11081/", |
131 | strlen ("http://127.0.0.1:11081/")); | 132 | strlen ("http://127.0.0.1:11081/")); |
132 | curl_easy_setopt (c, CURLOPT_URL, url); | 133 | curl_easy_setopt (c, CURLOPT_URL, url); |
133 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 134 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
134 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 135 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
135 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 136 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
136 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 137 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
137 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 138 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
138 | if (oneone) | 139 | if (oneone) |
139 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 140 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
140 | else | 141 | else |
141 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 142 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
142 | /* NOTE: use of CONNECTTIMEOUT without also | 143 | /* NOTE: use of CONNECTTIMEOUT without also |
143 | * setting NOSIGNAL results in really weird | 144 | * setting NOSIGNAL results in really weird |
144 | * crashes on my system! */ | 145 | * crashes on my system! */ |
145 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 146 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
146 | curl_easy_perform (c); | 147 | curl_easy_perform (c); |
147 | curl_easy_cleanup (c); | 148 | curl_easy_cleanup (c); |
148 | free (url); | 149 | free (url); |
149 | } | 150 | } |
150 | fprintf (stderr, "\n"); | 151 | fprintf (stderr, "\n"); |
151 | zzuf_socat_stop (); | 152 | zzuf_socat_stop (); |
152 | 153 | ||
@@ -169,49 +170,50 @@ testLongHeaderGet () | |||
169 | cbc.buf = buf; | 170 | cbc.buf = buf; |
170 | cbc.size = 2048; | 171 | cbc.size = 2048; |
171 | cbc.pos = 0; | 172 | cbc.pos = 0; |
172 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , | 173 | d = MHD_start_daemon ( |
173 | 11080, | 174 | MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */, |
174 | &apc_all, | 175 | 11080, |
175 | NULL, | 176 | &apc_all, |
176 | &ahc_echo, | 177 | NULL, |
177 | "GET", | 178 | &ahc_echo, |
178 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 179 | "GET", |
179 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); | 180 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
181 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); | ||
180 | if (d == NULL) | 182 | if (d == NULL) |
181 | return 16; | 183 | return 16; |
182 | zzuf_socat_start (); | 184 | zzuf_socat_start (); |
183 | for (i = 0; i < LOOP_COUNT; i++) | 185 | for (i = 0; i < LOOP_COUNT; i++) |
184 | { | 186 | { |
185 | fprintf (stderr, "."); | 187 | fprintf (stderr, "."); |
186 | c = curl_easy_init (); | 188 | c = curl_easy_init (); |
187 | url = malloc (VERY_LONG); | 189 | url = malloc (VERY_LONG); |
188 | memset (url, 'a', VERY_LONG); | 190 | memset (url, 'a', VERY_LONG); |
189 | url[VERY_LONG - 1] = '\0'; | 191 | url[VERY_LONG - 1] = '\0'; |
190 | url[VERY_LONG / 2] = ':'; | 192 | url[VERY_LONG / 2] = ':'; |
191 | url[VERY_LONG / 2 + 1] = ' '; | 193 | url[VERY_LONG / 2 + 1] = ' '; |
192 | header = curl_slist_append (header, url); | 194 | header = curl_slist_append (header, url); |
193 | 195 | ||
194 | curl_easy_setopt (c, CURLOPT_HTTPHEADER, header); | 196 | curl_easy_setopt (c, CURLOPT_HTTPHEADER, header); |
195 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); | 197 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); |
196 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 198 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
197 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 199 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
198 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 200 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
199 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 201 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
200 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 202 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
201 | if (oneone) | 203 | if (oneone) |
202 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 204 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
203 | else | 205 | else |
204 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 206 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
205 | /* NOTE: use of CONNECTTIMEOUT without also | 207 | /* NOTE: use of CONNECTTIMEOUT without also |
206 | * setting NOSIGNAL results in really weird | 208 | * setting NOSIGNAL results in really weird |
207 | * crashes on my system! */ | 209 | * crashes on my system! */ |
208 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 210 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
209 | curl_easy_perform (c); | 211 | curl_easy_perform (c); |
210 | curl_slist_free_all (header); | 212 | curl_slist_free_all (header); |
211 | header = NULL; | 213 | header = NULL; |
212 | curl_easy_cleanup (c); | 214 | curl_easy_cleanup (c); |
213 | free (url); | 215 | free (url); |
214 | } | 216 | } |
215 | fprintf (stderr, "\n"); | 217 | fprintf (stderr, "\n"); |
216 | zzuf_socat_stop (); | 218 | zzuf_socat_stop (); |
217 | 219 | ||