diff options
Diffstat (limited to 'src/testcurl/test_postform.c')
-rw-r--r-- | src/testcurl/test_postform.c | 92 |
1 files changed, 84 insertions, 8 deletions
diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c index 76b84824..d7fd14a0 100644 --- a/src/testcurl/test_postform.c +++ b/src/testcurl/test_postform.c | |||
@@ -179,18 +179,37 @@ testInternalPost () | |||
179 | struct CBC cbc; | 179 | struct CBC cbc; |
180 | CURLcode errornum; | 180 | CURLcode errornum; |
181 | struct curl_httppost *pd; | 181 | struct curl_httppost *pd; |
182 | int port; | ||
183 | |||
184 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
185 | port = 0; | ||
186 | else | ||
187 | { | ||
188 | port = 1390; | ||
189 | if (oneone) | ||
190 | port += 10; | ||
191 | } | ||
182 | 192 | ||
183 | cbc.buf = buf; | 193 | cbc.buf = buf; |
184 | cbc.size = 2048; | 194 | cbc.size = 2048; |
185 | cbc.pos = 0; | 195 | cbc.pos = 0; |
186 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 196 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
187 | 1080, NULL, NULL, &ahc_echo, NULL, | 197 | port, NULL, NULL, &ahc_echo, NULL, |
188 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 198 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
189 | MHD_OPTION_END); | 199 | MHD_OPTION_END); |
190 | if (d == NULL) | 200 | if (d == NULL) |
191 | return 1; | 201 | return 1; |
202 | if (0 == port) | ||
203 | { | ||
204 | const union MHD_DaemonInfo *dinfo; | ||
205 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
206 | if (NULL == dinfo || 0 == dinfo->port) | ||
207 | { MHD_stop_daemon (d); return 32; } | ||
208 | port = (int)dinfo->port; | ||
209 | } | ||
192 | c = curl_easy_init (); | 210 | c = curl_easy_init (); |
193 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); | 211 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
212 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
194 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 213 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
195 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 214 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
196 | pd = make_form (); | 215 | pd = make_form (); |
@@ -235,18 +254,37 @@ testMultithreadedPost () | |||
235 | struct CBC cbc; | 254 | struct CBC cbc; |
236 | CURLcode errornum; | 255 | CURLcode errornum; |
237 | struct curl_httppost *pd; | 256 | struct curl_httppost *pd; |
257 | int port; | ||
258 | |||
259 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
260 | port = 0; | ||
261 | else | ||
262 | { | ||
263 | port = 1390; | ||
264 | if (oneone) | ||
265 | port += 10; | ||
266 | } | ||
238 | 267 | ||
239 | cbc.buf = buf; | 268 | cbc.buf = buf; |
240 | cbc.size = 2048; | 269 | cbc.size = 2048; |
241 | cbc.pos = 0; | 270 | cbc.pos = 0; |
242 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 271 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
243 | 1081, NULL, NULL, &ahc_echo, NULL, | 272 | port, NULL, NULL, &ahc_echo, NULL, |
244 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 273 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
245 | MHD_OPTION_END); | 274 | MHD_OPTION_END); |
246 | if (d == NULL) | 275 | if (d == NULL) |
247 | return 16; | 276 | return 16; |
277 | if (0 == port) | ||
278 | { | ||
279 | const union MHD_DaemonInfo *dinfo; | ||
280 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
281 | if (NULL == dinfo || 0 == dinfo->port) | ||
282 | { MHD_stop_daemon (d); return 32; } | ||
283 | port = (int)dinfo->port; | ||
284 | } | ||
248 | c = curl_easy_init (); | 285 | c = curl_easy_init (); |
249 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); | 286 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
287 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
250 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 288 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
251 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 289 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
252 | pd = make_form (); | 290 | pd = make_form (); |
@@ -291,19 +329,38 @@ testMultithreadedPoolPost () | |||
291 | struct CBC cbc; | 329 | struct CBC cbc; |
292 | CURLcode errornum; | 330 | CURLcode errornum; |
293 | struct curl_httppost *pd; | 331 | struct curl_httppost *pd; |
332 | int port; | ||
333 | |||
334 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
335 | port = 0; | ||
336 | else | ||
337 | { | ||
338 | port = 1391; | ||
339 | if (oneone) | ||
340 | port += 10; | ||
341 | } | ||
294 | 342 | ||
295 | cbc.buf = buf; | 343 | cbc.buf = buf; |
296 | cbc.size = 2048; | 344 | cbc.size = 2048; |
297 | cbc.pos = 0; | 345 | cbc.pos = 0; |
298 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 346 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
299 | 1081, NULL, NULL, &ahc_echo, NULL, | 347 | port, NULL, NULL, &ahc_echo, NULL, |
300 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, | 348 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, |
301 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 349 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
302 | MHD_OPTION_END); | 350 | MHD_OPTION_END); |
303 | if (d == NULL) | 351 | if (d == NULL) |
304 | return 16; | 352 | return 16; |
353 | if (0 == port) | ||
354 | { | ||
355 | const union MHD_DaemonInfo *dinfo; | ||
356 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
357 | if (NULL == dinfo || 0 == dinfo->port) | ||
358 | { MHD_stop_daemon (d); return 32; } | ||
359 | port = (int)dinfo->port; | ||
360 | } | ||
305 | c = curl_easy_init (); | 361 | c = curl_easy_init (); |
306 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); | 362 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
363 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
307 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 364 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
308 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 365 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
309 | pd = make_form (); | 366 | pd = make_form (); |
@@ -362,19 +419,38 @@ testExternalPost () | |||
362 | time_t start; | 419 | time_t start; |
363 | struct timeval tv; | 420 | struct timeval tv; |
364 | struct curl_httppost *pd; | 421 | struct curl_httppost *pd; |
422 | int port; | ||
423 | |||
424 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
425 | port = 0; | ||
426 | else | ||
427 | { | ||
428 | port = 1392; | ||
429 | if (oneone) | ||
430 | port += 10; | ||
431 | } | ||
365 | 432 | ||
366 | multi = NULL; | 433 | multi = NULL; |
367 | cbc.buf = buf; | 434 | cbc.buf = buf; |
368 | cbc.size = 2048; | 435 | cbc.size = 2048; |
369 | cbc.pos = 0; | 436 | cbc.pos = 0; |
370 | d = MHD_start_daemon (MHD_USE_ERROR_LOG, | 437 | d = MHD_start_daemon (MHD_USE_ERROR_LOG, |
371 | 1082, NULL, NULL, &ahc_echo, NULL, | 438 | port, NULL, NULL, &ahc_echo, NULL, |
372 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 439 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
373 | MHD_OPTION_END); | 440 | MHD_OPTION_END); |
374 | if (d == NULL) | 441 | if (d == NULL) |
375 | return 256; | 442 | return 256; |
443 | if (0 == port) | ||
444 | { | ||
445 | const union MHD_DaemonInfo *dinfo; | ||
446 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
447 | if (NULL == dinfo || 0 == dinfo->port) | ||
448 | { MHD_stop_daemon (d); return 32; } | ||
449 | port = (int)dinfo->port; | ||
450 | } | ||
376 | c = curl_easy_init (); | 451 | c = curl_easy_init (); |
377 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); | 452 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
453 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
378 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 454 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
379 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 455 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
380 | pd = make_form (); | 456 | pd = make_form (); |