diff options
Diffstat (limited to 'src/testzzuf/daemontest_long_header.c')
-rw-r--r-- | src/testzzuf/daemontest_long_header.c | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/src/testzzuf/daemontest_long_header.c b/src/testzzuf/daemontest_long_header.c index 385b9776..42bd1114 100644 --- a/src/testzzuf/daemontest_long_header.c +++ b/src/testzzuf/daemontest_long_header.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | (C) 2007 Christian Grothoff | 3 | (C) 2007, 2008 Christian Grothoff |
4 | 4 | ||
5 | libmicrohttpd is free software; you can redistribute it and/or modify | 5 | libmicrohttpd is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -35,6 +35,18 @@ | |||
35 | #include <unistd.h> | 35 | #include <unistd.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include "socat.c" | ||
39 | |||
40 | /** | ||
41 | * A larger loop count will run more random tests -- | ||
42 | * which would be good, except that it may take too | ||
43 | * long for most user's patience. So this small | ||
44 | * value is the default. | ||
45 | */ | ||
46 | #define LOOP_COUNT 10 | ||
47 | |||
48 | #define CURL_TIMEOUT 50L | ||
49 | |||
38 | /** | 50 | /** |
39 | * We will set the memory available per connection to | 51 | * We will set the memory available per connection to |
40 | * half of this value, so the actual value does not have | 52 | * half of this value, so the actual value does not have |
@@ -94,13 +106,13 @@ testLongUrlGet () | |||
94 | char buf[2048]; | 106 | char buf[2048]; |
95 | struct CBC cbc; | 107 | struct CBC cbc; |
96 | char *url; | 108 | char *url; |
97 | long code; | 109 | int i; |
98 | 110 | ||
99 | cbc.buf = buf; | 111 | cbc.buf = buf; |
100 | cbc.size = 2048; | 112 | cbc.size = 2048; |
101 | cbc.pos = 0; | 113 | cbc.pos = 0; |
102 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */ , | 114 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */ , |
103 | 1080, | 115 | 11080, |
104 | &apc_all, | 116 | &apc_all, |
105 | NULL, | 117 | NULL, |
106 | &ahc_echo, | 118 | &ahc_echo, |
@@ -109,44 +121,39 @@ testLongUrlGet () | |||
109 | VERY_LONG / 2, MHD_OPTION_END); | 121 | VERY_LONG / 2, MHD_OPTION_END); |
110 | if (d == NULL) | 122 | if (d == NULL) |
111 | return 1; | 123 | return 1; |
112 | c = curl_easy_init (); | 124 | zzuf_socat_start (); |
113 | url = malloc (VERY_LONG); | 125 | for (i = 0; i < LOOP_COUNT; i++) |
114 | memset (url, 'a', VERY_LONG); | ||
115 | url[VERY_LONG - 1] = '\0'; | ||
116 | memcpy (url, "http://localhost:1080/", strlen ("http://localhost:1080/")); | ||
117 | curl_easy_setopt (c, CURLOPT_URL, url); | ||
118 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
119 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
120 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
121 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | ||
122 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | ||
123 | if (oneone) | ||
124 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
125 | else | ||
126 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
127 | // NOTE: use of CONNECTTIMEOUT without also | ||
128 | // setting NOSIGNAL results in really weird | ||
129 | // crashes on my system! | ||
130 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
131 | if (CURLE_OK == curl_easy_perform (c)) | ||
132 | { | 126 | { |
127 | fprintf (stderr, "."); | ||
128 | |||
129 | c = curl_easy_init (); | ||
130 | url = malloc (VERY_LONG); | ||
131 | memset (url, 'a', VERY_LONG); | ||
132 | url[VERY_LONG - 1] = '\0'; | ||
133 | memcpy (url, "http://localhost:11081/", | ||
134 | strlen ("http://localhost:11081/")); | ||
135 | curl_easy_setopt (c, CURLOPT_URL, url); | ||
136 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
137 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
138 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
139 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
140 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
141 | if (oneone) | ||
142 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
143 | else | ||
144 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
145 | // NOTE: use of CONNECTTIMEOUT without also | ||
146 | // setting NOSIGNAL results in really weird | ||
147 | // crashes on my system! | ||
148 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
149 | curl_easy_perform (c); | ||
133 | curl_easy_cleanup (c); | 150 | curl_easy_cleanup (c); |
134 | MHD_stop_daemon (d); | ||
135 | free (url); | ||
136 | return 2; | ||
137 | } | 151 | } |
138 | if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) | 152 | fprintf (stderr, "\n"); |
139 | { | 153 | zzuf_socat_stop (); |
140 | curl_easy_cleanup (c); | 154 | |
141 | MHD_stop_daemon (d); | ||
142 | free (url); | ||
143 | return 4; | ||
144 | } | ||
145 | curl_easy_cleanup (c); | ||
146 | MHD_stop_daemon (d); | 155 | MHD_stop_daemon (d); |
147 | free (url); | 156 | free (url); |
148 | if (code != MHD_HTTP_REQUEST_URI_TOO_LONG) | ||
149 | return 8; | ||
150 | return 0; | 157 | return 0; |
151 | } | 158 | } |
152 | 159 | ||
@@ -159,8 +166,8 @@ testLongHeaderGet () | |||
159 | char buf[2048]; | 166 | char buf[2048]; |
160 | struct CBC cbc; | 167 | struct CBC cbc; |
161 | char *url; | 168 | char *url; |
162 | long code; | ||
163 | struct curl_slist *header = NULL; | 169 | struct curl_slist *header = NULL; |
170 | int i; | ||
164 | 171 | ||
165 | cbc.buf = buf; | 172 | cbc.buf = buf; |
166 | cbc.size = 2048; | 173 | cbc.size = 2048; |
@@ -175,51 +182,44 @@ testLongHeaderGet () | |||
175 | VERY_LONG / 2, MHD_OPTION_END); | 182 | VERY_LONG / 2, MHD_OPTION_END); |
176 | if (d == NULL) | 183 | if (d == NULL) |
177 | return 16; | 184 | return 16; |
178 | c = curl_easy_init (); | 185 | zzuf_socat_start (); |
179 | url = malloc (VERY_LONG); | 186 | for (i = 0; i < LOOP_COUNT; i++) |
180 | memset (url, 'a', VERY_LONG); | ||
181 | url[VERY_LONG - 1] = '\0'; | ||
182 | url[VERY_LONG / 2] = ':'; | ||
183 | url[VERY_LONG / 2 + 1] = ':'; | ||
184 | header = curl_slist_append (header, url); | ||
185 | |||
186 | curl_easy_setopt (c, CURLOPT_HTTPHEADER, header); | ||
187 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world"); | ||
188 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
189 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
190 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
191 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | ||
192 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | ||
193 | if (oneone) | ||
194 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
195 | else | ||
196 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
197 | // NOTE: use of CONNECTTIMEOUT without also | ||
198 | // setting NOSIGNAL results in really weird | ||
199 | // crashes on my system! | ||
200 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
201 | if (CURLE_OK == curl_easy_perform (c)) | ||
202 | { | ||
203 | curl_easy_cleanup (c); | ||
204 | MHD_stop_daemon (d); | ||
205 | curl_slist_free_all (header); | ||
206 | free (url); | ||
207 | return 32; | ||
208 | } | ||
209 | if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) | ||
210 | { | 187 | { |
188 | fprintf (stderr, "."); | ||
189 | |||
190 | |||
191 | c = curl_easy_init (); | ||
192 | url = malloc (VERY_LONG); | ||
193 | memset (url, 'a', VERY_LONG); | ||
194 | url[VERY_LONG - 1] = '\0'; | ||
195 | url[VERY_LONG / 2] = ':'; | ||
196 | url[VERY_LONG / 2 + 1] = ':'; | ||
197 | header = curl_slist_append (header, url); | ||
198 | |||
199 | curl_easy_setopt (c, CURLOPT_HTTPHEADER, header); | ||
200 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world"); | ||
201 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
202 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
203 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
204 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
205 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
206 | if (oneone) | ||
207 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
208 | else | ||
209 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
210 | // NOTE: use of CONNECTTIMEOUT without also | ||
211 | // setting NOSIGNAL results in really weird | ||
212 | // crashes on my system! | ||
213 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
214 | curl_easy_perform (c); | ||
211 | curl_slist_free_all (header); | 215 | curl_slist_free_all (header); |
212 | curl_easy_cleanup (c); | 216 | curl_easy_cleanup (c); |
213 | MHD_stop_daemon (d); | ||
214 | free (url); | ||
215 | return 64; | ||
216 | } | 217 | } |
217 | curl_slist_free_all (header); | 218 | fprintf (stderr, "\n"); |
218 | curl_easy_cleanup (c); | 219 | zzuf_socat_stop (); |
220 | |||
219 | MHD_stop_daemon (d); | 221 | MHD_stop_daemon (d); |
220 | free (url); | 222 | free (url); |
221 | if (code != MHD_HTTP_REQUEST_ENTITY_TOO_LARGE) | ||
222 | return 128; | ||
223 | return 0; | 223 | return 0; |
224 | } | 224 | } |
225 | 225 | ||