diff options
Diffstat (limited to 'src/testcurl/test_timeout.c')
-rw-r--r-- | src/testcurl/test_timeout.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/testcurl/test_timeout.c b/src/testcurl/test_timeout.c index 6968f000..8e2cba85 100644 --- a/src/testcurl/test_timeout.c +++ b/src/testcurl/test_timeout.c | |||
@@ -168,20 +168,39 @@ testWithoutTimeout () | |||
168 | unsigned int pos = 0; | 168 | unsigned int pos = 0; |
169 | int done_flag = 0; | 169 | int done_flag = 0; |
170 | CURLcode errornum; | 170 | CURLcode errornum; |
171 | int port; | ||
172 | |||
173 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
174 | port = 0; | ||
175 | else | ||
176 | { | ||
177 | port = 1500; | ||
178 | if (oneone) | ||
179 | port += 5; | ||
180 | } | ||
171 | 181 | ||
172 | cbc.buf = buf; | 182 | cbc.buf = buf; |
173 | cbc.size = 2048; | 183 | cbc.size = 2048; |
174 | cbc.pos = 0; | 184 | cbc.pos = 0; |
175 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 185 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
176 | 1080, | 186 | port, |
177 | NULL, NULL, &ahc_echo, &done_flag, | 187 | NULL, NULL, &ahc_echo, &done_flag, |
178 | MHD_OPTION_CONNECTION_TIMEOUT, 2, | 188 | MHD_OPTION_CONNECTION_TIMEOUT, 2, |
179 | MHD_OPTION_NOTIFY_COMPLETED, &termination_cb, &withTimeout, | 189 | MHD_OPTION_NOTIFY_COMPLETED, &termination_cb, &withTimeout, |
180 | MHD_OPTION_END); | 190 | MHD_OPTION_END); |
181 | if (d == NULL) | 191 | if (d == NULL) |
182 | return 1; | 192 | return 1; |
193 | if (0 == port) | ||
194 | { | ||
195 | const union MHD_DaemonInfo *dinfo; | ||
196 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
197 | if (NULL == dinfo || 0 == dinfo->port) | ||
198 | { MHD_stop_daemon (d); return 32; } | ||
199 | port = (int)dinfo->port; | ||
200 | } | ||
183 | c = curl_easy_init (); | 201 | c = curl_easy_init (); |
184 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); | 202 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
203 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
185 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 204 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
186 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 205 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
187 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 206 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
@@ -223,20 +242,39 @@ testWithTimeout () | |||
223 | struct CBC cbc; | 242 | struct CBC cbc; |
224 | int done_flag = 0; | 243 | int done_flag = 0; |
225 | CURLcode errornum; | 244 | CURLcode errornum; |
245 | int port; | ||
246 | |||
247 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
248 | port = 0; | ||
249 | else | ||
250 | { | ||
251 | port = 1501; | ||
252 | if (oneone) | ||
253 | port += 5; | ||
254 | } | ||
226 | 255 | ||
227 | cbc.buf = buf; | 256 | cbc.buf = buf; |
228 | cbc.size = 2048; | 257 | cbc.size = 2048; |
229 | cbc.pos = 0; | 258 | cbc.pos = 0; |
230 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 259 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
231 | 1080, | 260 | port, |
232 | NULL, NULL, &ahc_echo, &done_flag, | 261 | NULL, NULL, &ahc_echo, &done_flag, |
233 | MHD_OPTION_CONNECTION_TIMEOUT, 2, | 262 | MHD_OPTION_CONNECTION_TIMEOUT, 2, |
234 | MHD_OPTION_NOTIFY_COMPLETED, &termination_cb, &withoutTimeout, | 263 | MHD_OPTION_NOTIFY_COMPLETED, &termination_cb, &withoutTimeout, |
235 | MHD_OPTION_END); | 264 | MHD_OPTION_END); |
236 | if (d == NULL) | 265 | if (d == NULL) |
237 | return 16; | 266 | return 16; |
267 | if (0 == port) | ||
268 | { | ||
269 | const union MHD_DaemonInfo *dinfo; | ||
270 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
271 | if (NULL == dinfo || 0 == dinfo->port) | ||
272 | { MHD_stop_daemon (d); return 32; } | ||
273 | port = (int)dinfo->port; | ||
274 | } | ||
238 | c = curl_easy_init (); | 275 | c = curl_easy_init (); |
239 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); | 276 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
277 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
240 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 278 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
241 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 279 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
242 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer_fail); | 280 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer_fail); |