aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-06-16 00:41:21 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-06-16 00:42:44 +0300
commite8d937beb5e0bf118c381846f2392cab973a2528 (patch)
treea7bec6dece0675986811e967d7e9756cc19e415a /src
parent36bf651023e2f810bd2ae4aa1ab2354338b9f00c (diff)
downloadlibmicrohttpd-e8d937beb5e0bf118c381846f2392cab973a2528.tar.gz
libmicrohttpd-e8d937beb5e0bf118c381846f2392cab973a2528.zip
Make testsuite parallel build compatible (part 1)
Diffstat (limited to 'src')
-rw-r--r--src/microhttpd/test_daemon.c14
-rw-r--r--src/microhttpd/test_upgrade.c14
-rw-r--r--src/testcurl/perf_get.c52
-rw-r--r--src/testcurl/perf_get_concurrent.c48
-rw-r--r--src/testcurl/test_callback.c21
-rw-r--r--src/testcurl/test_concurrent_stop.c25
-rw-r--r--src/testcurl/test_delete.c76
-rw-r--r--src/testcurl/test_digestauth.c20
-rw-r--r--src/testcurl/test_digestauth_with_arguments.c20
-rw-r--r--src/testcurl/test_get.c173
-rw-r--r--src/testcurl/test_get_chunked.c76
-rw-r--r--src/testcurl/test_get_response_cleanup.c98
-rw-r--r--src/testcurl/test_get_sendfile.c125
-rw-r--r--src/testcurl/test_iplimit.c45
-rw-r--r--src/testcurl/test_large_put.c100
-rw-r--r--src/testcurl/test_long_header.c45
-rw-r--r--src/testcurl/test_options.c8
-rw-r--r--src/testcurl/test_parse_cookies.c23
-rw-r--r--src/testcurl/test_post.c115
-rw-r--r--src/testcurl/test_post_loop.c88
-rw-r--r--src/testcurl/test_postform.c92
-rw-r--r--src/testcurl/test_process_arguments.c23
-rw-r--r--src/testcurl/test_process_headers.c96
-rw-r--r--src/testcurl/test_put.c94
-rw-r--r--src/testcurl/test_put_chunked.c76
-rw-r--r--src/testcurl/test_quiesce.c38
-rw-r--r--src/testcurl/test_quiesce_stream.c25
-rw-r--r--src/testcurl/test_start_stop.c8
-rw-r--r--src/testcurl/test_termination.c20
-rw-r--r--src/testcurl/test_timeout.c46
-rw-r--r--src/testcurl/test_urlparse.c23
31 files changed, 1537 insertions, 190 deletions
diff --git a/src/microhttpd/test_daemon.c b/src/microhttpd/test_daemon.c
index 9fc8e16d..bd201512 100644
--- a/src/microhttpd/test_daemon.c
+++ b/src/microhttpd/test_daemon.c
@@ -89,7 +89,7 @@ testStartStop ()
89 struct MHD_Daemon *d; 89 struct MHD_Daemon *d;
90 90
91 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 91 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
92 1080, 92 0,
93 &apc_nothing, NULL, 93 &apc_nothing, NULL,
94 &ahc_nothing, NULL, 94 &ahc_nothing, NULL,
95 MHD_OPTION_END); 95 MHD_OPTION_END);
@@ -97,7 +97,7 @@ testStartStop ()
97 { 97 {
98 fprintf (stderr, 98 fprintf (stderr,
99 "Failed to start daemon on port %u\n", 99 "Failed to start daemon on port %u\n",
100 1080); 100 0);
101 exit (77); 101 exit (77);
102 } 102 }
103 MHD_stop_daemon (d); 103 MHD_stop_daemon (d);
@@ -114,7 +114,7 @@ testExternalRun ()
114 int i; 114 int i;
115 115
116 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 116 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
117 1081, 117 0,
118 &apc_all, NULL, 118 &apc_all, NULL,
119 &ahc_nothing, NULL, 119 &ahc_nothing, NULL,
120 MHD_OPTION_END); 120 MHD_OPTION_END);
@@ -123,7 +123,7 @@ testExternalRun ()
123 { 123 {
124 fprintf (stderr, 124 fprintf (stderr,
125 "Failed to start daemon on port %u\n", 125 "Failed to start daemon on port %u\n",
126 1081); 126 0);
127 exit (77); 127 exit (77);
128 } 128 }
129 i = 0; 129 i = 0;
@@ -158,7 +158,7 @@ testThread ()
158 struct MHD_Daemon *d; 158 struct MHD_Daemon *d;
159 159
160 d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_INTERNAL_POLLING_THREAD, 160 d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_INTERNAL_POLLING_THREAD,
161 1082, 161 0,
162 &apc_all, NULL, 162 &apc_all, NULL,
163 &ahc_nothing, NULL, 163 &ahc_nothing, NULL,
164 MHD_OPTION_END); 164 MHD_OPTION_END);
@@ -187,7 +187,7 @@ testMultithread ()
187 struct MHD_Daemon *d; 187 struct MHD_Daemon *d;
188 188
189 d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION, 189 d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION,
190 1083, 190 0,
191 &apc_all, NULL, 191 &apc_all, NULL,
192 &ahc_nothing, NULL, 192 &ahc_nothing, NULL,
193 MHD_OPTION_END); 193 MHD_OPTION_END);
@@ -196,7 +196,7 @@ testMultithread ()
196 { 196 {
197 fprintf (stderr, 197 fprintf (stderr,
198 "Failed to start daemon on port %u\n", 198 "Failed to start daemon on port %u\n",
199 1083); 199 0);
200 exit (77); 200 exit (77);
201 } 201 }
202 if (MHD_run (d) != MHD_NO) 202 if (MHD_run (d) != MHD_NO)
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 64b47e5d..b1a234cb 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -982,6 +982,7 @@ test_upgrade (int flags,
982 wr_socket sock; 982 wr_socket sock;
983 struct sockaddr_in sa; 983 struct sockaddr_in sa;
984 const union MHD_DaemonInfo *real_flags; 984 const union MHD_DaemonInfo *real_flags;
985 const union MHD_DaemonInfo *dinfo;
985#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) 986#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID)
986 pid_t pid = -1; 987 pid_t pid = -1;
987#endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ 988#endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */
@@ -990,7 +991,8 @@ test_upgrade (int flags,
990 991
991 if (!test_tls) 992 if (!test_tls)
992 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE, 993 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE,
993 1080, 994 MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT) ?
995 0 : 1090,
994 NULL, NULL, 996 NULL, NULL,
995 &ahc_upgrade, NULL, 997 &ahc_upgrade, NULL,
996 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 998 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
@@ -1001,7 +1003,8 @@ test_upgrade (int flags,
1001#ifdef HTTPS_SUPPORT 1003#ifdef HTTPS_SUPPORT
1002 else 1004 else
1003 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | MHD_USE_TLS, 1005 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | MHD_USE_TLS,
1004 1080, 1006 MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT) ?
1007 0 : 1090,
1005 NULL, NULL, 1008 NULL, NULL,
1006 &ahc_upgrade, NULL, 1009 &ahc_upgrade, NULL,
1007 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 1010 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
@@ -1017,13 +1020,16 @@ test_upgrade (int flags,
1017 real_flags = MHD_get_daemon_info(d, MHD_DAEMON_INFO_FLAGS); 1020 real_flags = MHD_get_daemon_info(d, MHD_DAEMON_INFO_FLAGS);
1018 if (NULL == real_flags) 1021 if (NULL == real_flags)
1019 abort (); 1022 abort ();
1023 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
1024 if (NULL == dinfo || 0 == dinfo->port)
1025 abort ();
1020 if (!test_tls || TLS_LIB_GNUTLS == use_tls_tool) 1026 if (!test_tls || TLS_LIB_GNUTLS == use_tls_tool)
1021 { 1027 {
1022 sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); 1028 sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt ();
1023 if (WR_BAD == sock) 1029 if (WR_BAD == sock)
1024 abort (); 1030 abort ();
1025 sa.sin_family = AF_INET; 1031 sa.sin_family = AF_INET;
1026 sa.sin_port = htons (1080); 1032 sa.sin_port = htons (dinfo->port);
1027 sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); 1033 sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
1028 if (0 != wr_connect (sock, 1034 if (0 != wr_connect (sock,
1029 (struct sockaddr *) &sa, 1035 (struct sockaddr *) &sa,
@@ -1034,7 +1040,7 @@ test_upgrade (int flags,
1034 { 1040 {
1035#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) 1041#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID)
1036 MHD_socket tls_fork_sock; 1042 MHD_socket tls_fork_sock;
1037 if (-1 == (pid = gnutlscli_connect (&tls_fork_sock, 1080))) 1043 if (-1 == (pid = gnutlscli_connect (&tls_fork_sock, dinfo->port)))
1038 { 1044 {
1039 MHD_stop_daemon (d); 1045 MHD_stop_daemon (d);
1040 return 4; 1046 return 4;
diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c
index b215c837..8e5902d8 100644
--- a/src/testcurl/perf_get.c
+++ b/src/testcurl/perf_get.c
@@ -188,7 +188,8 @@ testInternalGet (int port, int poll_flag)
188 unsigned int i; 188 unsigned int i;
189 char url[64]; 189 char url[64];
190 190
191 sprintf(url, "http://127.0.0.1:%d/hello_world", port); 191 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
192 port = 0;
192 193
193 cbc.buf = buf; 194 cbc.buf = buf;
194 cbc.size = 2048; 195 cbc.size = 2048;
@@ -196,6 +197,15 @@ testInternalGet (int port, int poll_flag)
196 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 197 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
197 if (d == NULL) 198 if (d == NULL)
198 return 1; 199 return 1;
200 if (0 == port)
201 {
202 const union MHD_DaemonInfo *dinfo;
203 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
204 if (NULL == dinfo || 0 == dinfo->port)
205 { MHD_stop_daemon (d); return 32; }
206 port = (int)dinfo->port;
207 }
208 sprintf(url, "http://127.0.0.1:%d/hello_world", port);
199 start_timer (); 209 start_timer ();
200 for (i=0;i<ROUNDS;i++) 210 for (i=0;i<ROUNDS;i++)
201 { 211 {
@@ -249,7 +259,8 @@ testMultithreadedGet (int port, int poll_flag)
249 unsigned int i; 259 unsigned int i;
250 char url[64]; 260 char url[64];
251 261
252 sprintf(url, "http://127.0.0.1:%d/hello_world", port); 262 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
263 port = 0;
253 264
254 cbc.buf = buf; 265 cbc.buf = buf;
255 cbc.size = 2048; 266 cbc.size = 2048;
@@ -257,6 +268,15 @@ testMultithreadedGet (int port, int poll_flag)
257 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 268 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
258 if (d == NULL) 269 if (d == NULL)
259 return 16; 270 return 16;
271 if (0 == port)
272 {
273 const union MHD_DaemonInfo *dinfo;
274 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
275 if (NULL == dinfo || 0 == dinfo->port)
276 { MHD_stop_daemon (d); return 32; }
277 port = (int)dinfo->port;
278 }
279 sprintf(url, "http://127.0.0.1:%d/hello_world", port);
260 start_timer (); 280 start_timer ();
261 for (i=0;i<ROUNDS;i++) 281 for (i=0;i<ROUNDS;i++)
262 { 282 {
@@ -310,7 +330,8 @@ testMultithreadedPoolGet (int port, int poll_flag)
310 unsigned int i; 330 unsigned int i;
311 char url[64]; 331 char url[64];
312 332
313 sprintf(url, "http://127.0.0.1:%d/hello_world", port); 333 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
334 port = 0;
314 335
315 cbc.buf = buf; 336 cbc.buf = buf;
316 cbc.size = 2048; 337 cbc.size = 2048;
@@ -319,6 +340,15 @@ testMultithreadedPoolGet (int port, int poll_flag)
319 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 340 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
320 if (d == NULL) 341 if (d == NULL)
321 return 16; 342 return 16;
343 if (0 == port)
344 {
345 const union MHD_DaemonInfo *dinfo;
346 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
347 if (NULL == dinfo || 0 == dinfo->port)
348 { MHD_stop_daemon (d); return 32; }
349 port = (int)dinfo->port;
350 }
351 sprintf(url, "http://127.0.0.1:%d/hello_world", port);
322 start_timer (); 352 start_timer ();
323 for (i=0;i<ROUNDS;i++) 353 for (i=0;i<ROUNDS;i++)
324 { 354 {
@@ -385,7 +415,8 @@ testExternalGet (int port)
385 unsigned int i; 415 unsigned int i;
386 char url[64]; 416 char url[64];
387 417
388 sprintf(url, "http://127.0.0.1:%d/hello_world", port); 418 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
419 port = 0;
389 420
390 multi = NULL; 421 multi = NULL;
391 cbc.buf = buf; 422 cbc.buf = buf;
@@ -394,6 +425,15 @@ testExternalGet (int port)
394 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 425 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
395 if (d == NULL) 426 if (d == NULL)
396 return 256; 427 return 256;
428 if (0 == port)
429 {
430 const union MHD_DaemonInfo *dinfo;
431 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
432 if (NULL == dinfo || 0 == dinfo->port)
433 { MHD_stop_daemon (d); return 32; }
434 port = (int)dinfo->port;
435 }
436 sprintf(url, "http://127.0.0.1:%d/hello_world", port);
397 start_timer (); 437 start_timer ();
398 multi = curl_multi_init (); 438 multi = curl_multi_init ();
399 if (multi == NULL) 439 if (multi == NULL)
@@ -514,10 +554,12 @@ int
514main (int argc, char *const *argv) 554main (int argc, char *const *argv)
515{ 555{
516 unsigned int errorCount = 0; 556 unsigned int errorCount = 0;
517 int port = 1081; 557 int port = 1130;
518 558
519 oneone = (NULL != strrchr (argv[0], (int) '/')) ? 559 oneone = (NULL != strrchr (argv[0], (int) '/')) ?
520 (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0; 560 (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
561 if (oneone)
562 port += 15;
521 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 563 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
522 return 2; 564 return 2;
523 response = MHD_create_response_from_buffer (strlen ("/hello_world"), 565 response = MHD_create_response_from_buffer (strlen ("/hello_world"),
diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c
index 888e77eb..d4bbf753 100644
--- a/src/testcurl/perf_get_concurrent.c
+++ b/src/testcurl/perf_get_concurrent.c
@@ -247,11 +247,22 @@ testInternalGet (int port, int poll_flag)
247 (poll_flag & MHD_USE_EPOLL) ? "internal thread with epoll" : "internal thread with select()"); 247 (poll_flag & MHD_USE_EPOLL) ? "internal thread with epoll" : "internal thread with select()");
248 const char * ret_val; 248 const char * ret_val;
249 249
250 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
251 port = 0;
252
250 signal_done = 0; 253 signal_done = 0;
251 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 254 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
252 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 255 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
253 if (d == NULL) 256 if (d == NULL)
254 return 1; 257 return 1;
258 if (0 == port)
259 {
260 const union MHD_DaemonInfo *dinfo;
261 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
262 if (NULL == dinfo || 0 == dinfo->port)
263 { MHD_stop_daemon (d); return 32; }
264 port = (int)dinfo->port;
265 }
255 start_timer (); 266 start_timer ();
256 ret_val = do_gets ((void*)(intptr_t)port); 267 ret_val = do_gets ((void*)(intptr_t)port);
257 if (!ret_val) 268 if (!ret_val)
@@ -277,11 +288,22 @@ testMultithreadedGet (int port, int poll_flag)
277 : "internal thread with select() and thread per connection"); 288 : "internal thread with select() and thread per connection");
278 const char * ret_val; 289 const char * ret_val;
279 290
291 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
292 port = 0;
293
280 signal_done = 0; 294 signal_done = 0;
281 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 295 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
282 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 296 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
283 if (d == NULL) 297 if (d == NULL)
284 return 16; 298 return 16;
299 if (0 == port)
300 {
301 const union MHD_DaemonInfo *dinfo;
302 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
303 if (NULL == dinfo || 0 == dinfo->port)
304 { MHD_stop_daemon (d); return 32; }
305 port = (int)dinfo->port;
306 }
285 start_timer (); 307 start_timer ();
286 ret_val = do_gets ((void*)(intptr_t)port); 308 ret_val = do_gets ((void*)(intptr_t)port);
287 if (!ret_val) 309 if (!ret_val)
@@ -306,12 +328,23 @@ testMultithreadedPoolGet (int port, int poll_flag)
306 (poll_flag & MHD_USE_EPOLL) ? "internal thread poll with epoll" : "internal thread pool with select()"); 328 (poll_flag & MHD_USE_EPOLL) ? "internal thread poll with epoll" : "internal thread pool with select()");
307 const char * ret_val; 329 const char * ret_val;
308 330
331 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
332 port = 0;
333
309 signal_done = 0 ; 334 signal_done = 0 ;
310 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 335 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
311 port, NULL, NULL, &ahc_echo, "GET", 336 port, NULL, NULL, &ahc_echo, "GET",
312 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 337 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
313 if (d == NULL) 338 if (d == NULL)
314 return 16; 339 return 16;
340 if (0 == port)
341 {
342 const union MHD_DaemonInfo *dinfo;
343 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
344 if (NULL == dinfo || 0 == dinfo->port)
345 { MHD_stop_daemon (d); return 32; }
346 port = (int)dinfo->port;
347 }
315 start_timer (); 348 start_timer ();
316 ret_val = do_gets ((void*)(intptr_t)port); 349 ret_val = do_gets ((void*)(intptr_t)port);
317 if (!ret_val) 350 if (!ret_val)
@@ -342,11 +375,22 @@ testExternalGet (int port)
342 char *ret_val; 375 char *ret_val;
343 int ret = 0; 376 int ret = 0;
344 377
378 if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT))
379 port = 0;
380
345 signal_done = 0; 381 signal_done = 0;
346 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 382 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
347 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 383 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
348 if (d == NULL) 384 if (d == NULL)
349 return 256; 385 return 256;
386 if (0 == port)
387 {
388 const union MHD_DaemonInfo *dinfo;
389 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
390 if (NULL == dinfo || 0 == dinfo->port)
391 { MHD_stop_daemon (d); return 32; }
392 port = (int)dinfo->port;
393 }
350 if (0 != pthread_create (&pid, NULL, 394 if (0 != pthread_create (&pid, NULL,
351 &do_gets, (void*)(intptr_t)port)) 395 &do_gets, (void*)(intptr_t)port))
352 { 396 {
@@ -402,10 +446,12 @@ int
402main (int argc, char *const *argv) 446main (int argc, char *const *argv)
403{ 447{
404 unsigned int errorCount = 0; 448 unsigned int errorCount = 0;
405 int port = 1081; 449 int port = 1100;
406 450
407 oneone = (NULL != strrchr (argv[0], (int) '/')) ? 451 oneone = (NULL != strrchr (argv[0], (int) '/')) ?
408 (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0; 452 (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
453 if (oneone)
454 port += 15;
409 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 455 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
410 return 2; 456 return 2;
411 response = MHD_create_response_from_buffer (strlen ("/hello_world"), 457 response = MHD_create_response_from_buffer (strlen ("/hello_world"),
diff --git a/src/testcurl/test_callback.c b/src/testcurl/test_callback.c
index 4af997d3..6901be0f 100644
--- a/src/testcurl/test_callback.c
+++ b/src/testcurl/test_callback.c
@@ -111,16 +111,33 @@ main(int argc, char **argv)
111 int running; 111 int running;
112 struct timeval tv; 112 struct timeval tv;
113 int extra; 113 int extra;
114 int port;
115
116 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
117 port = 0;
118 else
119 port = 1140;
114 120
115 d = MHD_start_daemon(0, 121 d = MHD_start_daemon(0,
116 8000, 122 port,
117 NULL, 123 NULL,
118 NULL, 124 NULL,
119 &callback, 125 &callback,
120 NULL, 126 NULL,
121 MHD_OPTION_END); 127 MHD_OPTION_END);
128 if (d == NULL)
129 return 32;
130 if (0 == port)
131 {
132 const union MHD_DaemonInfo *dinfo;
133 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
134 if (NULL == dinfo || 0 == dinfo->port)
135 { MHD_stop_daemon (d); return 48; }
136 port = (int)dinfo->port;
137 }
122 c = curl_easy_init (); 138 c = curl_easy_init ();
123 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:8000/"); 139 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/");
140 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
124 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &discard_buffer); 141 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &discard_buffer);
125 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 142 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
126 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 143 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
diff --git a/src/testcurl/test_concurrent_stop.c b/src/testcurl/test_concurrent_stop.c
index 61408960..67c48e1c 100644
--- a/src/testcurl/test_concurrent_stop.c
+++ b/src/testcurl/test_concurrent_stop.c
@@ -217,6 +217,14 @@ testMultithreadedGet (int port,
217 MHD_OPTION_END); 217 MHD_OPTION_END);
218 if (d == NULL) 218 if (d == NULL)
219 return 16; 219 return 16;
220 if (0 == port)
221 {
222 const union MHD_DaemonInfo *dinfo;
223 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
224 if (NULL == dinfo || 0 == dinfo->port)
225 { MHD_stop_daemon (d); return 32; }
226 port = (int)dinfo->port;
227 }
220 p = start_gets (port); 228 p = start_gets (port);
221 sleep (1); 229 sleep (1);
222 MHD_stop_daemon (d); 230 MHD_stop_daemon (d);
@@ -240,6 +248,14 @@ testMultithreadedPoolGet (int port,
240 MHD_OPTION_END); 248 MHD_OPTION_END);
241 if (d == NULL) 249 if (d == NULL)
242 return 16; 250 return 16;
251 if (0 == port)
252 {
253 const union MHD_DaemonInfo *dinfo;
254 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
255 if (NULL == dinfo || 0 == dinfo->port)
256 { MHD_stop_daemon (d); return 32; }
257 port = (int)dinfo->port;
258 }
243 p = start_gets (port); 259 p = start_gets (port);
244 sleep (1); 260 sleep (1);
245 MHD_stop_daemon (d); 261 MHD_stop_daemon (d);
@@ -252,10 +268,17 @@ int
252main (int argc, char *const *argv) 268main (int argc, char *const *argv)
253{ 269{
254 unsigned int errorCount = 0; 270 unsigned int errorCount = 0;
255 int port = 1081; 271 int port;
272 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
273 port = 0;
274 else
275 port = 1142;
276
256 277
257 oneone = (NULL != strrchr (argv[0], (int) '/')) ? 278 oneone = (NULL != strrchr (argv[0], (int) '/')) ?
258 (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0; 279 (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
280 if (0 != port && oneone)
281 port += 5;
259 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 282 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
260 return 2; 283 return 2;
261 response = MHD_create_response_from_buffer (strlen ("/hello_world"), 284 response = MHD_create_response_from_buffer (strlen ("/hello_world"),
diff --git a/src/testcurl/test_delete.c b/src/testcurl/test_delete.c
index fc0b1889..513a5ebd 100644
--- a/src/testcurl/test_delete.c
+++ b/src/testcurl/test_delete.c
@@ -127,17 +127,32 @@ testInternalDelete ()
127 unsigned int pos = 0; 127 unsigned int pos = 0;
128 int done_flag = 0; 128 int done_flag = 0;
129 CURLcode errornum; 129 CURLcode errornum;
130 int port;
131
132 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
133 port = 0;
134 else
135 port = 1152;
130 136
131 cbc.buf = buf; 137 cbc.buf = buf;
132 cbc.size = 2048; 138 cbc.size = 2048;
133 cbc.pos = 0; 139 cbc.pos = 0;
134 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 140 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
135 1080, 141 port,
136 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 142 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
137 if (d == NULL) 143 if (d == NULL)
138 return 1; 144 return 1;
145 if (0 == port)
146 {
147 const union MHD_DaemonInfo *dinfo;
148 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
149 if (NULL == dinfo || 0 == dinfo->port)
150 { MHD_stop_daemon (d); return 32; }
151 port = (int)dinfo->port;
152 }
139 c = curl_easy_init (); 153 c = curl_easy_init ();
140 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); 154 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
155 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
141 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 156 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
142 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 157 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
143 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 158 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -185,17 +200,32 @@ testMultithreadedDelete ()
185 unsigned int pos = 0; 200 unsigned int pos = 0;
186 int done_flag = 0; 201 int done_flag = 0;
187 CURLcode errornum; 202 CURLcode errornum;
203 int port;
204
205 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
206 port = 0;
207 else
208 port = 1153;
188 209
189 cbc.buf = buf; 210 cbc.buf = buf;
190 cbc.size = 2048; 211 cbc.size = 2048;
191 cbc.pos = 0; 212 cbc.pos = 0;
192 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 213 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
193 1081, 214 port,
194 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 215 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
195 if (d == NULL) 216 if (d == NULL)
196 return 16; 217 return 16;
218 if (0 == port)
219 {
220 const union MHD_DaemonInfo *dinfo;
221 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
222 if (NULL == dinfo || 0 == dinfo->port)
223 { MHD_stop_daemon (d); return 32; }
224 port = (int)dinfo->port;
225 }
197 c = curl_easy_init (); 226 c = curl_easy_init ();
198 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 227 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
228 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
199 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 229 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
200 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 230 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
201 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 231 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -243,18 +273,33 @@ testMultithreadedPoolDelete ()
243 unsigned int pos = 0; 273 unsigned int pos = 0;
244 int done_flag = 0; 274 int done_flag = 0;
245 CURLcode errornum; 275 CURLcode errornum;
276 int port;
277
278 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
279 port = 0;
280 else
281 port = 1154;
246 282
247 cbc.buf = buf; 283 cbc.buf = buf;
248 cbc.size = 2048; 284 cbc.size = 2048;
249 cbc.pos = 0; 285 cbc.pos = 0;
250 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 286 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
251 1081, 287 port,
252 NULL, NULL, &ahc_echo, &done_flag, 288 NULL, NULL, &ahc_echo, &done_flag,
253 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 289 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
254 if (d == NULL) 290 if (d == NULL)
255 return 16; 291 return 16;
292 if (0 == port)
293 {
294 const union MHD_DaemonInfo *dinfo;
295 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
296 if (NULL == dinfo || 0 == dinfo->port)
297 { MHD_stop_daemon (d); return 32; }
298 port = (int)dinfo->port;
299 }
256 c = curl_easy_init (); 300 c = curl_easy_init ();
257 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 301 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
302 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
258 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 303 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
259 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 304 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
260 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 305 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -317,18 +362,33 @@ testExternalDelete ()
317 struct timeval tv; 362 struct timeval tv;
318 unsigned int pos = 0; 363 unsigned int pos = 0;
319 int done_flag = 0; 364 int done_flag = 0;
365 int port;
366
367 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
368 port = 0;
369 else
370 port = 1154;
320 371
321 multi = NULL; 372 multi = NULL;
322 cbc.buf = buf; 373 cbc.buf = buf;
323 cbc.size = 2048; 374 cbc.size = 2048;
324 cbc.pos = 0; 375 cbc.pos = 0;
325 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 376 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
326 1082, 377 port,
327 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 378 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
328 if (d == NULL) 379 if (d == NULL)
329 return 256; 380 return 256;
381 if (0 == port)
382 {
383 const union MHD_DaemonInfo *dinfo;
384 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
385 if (NULL == dinfo || 0 == dinfo->port)
386 { MHD_stop_daemon (d); return 32; }
387 port = (int)dinfo->port;
388 }
330 c = curl_easy_init (); 389 c = curl_easy_init ();
331 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); 390 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
391 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
332 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 392 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
333 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 393 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
334 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 394 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c
index 57abbbe6..3db08b4b 100644
--- a/src/testcurl/test_digestauth.c
+++ b/src/testcurl/test_digestauth.c
@@ -140,6 +140,13 @@ testDigestAuth ()
140 size_t off = 0; 140 size_t off = 0;
141 char buf[2048]; 141 char buf[2048];
142 char rnd[8]; 142 char rnd[8];
143 int port;
144 char url[128];
145
146 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
147 port = 0;
148 else
149 port = 1165;
143 150
144 cbc.buf = buf; 151 cbc.buf = buf;
145 cbc.size = 2048; 152 cbc.size = 2048;
@@ -190,14 +197,23 @@ testDigestAuth ()
190 } 197 }
191#endif 198#endif
192 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 199 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
193 1337, NULL, NULL, &ahc_echo, PAGE, 200 port, NULL, NULL, &ahc_echo, PAGE,
194 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, 201 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
195 MHD_OPTION_NONCE_NC_SIZE, 300, 202 MHD_OPTION_NONCE_NC_SIZE, 300,
196 MHD_OPTION_END); 203 MHD_OPTION_END);
197 if (d == NULL) 204 if (d == NULL)
198 return 1; 205 return 1;
206 if (0 == port)
207 {
208 const union MHD_DaemonInfo *dinfo;
209 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
210 if (NULL == dinfo || 0 == dinfo->port)
211 { MHD_stop_daemon (d); return 32; }
212 port = (int)dinfo->port;
213 }
214 sprintf(url, "http://127.0.0.1:%d/bar%%20 foo?a=bü%%20", port);
199 c = curl_easy_init (); 215 c = curl_easy_init ();
200 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1337/bar%20 foo?a=bü%20"); 216 curl_easy_setopt (c, CURLOPT_URL, url);
201 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 217 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
202 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 218 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
203 curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); 219 curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c
index 1c4be0d6..3245b046 100644
--- a/src/testcurl/test_digestauth_with_arguments.c
+++ b/src/testcurl/test_digestauth_with_arguments.c
@@ -135,6 +135,13 @@ testDigestAuth ()
135 size_t off = 0; 135 size_t off = 0;
136 char buf[2048]; 136 char buf[2048];
137 char rnd[8]; 137 char rnd[8];
138 int port;
139 char url[128];
140
141 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
142 port = 0;
143 else
144 port = 1160;
138 145
139 cbc.buf = buf; 146 cbc.buf = buf;
140 cbc.size = 2048; 147 cbc.size = 2048;
@@ -185,14 +192,23 @@ testDigestAuth ()
185 } 192 }
186#endif 193#endif
187 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 194 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
188 1337, NULL, NULL, &ahc_echo, PAGE, 195 port, NULL, NULL, &ahc_echo, PAGE,
189 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, 196 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
190 MHD_OPTION_NONCE_NC_SIZE, 300, 197 MHD_OPTION_NONCE_NC_SIZE, 300,
191 MHD_OPTION_END); 198 MHD_OPTION_END);
192 if (d == NULL) 199 if (d == NULL)
193 return 1; 200 return 1;
201 if (0 == port)
202 {
203 const union MHD_DaemonInfo *dinfo;
204 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
205 if (NULL == dinfo || 0 == dinfo->port)
206 { MHD_stop_daemon (d); return 32; }
207 port = (int)dinfo->port;
208 }
209 sprintf(url, "http://127.0.0.1:%d/foo?key=value", port);
194 c = curl_easy_init (); 210 c = curl_easy_init ();
195 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1337/foo?key=value"); 211 curl_easy_setopt (c, CURLOPT_URL, url);
196 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 212 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
197 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 213 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
198 curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); 214 curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c
index dc8f9dc4..bc7f5fb5 100644
--- a/src/testcurl/test_get.c
+++ b/src/testcurl/test_get.c
@@ -116,16 +116,35 @@ testInternalGet (int poll_flag)
116 char buf[2048]; 116 char buf[2048];
117 struct CBC cbc; 117 struct CBC cbc;
118 CURLcode errornum; 118 CURLcode errornum;
119 int port;
120
121 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
122 port = 0;
123 else
124 {
125 port = 1220;
126 if (oneone)
127 port += 20;
128 }
119 129
120 cbc.buf = buf; 130 cbc.buf = buf;
121 cbc.size = 2048; 131 cbc.size = 2048;
122 cbc.pos = 0; 132 cbc.pos = 0;
123 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 133 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
124 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 134 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
125 if (d == NULL) 135 if (d == NULL)
126 return 1; 136 return 1;
137 if (0 == port)
138 {
139 const union MHD_DaemonInfo *dinfo;
140 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
141 if (NULL == dinfo || 0 == dinfo->port)
142 { MHD_stop_daemon (d); return 32; }
143 port = (int)dinfo->port;
144 }
127 c = curl_easy_init (); 145 c = curl_easy_init ();
128 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11080/hello_world"); 146 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
147 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
129 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 148 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
130 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 149 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
131 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 150 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -166,16 +185,35 @@ testMultithreadedGet (int poll_flag)
166 char buf[2048]; 185 char buf[2048];
167 struct CBC cbc; 186 struct CBC cbc;
168 CURLcode errornum; 187 CURLcode errornum;
188 int port;
189
190 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
191 port = 0;
192 else
193 {
194 port = 1221;
195 if (oneone)
196 port += 20;
197 }
169 198
170 cbc.buf = buf; 199 cbc.buf = buf;
171 cbc.size = 2048; 200 cbc.size = 2048;
172 cbc.pos = 0; 201 cbc.pos = 0;
173 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 202 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
174 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 203 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
175 if (d == NULL) 204 if (d == NULL)
176 return 16; 205 return 16;
206 if (0 == port)
207 {
208 const union MHD_DaemonInfo *dinfo;
209 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
210 if (NULL == dinfo || 0 == dinfo->port)
211 { MHD_stop_daemon (d); return 32; }
212 port = (int)dinfo->port;
213 }
177 c = curl_easy_init (); 214 c = curl_easy_init ();
178 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 215 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
216 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
179 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 217 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
180 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 218 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
181 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 219 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -216,17 +254,36 @@ testMultithreadedPoolGet (int poll_flag)
216 char buf[2048]; 254 char buf[2048];
217 struct CBC cbc; 255 struct CBC cbc;
218 CURLcode errornum; 256 CURLcode errornum;
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 = 1222;
264 if (oneone)
265 port += 20;
266 }
219 267
220 cbc.buf = buf; 268 cbc.buf = buf;
221 cbc.size = 2048; 269 cbc.size = 2048;
222 cbc.pos = 0; 270 cbc.pos = 0;
223 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 271 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
224 1081, NULL, NULL, &ahc_echo, "GET", 272 port, NULL, NULL, &ahc_echo, "GET",
225 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 273 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
226 if (d == NULL) 274 if (d == NULL)
227 return 16; 275 return 16;
276 if (0 == port)
277 {
278 const union MHD_DaemonInfo *dinfo;
279 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
280 if (NULL == dinfo || 0 == dinfo->port)
281 { MHD_stop_daemon (d); return 32; }
282 port = (int)dinfo->port;
283 }
228 c = curl_easy_init (); 284 c = curl_easy_init ();
229 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 285 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
286 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
230 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 287 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
231 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 288 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
232 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 289 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -281,17 +338,36 @@ testExternalGet ()
281 struct CURLMsg *msg; 338 struct CURLMsg *msg;
282 time_t start; 339 time_t start;
283 struct timeval tv; 340 struct timeval tv;
341 int port;
342
343 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
344 port = 0;
345 else
346 {
347 port = 1223;
348 if (oneone)
349 port += 20;
350 }
284 351
285 multi = NULL; 352 multi = NULL;
286 cbc.buf = buf; 353 cbc.buf = buf;
287 cbc.size = 2048; 354 cbc.size = 2048;
288 cbc.pos = 0; 355 cbc.pos = 0;
289 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 356 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
290 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 357 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
291 if (d == NULL) 358 if (d == NULL)
292 return 256; 359 return 256;
360 if (0 == port)
361 {
362 const union MHD_DaemonInfo *dinfo;
363 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
364 if (NULL == dinfo || 0 == dinfo->port)
365 { MHD_stop_daemon (d); return 32; }
366 port = (int)dinfo->port;
367 }
293 c = curl_easy_init (); 368 c = curl_easy_init ();
294 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); 369 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
370 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
295 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 371 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
296 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 372 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
297 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 373 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -401,6 +477,7 @@ testUnknownPortGet (int poll_flag)
401 char buf[2048]; 477 char buf[2048];
402 struct CBC cbc; 478 struct CBC cbc;
403 CURLcode errornum; 479 CURLcode errornum;
480 int port;
404 481
405 struct sockaddr_in addr; 482 struct sockaddr_in addr;
406 socklen_t addr_len = sizeof(addr); 483 socklen_t addr_len = sizeof(addr);
@@ -413,24 +490,33 @@ testUnknownPortGet (int poll_flag)
413 cbc.size = 2048; 490 cbc.size = 2048;
414 cbc.pos = 0; 491 cbc.pos = 0;
415 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 492 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
416 1, NULL, NULL, &ahc_echo, "GET", 493 0, NULL, NULL, &ahc_echo, "GET",
417 MHD_OPTION_SOCK_ADDR, &addr, 494 MHD_OPTION_SOCK_ADDR, &addr,
418 MHD_OPTION_END); 495 MHD_OPTION_END);
419 if (d == NULL) 496 if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
420 return 32768; 497 {
421 498 di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD);
422 di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); 499 if (di == NULL)
423 if (di == NULL) 500 return 65536;
424 return 65536;
425 501
426 if (0 != getsockname(di->listen_fd, (struct sockaddr *) &addr, &addr_len)) 502 if (0 != getsockname(di->listen_fd, (struct sockaddr *) &addr, &addr_len))
427 return 131072; 503 return 131072;
428 504
429 if (addr.sin_family != AF_INET) 505 if (addr.sin_family != AF_INET)
430 return 26214; 506 return 26214;
507 port = (int)ntohs(addr.sin_port);
508 }
509 else
510 {
511 const union MHD_DaemonInfo *dinfo;
512 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
513 if (NULL == dinfo || 0 == dinfo->port)
514 { MHD_stop_daemon (d); return 32; }
515 port = (int)dinfo->port;
516 }
431 517
432 snprintf(buf, sizeof(buf), "http://127.0.0.1:%hu/hello_world", 518 snprintf(buf, sizeof(buf), "http://127.0.0.1:%d/hello_world",
433 ntohs(addr.sin_port)); 519 port);
434 520
435 c = curl_easy_init (); 521 c = curl_easy_init ();
436 curl_easy_setopt (c, CURLOPT_URL, buf); 522 curl_easy_setopt (c, CURLOPT_URL, buf);
@@ -472,11 +558,29 @@ testStopRace (int poll_flag)
472 struct sockaddr_in sin; 558 struct sockaddr_in sin;
473 MHD_socket fd; 559 MHD_socket fd;
474 struct MHD_Daemon *d; 560 struct MHD_Daemon *d;
561 int port;
562
563 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
564 port = 0;
565 else
566 {
567 port = 1224;
568 if (oneone)
569 port += 20;
570 }
475 571
476 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 572 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
477 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 573 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
478 if (d == NULL) 574 if (d == NULL)
479 return 16; 575 return 16;
576 if (0 == port)
577 {
578 const union MHD_DaemonInfo *dinfo;
579 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
580 if (NULL == dinfo || 0 == dinfo->port)
581 { MHD_stop_daemon (d); return 32; }
582 port = (int)dinfo->port;
583 }
480 584
481 fd = socket (PF_INET, SOCK_STREAM, 0); 585 fd = socket (PF_INET, SOCK_STREAM, 0);
482 if (fd == MHD_INVALID_SOCKET) 586 if (fd == MHD_INVALID_SOCKET)
@@ -487,7 +591,7 @@ testStopRace (int poll_flag)
487 591
488 memset(&sin, 0, sizeof(sin)); 592 memset(&sin, 0, sizeof(sin));
489 sin.sin_family = AF_INET; 593 sin.sin_family = AF_INET;
490 sin.sin_port = htons(1081); 594 sin.sin_port = htons(port);
491 sin.sin_addr.s_addr = htonl(0x7f000001); 595 sin.sin_addr.s_addr = htonl(0x7f000001);
492 596
493 if (connect (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0) 597 if (connect (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0)
@@ -566,16 +670,35 @@ testEmptyGet (int poll_flag)
566 struct CBC cbc; 670 struct CBC cbc;
567 CURLcode errornum; 671 CURLcode errornum;
568 int excess_found = 0; 672 int excess_found = 0;
673 int port;
674
675 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
676 port = 0;
677 else
678 {
679 port = 1225;
680 if (oneone)
681 port += 20;
682 }
569 683
570 cbc.buf = buf; 684 cbc.buf = buf;
571 cbc.size = 2048; 685 cbc.size = 2048;
572 cbc.pos = 0; 686 cbc.pos = 0;
573 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 687 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
574 11081, NULL, NULL, &ahc_empty, NULL, MHD_OPTION_END); 688 port, NULL, NULL, &ahc_empty, NULL, MHD_OPTION_END);
575 if (d == NULL) 689 if (d == NULL)
576 return 4194304; 690 return 4194304;
691 if (0 == port)
692 {
693 const union MHD_DaemonInfo *dinfo;
694 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
695 if (NULL == dinfo || 0 == dinfo->port)
696 { MHD_stop_daemon (d); return 32; }
697 port = (int)dinfo->port;
698 }
577 c = curl_easy_init (); 699 c = curl_easy_init ();
578 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); 700 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
701 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
579 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 702 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
580 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 703 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
581 curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &curlExcessFound); 704 curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &curlExcessFound);
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c
index 9fb94626..425776af 100644
--- a/src/testcurl/test_get_chunked.c
+++ b/src/testcurl/test_get_chunked.c
@@ -160,16 +160,31 @@ testInternalGet ()
160 char buf[2048]; 160 char buf[2048];
161 struct CBC cbc; 161 struct CBC cbc;
162 CURLcode errornum; 162 CURLcode errornum;
163 int port;
164
165 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
166 port = 0;
167 else
168 port = 1170;
163 169
164 cbc.buf = buf; 170 cbc.buf = buf;
165 cbc.size = 2048; 171 cbc.size = 2048;
166 cbc.pos = 0; 172 cbc.pos = 0;
167 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 173 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
168 1080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 174 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
169 if (d == NULL) 175 if (d == NULL)
170 return 1; 176 return 1;
177 if (0 == port)
178 {
179 const union MHD_DaemonInfo *dinfo;
180 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
181 if (NULL == dinfo || 0 == dinfo->port)
182 { MHD_stop_daemon (d); return 32; }
183 port = (int)dinfo->port;
184 }
171 c = curl_easy_init (); 185 c = curl_easy_init ();
172 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); 186 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
187 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
173 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 188 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
174 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 189 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
175 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 190 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -202,16 +217,31 @@ testMultithreadedGet ()
202 char buf[2048]; 217 char buf[2048];
203 struct CBC cbc; 218 struct CBC cbc;
204 CURLcode errornum; 219 CURLcode errornum;
220 int port;
221
222 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
223 port = 0;
224 else
225 port = 1171;
205 226
206 cbc.buf = buf; 227 cbc.buf = buf;
207 cbc.size = 2048; 228 cbc.size = 2048;
208 cbc.pos = 0; 229 cbc.pos = 0;
209 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 230 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
210 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 231 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
211 if (d == NULL) 232 if (d == NULL)
212 return 16; 233 return 16;
234 if (0 == port)
235 {
236 const union MHD_DaemonInfo *dinfo;
237 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
238 if (NULL == dinfo || 0 == dinfo->port)
239 { MHD_stop_daemon (d); return 32; }
240 port = (int)dinfo->port;
241 }
213 c = curl_easy_init (); 242 c = curl_easy_init ();
214 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 243 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
244 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
215 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 245 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
216 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 246 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
217 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 247 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -244,17 +274,32 @@ testMultithreadedPoolGet ()
244 char buf[2048]; 274 char buf[2048];
245 struct CBC cbc; 275 struct CBC cbc;
246 CURLcode errornum; 276 CURLcode errornum;
277 int port;
278
279 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
280 port = 0;
281 else
282 port = 1172;
247 283
248 cbc.buf = buf; 284 cbc.buf = buf;
249 cbc.size = 2048; 285 cbc.size = 2048;
250 cbc.pos = 0; 286 cbc.pos = 0;
251 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 287 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
252 1081, NULL, NULL, &ahc_echo, "GET", 288 port, NULL, NULL, &ahc_echo, "GET",
253 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 289 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
254 if (d == NULL) 290 if (d == NULL)
255 return 16; 291 return 16;
292 if (0 == port)
293 {
294 const union MHD_DaemonInfo *dinfo;
295 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
296 if (NULL == dinfo || 0 == dinfo->port)
297 { MHD_stop_daemon (d); return 32; }
298 port = (int)dinfo->port;
299 }
256 c = curl_easy_init (); 300 c = curl_easy_init ();
257 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 301 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
302 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
258 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 303 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
259 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 304 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
260 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 305 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -301,17 +346,32 @@ testExternalGet ()
301 struct CURLMsg *msg; 346 struct CURLMsg *msg;
302 time_t start; 347 time_t start;
303 struct timeval tv; 348 struct timeval tv;
349 int port;
350
351 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
352 port = 0;
353 else
354 port = 1173;
304 355
305 multi = NULL; 356 multi = NULL;
306 cbc.buf = buf; 357 cbc.buf = buf;
307 cbc.size = 2048; 358 cbc.size = 2048;
308 cbc.pos = 0; 359 cbc.pos = 0;
309 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 360 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
310 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 361 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
311 if (d == NULL) 362 if (d == NULL)
312 return 256; 363 return 256;
364 if (0 == port)
365 {
366 const union MHD_DaemonInfo *dinfo;
367 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
368 if (NULL == dinfo || 0 == dinfo->port)
369 { MHD_stop_daemon (d); return 32; }
370 port = (int)dinfo->port;
371 }
313 c = curl_easy_init (); 372 c = curl_easy_init ();
314 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); 373 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
374 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
315 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 375 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
316 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 376 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
317 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 377 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
diff --git a/src/testcurl/test_get_response_cleanup.c b/src/testcurl/test_get_response_cleanup.c
index 76657262..03552ba0 100644
--- a/src/testcurl/test_get_response_cleanup.c
+++ b/src/testcurl/test_get_response_cleanup.c
@@ -153,13 +153,33 @@ testInternalGet ()
153{ 153{
154 struct MHD_Daemon *d; 154 struct MHD_Daemon *d;
155 pid_t curl; 155 pid_t curl;
156 int port;
157 char url[127];
158
159 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
160 port = 0;
161 else
162 {
163 port = 1180;
164 if (oneone)
165 port += 10;
166 }
156 167
157 ok = 1; 168 ok = 1;
158 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 169 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
159 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 170 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
160 if (d == NULL) 171 if (d == NULL)
161 return 1; 172 return 1;
162 curl = fork_curl ("http://127.0.0.1:11080/"); 173 if (0 == port)
174 {
175 const union MHD_DaemonInfo *dinfo;
176 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
177 if (NULL == dinfo || 0 == dinfo->port)
178 { MHD_stop_daemon (d); return 32; }
179 port = (int)dinfo->port;
180 }
181 sprintf(url, "http://127.0.0.1:%d/", port);
182 curl = fork_curl (url);
163 sleep (1); 183 sleep (1);
164 kill_curl (curl); 184 kill_curl (curl);
165 sleep (1); 185 sleep (1);
@@ -176,20 +196,40 @@ testMultithreadedGet ()
176{ 196{
177 struct MHD_Daemon *d; 197 struct MHD_Daemon *d;
178 pid_t curl; 198 pid_t curl;
199 int port;
200 char url[127];
201
202 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
203 port = 0;
204 else
205 {
206 port = 1181;
207 if (oneone)
208 port += 10;
209 }
179 210
180 ok = 1; 211 ok = 1;
181 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 212 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
182 1081, NULL, NULL, &ahc_echo, "GET", 213 port, NULL, NULL, &ahc_echo, "GET",
183 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 2, 214 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 2,
184 MHD_OPTION_END); 215 MHD_OPTION_END);
185 if (d == NULL) 216 if (d == NULL)
186 return 16; 217 return 16;
218 if (0 == port)
219 {
220 const union MHD_DaemonInfo *dinfo;
221 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
222 if (NULL == dinfo || 0 == dinfo->port)
223 { MHD_stop_daemon (d); return 32; }
224 port = (int)dinfo->port;
225 }
226 sprintf(url, "http://127.0.0.1:%d/", port);
187 //fprintf (stderr, "Forking cURL!\n"); 227 //fprintf (stderr, "Forking cURL!\n");
188 curl = fork_curl ("http://127.0.0.1:1081/"); 228 curl = fork_curl (url);
189 sleep (1); 229 sleep (1);
190 kill_curl (curl); 230 kill_curl (curl);
191 sleep (1); 231 sleep (1);
192 curl = fork_curl ("http://127.0.0.1:1081/"); 232 curl = fork_curl (url);
193 sleep (1); 233 sleep (1);
194 if (ok != 0) 234 if (ok != 0)
195 { 235 {
@@ -213,14 +253,34 @@ testMultithreadedPoolGet ()
213{ 253{
214 struct MHD_Daemon *d; 254 struct MHD_Daemon *d;
215 pid_t curl; 255 pid_t curl;
256 int port;
257 char url[127];
258
259 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
260 port = 0;
261 else
262 {
263 port = 1182;
264 if (oneone)
265 port += 10;
266 }
216 267
217 ok = 1; 268 ok = 1;
218 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 269 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
219 1081, NULL, NULL, &ahc_echo, "GET", 270 port, NULL, NULL, &ahc_echo, "GET",
220 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 271 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
221 if (d == NULL) 272 if (d == NULL)
222 return 64; 273 return 64;
223 curl = fork_curl ("http://127.0.0.1:1081/"); 274 if (0 == port)
275 {
276 const union MHD_DaemonInfo *dinfo;
277 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
278 if (NULL == dinfo || 0 == dinfo->port)
279 { MHD_stop_daemon (d); return 32; }
280 port = (int)dinfo->port;
281 }
282 sprintf(url, "http://127.0.0.1:%d/", port);
283 curl = fork_curl (url);
224 sleep (1); 284 sleep (1);
225 kill_curl (curl); 285 kill_curl (curl);
226 sleep (1); 286 sleep (1);
@@ -243,13 +303,33 @@ testExternalGet ()
243 time_t start; 303 time_t start;
244 struct timeval tv; 304 struct timeval tv;
245 pid_t curl; 305 pid_t curl;
306 int port;
307 char url[127];
308
309 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
310 port = 0;
311 else
312 {
313 port = 1183;
314 if (oneone)
315 port += 10;
316 }
246 317
247 ok = 1; 318 ok = 1;
248 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 319 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
249 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 320 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
250 if (d == NULL) 321 if (d == NULL)
251 return 256; 322 return 256;
252 curl = fork_curl ("http://127.0.0.1:1082/"); 323 if (0 == port)
324 {
325 const union MHD_DaemonInfo *dinfo;
326 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
327 if (NULL == dinfo || 0 == dinfo->port)
328 { MHD_stop_daemon (d); return 32; }
329 port = (int)dinfo->port;
330 }
331 sprintf(url, "http://127.0.0.1:%d/", port);
332 curl = fork_curl (url);
253 333
254 start = time (NULL); 334 start = time (NULL);
255 while ((time (NULL) - start < 2)) 335 while ((time (NULL) - start < 2))
diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c
index a177d213..652423d4 100644
--- a/src/testcurl/test_get_sendfile.c
+++ b/src/testcurl/test_get_sendfile.c
@@ -121,16 +121,35 @@ testInternalGet ()
121 char buf[2048]; 121 char buf[2048];
122 struct CBC cbc; 122 struct CBC cbc;
123 CURLcode errornum; 123 CURLcode errornum;
124 int port;
125
126 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
127 port = 0;
128 else
129 {
130 port = 1200;
131 if (oneone)
132 port += 10;
133 }
124 134
125 cbc.buf = buf; 135 cbc.buf = buf;
126 cbc.size = 2048; 136 cbc.size = 2048;
127 cbc.pos = 0; 137 cbc.pos = 0;
128 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 138 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
129 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 139 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
130 if (d == NULL) 140 if (d == NULL)
131 return 1; 141 return 1;
142 if (0 == port)
143 {
144 const union MHD_DaemonInfo *dinfo;
145 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
146 if (NULL == dinfo || 0 == dinfo->port)
147 { MHD_stop_daemon (d); return 32; }
148 port = (int)dinfo->port;
149 }
132 c = curl_easy_init (); 150 c = curl_easy_init ();
133 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11080/"); 151 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/");
152 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
134 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 153 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
135 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 154 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
136 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 155 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -171,16 +190,35 @@ testMultithreadedGet ()
171 char buf[2048]; 190 char buf[2048];
172 struct CBC cbc; 191 struct CBC cbc;
173 CURLcode errornum; 192 CURLcode errornum;
193 int port;
194
195 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
196 port = 0;
197 else
198 {
199 port = 1201;
200 if (oneone)
201 port += 10;
202 }
174 203
175 cbc.buf = buf; 204 cbc.buf = buf;
176 cbc.size = 2048; 205 cbc.size = 2048;
177 cbc.pos = 0; 206 cbc.pos = 0;
178 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 207 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
179 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 208 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
180 if (d == NULL) 209 if (d == NULL)
181 return 16; 210 return 16;
211 if (0 == port)
212 {
213 const union MHD_DaemonInfo *dinfo;
214 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
215 if (NULL == dinfo || 0 == dinfo->port)
216 { MHD_stop_daemon (d); return 32; }
217 port = (int)dinfo->port;
218 }
182 c = curl_easy_init (); 219 c = curl_easy_init ();
183 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/"); 220 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/");
221 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
184 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 222 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
185 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 223 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
186 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 224 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -221,17 +259,36 @@ testMultithreadedPoolGet ()
221 char buf[2048]; 259 char buf[2048];
222 struct CBC cbc; 260 struct CBC cbc;
223 CURLcode errornum; 261 CURLcode errornum;
262 int port;
263
264 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
265 port = 0;
266 else
267 {
268 port = 1202;
269 if (oneone)
270 port += 10;
271 }
224 272
225 cbc.buf = buf; 273 cbc.buf = buf;
226 cbc.size = 2048; 274 cbc.size = 2048;
227 cbc.pos = 0; 275 cbc.pos = 0;
228 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 276 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
229 1081, NULL, NULL, &ahc_echo, "GET", 277 port, NULL, NULL, &ahc_echo, "GET",
230 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 278 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
231 if (d == NULL) 279 if (d == NULL)
232 return 16; 280 return 16;
281 if (0 == port)
282 {
283 const union MHD_DaemonInfo *dinfo;
284 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
285 if (NULL == dinfo || 0 == dinfo->port)
286 { MHD_stop_daemon (d); return 32; }
287 port = (int)dinfo->port;
288 }
233 c = curl_easy_init (); 289 c = curl_easy_init ();
234 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/"); 290 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/");
291 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
235 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 292 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
236 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 293 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
237 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 294 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -286,17 +343,36 @@ testExternalGet ()
286 struct CURLMsg *msg; 343 struct CURLMsg *msg;
287 time_t start; 344 time_t start;
288 struct timeval tv; 345 struct timeval tv;
346 int port;
347
348 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
349 port = 0;
350 else
351 {
352 port = 1203;
353 if (oneone)
354 port += 10;
355 }
289 356
290 multi = NULL; 357 multi = NULL;
291 cbc.buf = buf; 358 cbc.buf = buf;
292 cbc.size = 2048; 359 cbc.size = 2048;
293 cbc.pos = 0; 360 cbc.pos = 0;
294 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 361 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
295 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 362 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
296 if (d == NULL) 363 if (d == NULL)
297 return 256; 364 return 256;
365 if (0 == port)
366 {
367 const union MHD_DaemonInfo *dinfo;
368 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
369 if (NULL == dinfo || 0 == dinfo->port)
370 { MHD_stop_daemon (d); return 32; }
371 port = (int)dinfo->port;
372 }
298 c = curl_easy_init (); 373 c = curl_easy_init ();
299 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/"); 374 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/");
375 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
300 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 376 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
301 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 377 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
302 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 378 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -406,6 +482,7 @@ testUnknownPortGet ()
406 char buf[2048]; 482 char buf[2048];
407 struct CBC cbc; 483 struct CBC cbc;
408 CURLcode errornum; 484 CURLcode errornum;
485 int port;
409 486
410 struct sockaddr_in addr; 487 struct sockaddr_in addr;
411 socklen_t addr_len = sizeof(addr); 488 socklen_t addr_len = sizeof(addr);
@@ -418,24 +495,36 @@ testUnknownPortGet ()
418 cbc.size = 2048; 495 cbc.size = 2048;
419 cbc.pos = 0; 496 cbc.pos = 0;
420 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 497 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
421 1, NULL, NULL, &ahc_echo, "GET", 498 0, NULL, NULL, &ahc_echo, "GET",
422 MHD_OPTION_SOCK_ADDR, &addr, 499 MHD_OPTION_SOCK_ADDR, &addr,
423 MHD_OPTION_END); 500 MHD_OPTION_END);
424 if (d == NULL) 501 if (d == NULL)
425 return 32768; 502 return 32768;
426 503
427 di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); 504 if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
428 if (di == NULL) 505 {
429 return 65536; 506 di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD);
507 if (di == NULL)
508 return 65536;
430 509
431 if (0 != getsockname(di->listen_fd, (struct sockaddr *) &addr, &addr_len)) 510 if (0 != getsockname(di->listen_fd, (struct sockaddr *) &addr, &addr_len))
432 return 131072; 511 return 131072;
433 512
434 if (addr.sin_family != AF_INET) 513 if (addr.sin_family != AF_INET)
435 return 26214; 514 return 26214;
515 port = (int)ntohs(addr.sin_port);
516 }
517 else
518 {
519 const union MHD_DaemonInfo *dinfo;
520 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
521 if (NULL == dinfo || 0 == dinfo->port)
522 { MHD_stop_daemon (d); return 32; }
523 port = (int)dinfo->port;
524 }
436 525
437 snprintf(buf, sizeof(buf), "http://127.0.0.1:%hu/", 526 snprintf(buf, sizeof(buf), "http://127.0.0.1:%d/",
438 ntohs(addr.sin_port)); 527 port);
439 528
440 c = curl_easy_init (); 529 c = curl_easy_init ();
441 curl_easy_setopt (c, CURLOPT_URL, buf); 530 curl_easy_setopt (c, CURLOPT_URL, buf);
diff --git a/src/testcurl/test_iplimit.c b/src/testcurl/test_iplimit.c
index a41294ba..0667f0d5 100644
--- a/src/testcurl/test_iplimit.c
+++ b/src/testcurl/test_iplimit.c
@@ -112,18 +112,36 @@ testMultithreadedGet ()
112 int k; 112 int k;
113 unsigned int success; 113 unsigned int success;
114 unsigned int failure; 114 unsigned int failure;
115 int port;
116
117 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
118 port = 0;
119 else
120 {
121 port = 1260;
122 if (oneone)
123 port += 5;
124 }
115 125
116 /* Test only valid for HTTP/1.1 (uses persistent connections) */ 126 /* Test only valid for HTTP/1.1 (uses persistent connections) */
117 if (!oneone) 127 if (!oneone)
118 return 0; 128 return 0;
119 129
120 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 130 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
121 1081, NULL, NULL, 131 port, NULL, NULL,
122 &ahc_echo, "GET", 132 &ahc_echo, "GET",
123 MHD_OPTION_PER_IP_CONNECTION_LIMIT, 2, 133 MHD_OPTION_PER_IP_CONNECTION_LIMIT, 2,
124 MHD_OPTION_END); 134 MHD_OPTION_END);
125 if (d == NULL) 135 if (d == NULL)
126 return 16; 136 return 16;
137 if (0 == port)
138 {
139 const union MHD_DaemonInfo *dinfo;
140 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
141 if (NULL == dinfo || 0 == dinfo->port)
142 { MHD_stop_daemon (d); return 32; }
143 port = (int)dinfo->port;
144 }
127 145
128 for (k = 0; k < 3; ++k) 146 for (k = 0; k < 3; ++k)
129 { 147 {
@@ -143,7 +161,8 @@ testMultithreadedGet ()
143 cbc[i].size = 2048; 161 cbc[i].size = 2048;
144 cbc[i].pos = 0; 162 cbc[i].pos = 0;
145 163
146 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 164 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
165 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
147 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 166 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
148 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc[i]); 167 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc[i]);
149 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 168 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -203,18 +222,35 @@ testMultithreadedPoolGet ()
203 struct MHD_Daemon *d; 222 struct MHD_Daemon *d;
204 char buf[2048]; 223 char buf[2048];
205 int k; 224 int k;
225 int port;
226 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
227 port = 0;
228 else
229 {
230 port = 1261;
231 if (oneone)
232 port += 5;
233 }
206 234
207 /* Test only valid for HTTP/1.1 (uses persistent connections) */ 235 /* Test only valid for HTTP/1.1 (uses persistent connections) */
208 if (!oneone) 236 if (!oneone)
209 return 0; 237 return 0;
210 238
211 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 239 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
212 1081, NULL, NULL, &ahc_echo, "GET", 240 port, NULL, NULL, &ahc_echo, "GET",
213 MHD_OPTION_PER_IP_CONNECTION_LIMIT, 2, 241 MHD_OPTION_PER_IP_CONNECTION_LIMIT, 2,
214 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, 242 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT,
215 MHD_OPTION_END); 243 MHD_OPTION_END);
216 if (d == NULL) 244 if (d == NULL)
217 return 16; 245 return 16;
246 if (0 == port)
247 {
248 const union MHD_DaemonInfo *dinfo;
249 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
250 if (NULL == dinfo || 0 == dinfo->port)
251 { MHD_stop_daemon (d); return 32; }
252 port = (int)dinfo->port;
253 }
218 254
219 for (k = 0; k < 3; ++k) 255 for (k = 0; k < 3; ++k)
220 { 256 {
@@ -232,7 +268,8 @@ testMultithreadedPoolGet ()
232 cbc[i].size = 2048; 268 cbc[i].size = 2048;
233 cbc[i].pos = 0; 269 cbc[i].pos = 0;
234 270
235 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 271 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
272 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
236 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 273 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
237 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc[i]); 274 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc[i]);
238 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 275 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c
index d701e64d..c6b3ae27 100644
--- a/src/testcurl/test_large_put.c
+++ b/src/testcurl/test_large_put.c
@@ -182,19 +182,40 @@ testPutInternalThread (unsigned int add_flag)
182 int done_flag = 0; 182 int done_flag = 0;
183 CURLcode errornum; 183 CURLcode errornum;
184 char buf[2048]; 184 char buf[2048];
185 int port;
186
187 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
188 port = 0;
189 else
190 {
191 port = 1270;
192 if (oneone)
193 port += 10;
194 if (incr_read)
195 port += 20;
196 }
185 197
186 cbc.buf = buf; 198 cbc.buf = buf;
187 cbc.size = 2048; 199 cbc.size = 2048;
188 cbc.pos = 0; 200 cbc.pos = 0;
189 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | add_flag, 201 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | add_flag,
190 1080, 202 port,
191 NULL, NULL, &ahc_echo, &done_flag, 203 NULL, NULL, &ahc_echo, &done_flag,
192 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)), 204 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)),
193 MHD_OPTION_END); 205 MHD_OPTION_END);
194 if (d == NULL) 206 if (d == NULL)
195 return 1; 207 return 1;
208 if (0 == port)
209 {
210 const union MHD_DaemonInfo *dinfo;
211 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
212 if (NULL == dinfo || 0 == dinfo->port)
213 { MHD_stop_daemon (d); return 32; }
214 port = (int)dinfo->port;
215 }
196 c = curl_easy_init (); 216 c = curl_easy_init ();
197 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); 217 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
218 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
198 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 219 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
199 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 220 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
200 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 221 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -240,20 +261,41 @@ testPutThreadPerConn (unsigned int add_flag)
240 int done_flag = 0; 261 int done_flag = 0;
241 CURLcode errornum; 262 CURLcode errornum;
242 char buf[2048]; 263 char buf[2048];
264 int port;
265
266 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
267 port = 0;
268 else
269 {
270 port = 1271;
271 if (oneone)
272 port += 10;
273 if (incr_read)
274 port += 20;
275 }
243 276
244 cbc.buf = buf; 277 cbc.buf = buf;
245 cbc.size = 2048; 278 cbc.size = 2048;
246 cbc.pos = 0; 279 cbc.pos = 0;
247 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | 280 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD |
248 MHD_USE_ERROR_LOG | add_flag, 281 MHD_USE_ERROR_LOG | add_flag,
249 1081, 282 port,
250 NULL, NULL, &ahc_echo, &done_flag, 283 NULL, NULL, &ahc_echo, &done_flag,
251 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)), 284 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)),
252 MHD_OPTION_END); 285 MHD_OPTION_END);
253 if (d == NULL) 286 if (d == NULL)
254 return 16; 287 return 16;
288 if (0 == port)
289 {
290 const union MHD_DaemonInfo *dinfo;
291 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
292 if (NULL == dinfo || 0 == dinfo->port)
293 { MHD_stop_daemon (d); return 32; }
294 port = (int)dinfo->port;
295 }
255 c = curl_easy_init (); 296 c = curl_easy_init ();
256 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 297 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
298 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
257 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 299 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
258 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 300 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
259 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 301 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -302,20 +344,41 @@ testPutThreadPool (unsigned int add_flag)
302 int done_flag = 0; 344 int done_flag = 0;
303 CURLcode errornum; 345 CURLcode errornum;
304 char buf[2048]; 346 char buf[2048];
347 int port;
348
349 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
350 port = 0;
351 else
352 {
353 port = 1272;
354 if (oneone)
355 port += 10;
356 if (incr_read)
357 port += 20;
358 }
305 359
306 cbc.buf = buf; 360 cbc.buf = buf;
307 cbc.size = 2048; 361 cbc.size = 2048;
308 cbc.pos = 0; 362 cbc.pos = 0;
309 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | add_flag, 363 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | add_flag,
310 1081, 364 port,
311 NULL, NULL, &ahc_echo, &done_flag, 365 NULL, NULL, &ahc_echo, &done_flag,
312 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, 366 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT,
313 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)), 367 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)),
314 MHD_OPTION_END); 368 MHD_OPTION_END);
315 if (d == NULL) 369 if (d == NULL)
316 return 16; 370 return 16;
371 if (0 == port)
372 {
373 const union MHD_DaemonInfo *dinfo;
374 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
375 if (NULL == dinfo || 0 == dinfo->port)
376 { MHD_stop_daemon (d); return 32; }
377 port = (int)dinfo->port;
378 }
317 c = curl_easy_init (); 379 c = curl_easy_init ();
318 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 380 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
381 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
319 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 382 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
320 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 383 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
321 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 384 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -378,20 +441,41 @@ testPutExternal (void)
378 size_t pos = 0; 441 size_t pos = 0;
379 int done_flag = 0; 442 int done_flag = 0;
380 char buf[2048]; 443 char buf[2048];
444 int port;
445
446 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
447 port = 0;
448 else
449 {
450 port = 1273;
451 if (oneone)
452 port += 10;
453 if (incr_read)
454 port += 20;
455 }
381 456
382 cbc.buf = buf; 457 cbc.buf = buf;
383 cbc.size = 2048; 458 cbc.size = 2048;
384 cbc.pos = 0; 459 cbc.pos = 0;
385 multi = NULL; 460 multi = NULL;
386 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 461 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
387 1082, 462 port,
388 NULL, NULL, &ahc_echo, &done_flag, 463 NULL, NULL, &ahc_echo, &done_flag,
389 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)), 464 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)(incr_read ? 1024 : (PUT_SIZE * 4)),
390 MHD_OPTION_END); 465 MHD_OPTION_END);
391 if (d == NULL) 466 if (d == NULL)
392 return 256; 467 return 256;
468 if (0 == port)
469 {
470 const union MHD_DaemonInfo *dinfo;
471 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
472 if (NULL == dinfo || 0 == dinfo->port)
473 { MHD_stop_daemon (d); return 32; }
474 port = (int)dinfo->port;
475 }
393 c = curl_easy_init (); 476 c = curl_easy_init ();
394 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); 477 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
478 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
395 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 479 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
396 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 480 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
397 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 481 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
diff --git a/src/testcurl/test_long_header.c b/src/testcurl/test_long_header.c
index a82464b8..31a8581d 100644
--- a/src/testcurl/test_long_header.c
+++ b/src/testcurl/test_long_header.c
@@ -97,12 +97,21 @@ testLongUrlGet ()
97 struct CBC cbc; 97 struct CBC cbc;
98 char *url; 98 char *url;
99 long code; 99 long code;
100 int port;
100 101
102 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
103 port = 0;
104 else
105 {
106 port = 1330;
107 if (oneone)
108 port += 5;
109 }
101 cbc.buf = buf; 110 cbc.buf = buf;
102 cbc.size = 2048; 111 cbc.size = 2048;
103 cbc.pos = 0; 112 cbc.pos = 0;
104 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , 113 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ ,
105 1080, 114 port,
106 &apc_all, 115 &apc_all,
107 NULL, 116 NULL,
108 &ahc_echo, 117 &ahc_echo,
@@ -111,6 +120,14 @@ testLongUrlGet ()
111 (size_t) (VERY_LONG / 2), MHD_OPTION_END); 120 (size_t) (VERY_LONG / 2), MHD_OPTION_END);
112 if (d == NULL) 121 if (d == NULL)
113 return 1; 122 return 1;
123 if (0 == port)
124 {
125 const union MHD_DaemonInfo *dinfo;
126 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
127 if (NULL == dinfo || 0 == dinfo->port)
128 { MHD_stop_daemon (d); return 32; }
129 port = (int)dinfo->port;
130 }
114 c = curl_easy_init (); 131 c = curl_easy_init ();
115 url = malloc (VERY_LONG); 132 url = malloc (VERY_LONG);
116 if (url == NULL) 133 if (url == NULL)
@@ -120,8 +137,9 @@ testLongUrlGet ()
120 } 137 }
121 memset (url, 'a', VERY_LONG); 138 memset (url, 'a', VERY_LONG);
122 url[VERY_LONG - 1] = '\0'; 139 url[VERY_LONG - 1] = '\0';
123 memcpy (url, "http://127.0.0.1:1080/", strlen ("http://127.0.0.1:1080/")); 140 memcpy (url, "http://127.0.0.1/", strlen ("http://127.0.0.1/"));
124 curl_easy_setopt (c, CURLOPT_URL, url); 141 curl_easy_setopt (c, CURLOPT_URL, url);
142 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
125 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 143 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
126 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 144 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
127 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 145 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -168,12 +186,22 @@ testLongHeaderGet ()
168 char *url; 186 char *url;
169 long code; 187 long code;
170 struct curl_slist *header = NULL; 188 struct curl_slist *header = NULL;
189 int port;
190
191 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
192 port = 0;
193 else
194 {
195 port = 1331;
196 if (oneone)
197 port += 5;
198 }
171 199
172 cbc.buf = buf; 200 cbc.buf = buf;
173 cbc.size = 2048; 201 cbc.size = 2048;
174 cbc.pos = 0; 202 cbc.pos = 0;
175 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , 203 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ ,
176 1080, 204 port,
177 &apc_all, 205 &apc_all,
178 NULL, 206 NULL,
179 &ahc_echo, 207 &ahc_echo,
@@ -182,6 +210,14 @@ testLongHeaderGet ()
182 (size_t) (VERY_LONG / 2), MHD_OPTION_END); 210 (size_t) (VERY_LONG / 2), MHD_OPTION_END);
183 if (d == NULL) 211 if (d == NULL)
184 return 16; 212 return 16;
213 if (0 == port)
214 {
215 const union MHD_DaemonInfo *dinfo;
216 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
217 if (NULL == dinfo || 0 == dinfo->port)
218 { MHD_stop_daemon (d); return 32; }
219 port = (int)dinfo->port;
220 }
185 c = curl_easy_init (); 221 c = curl_easy_init ();
186 url = malloc (VERY_LONG); 222 url = malloc (VERY_LONG);
187 if (url == NULL) 223 if (url == NULL)
@@ -196,7 +232,8 @@ testLongHeaderGet ()
196 header = curl_slist_append (header, url); 232 header = curl_slist_append (header, url);
197 233
198 curl_easy_setopt (c, CURLOPT_HTTPHEADER, header); 234 curl_easy_setopt (c, CURLOPT_HTTPHEADER, header);
199 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); 235 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
236 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
200 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 237 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
201 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 238 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
202 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 239 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
diff --git a/src/testcurl/test_options.c b/src/testcurl/test_options.c
index 7b0949a1..317968e5 100644
--- a/src/testcurl/test_options.c
+++ b/src/testcurl/test_options.c
@@ -80,17 +80,17 @@ test_ip_addr_option ()
80 80
81 memset (&daemon_ip_addr, 0, sizeof (struct sockaddr_in)); 81 memset (&daemon_ip_addr, 0, sizeof (struct sockaddr_in));
82 daemon_ip_addr.sin_family = AF_INET; 82 daemon_ip_addr.sin_family = AF_INET;
83 daemon_ip_addr.sin_port = htons (4233); 83 daemon_ip_addr.sin_port = 0;
84 daemon_ip_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); 84 daemon_ip_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
85 85
86#if HAVE_INET6 86#if HAVE_INET6
87 memset (&daemon_ip_addr6, 0, sizeof (struct sockaddr_in6)); 87 memset (&daemon_ip_addr6, 0, sizeof (struct sockaddr_in6));
88 daemon_ip_addr6.sin6_family = AF_INET6; 88 daemon_ip_addr6.sin6_family = AF_INET6;
89 daemon_ip_addr6.sin6_port = htons (4233); 89 daemon_ip_addr6.sin6_port = 0;
90 daemon_ip_addr6.sin6_addr = in6addr_loopback; 90 daemon_ip_addr6.sin6_addr = in6addr_loopback;
91#endif 91#endif
92 92
93 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 4233, 93 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 0,
94 NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, 94 NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR,
95 &daemon_ip_addr, MHD_OPTION_END); 95 &daemon_ip_addr, MHD_OPTION_END);
96 96
@@ -100,7 +100,7 @@ test_ip_addr_option ()
100 MHD_stop_daemon (d); 100 MHD_stop_daemon (d);
101 101
102#if HAVE_INET6 102#if HAVE_INET6
103 d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_IPv6, 4233, 103 d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_IPv6, 0,
104 NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, 104 NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR,
105 &daemon_ip_addr6, MHD_OPTION_END); 105 &daemon_ip_addr6, MHD_OPTION_END);
106 106
diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c
index f2a3647d..d04815d5 100644
--- a/src/testcurl/test_parse_cookies.c
+++ b/src/testcurl/test_parse_cookies.c
@@ -126,17 +126,36 @@ testExternalGet ()
126 struct CURLMsg *msg; 126 struct CURLMsg *msg;
127 time_t start; 127 time_t start;
128 struct timeval tv; 128 struct timeval tv;
129 int port;
130
131 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
132 port = 0;
133 else
134 {
135 port = 1340;
136 if (oneone)
137 port += 5;
138 }
129 139
130 multi = NULL; 140 multi = NULL;
131 cbc.buf = buf; 141 cbc.buf = buf;
132 cbc.size = 2048; 142 cbc.size = 2048;
133 cbc.pos = 0; 143 cbc.pos = 0;
134 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 144 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
135 21080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 145 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
136 if (d == NULL) 146 if (d == NULL)
137 return 256; 147 return 256;
148 if (0 == port)
149 {
150 const union MHD_DaemonInfo *dinfo;
151 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
152 if (NULL == dinfo || 0 == dinfo->port)
153 { MHD_stop_daemon (d); return 32; }
154 port = (int)dinfo->port;
155 }
138 c = curl_easy_init (); 156 c = curl_easy_init ();
139 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:21080/hello_world"); 157 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
158 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
140 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 159 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
141 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 160 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
142 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 161 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c
index cb9ded6e..41d219fa 100644
--- a/src/testcurl/test_post.c
+++ b/src/testcurl/test_post.c
@@ -166,18 +166,37 @@ testInternalPost ()
166 char buf[2048]; 166 char buf[2048];
167 struct CBC cbc; 167 struct CBC cbc;
168 CURLcode errornum; 168 CURLcode errornum;
169 int port;
170
171 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
172 port = 0;
173 else
174 {
175 port = 1370;
176 if (oneone)
177 port += 10;
178 }
169 179
170 cbc.buf = buf; 180 cbc.buf = buf;
171 cbc.size = 2048; 181 cbc.size = 2048;
172 cbc.pos = 0; 182 cbc.pos = 0;
173 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 183 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
174 1080, NULL, NULL, &ahc_echo, NULL, 184 port, NULL, NULL, &ahc_echo, NULL,
175 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 185 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
176 MHD_OPTION_END); 186 MHD_OPTION_END);
177 if (d == NULL) 187 if (d == NULL)
178 return 1; 188 return 1;
189 if (0 == port)
190 {
191 const union MHD_DaemonInfo *dinfo;
192 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
193 if (NULL == dinfo || 0 == dinfo->port)
194 { MHD_stop_daemon (d); return 32; }
195 port = (int)dinfo->port;
196 }
179 c = curl_easy_init (); 197 c = curl_easy_init ();
180 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); 198 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
199 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
181 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 200 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
182 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 201 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
183 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 202 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA);
@@ -220,18 +239,37 @@ testMultithreadedPost ()
220 char buf[2048]; 239 char buf[2048];
221 struct CBC cbc; 240 struct CBC cbc;
222 CURLcode errornum; 241 CURLcode errornum;
242 int port;
243
244 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
245 port = 0;
246 else
247 {
248 port = 1371;
249 if (oneone)
250 port += 10;
251 }
223 252
224 cbc.buf = buf; 253 cbc.buf = buf;
225 cbc.size = 2048; 254 cbc.size = 2048;
226 cbc.pos = 0; 255 cbc.pos = 0;
227 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 256 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
228 1081, NULL, NULL, &ahc_echo, NULL, 257 port, NULL, NULL, &ahc_echo, NULL,
229 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 258 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
230 MHD_OPTION_END); 259 MHD_OPTION_END);
231 if (d == NULL) 260 if (d == NULL)
232 return 16; 261 return 16;
262 if (0 == port)
263 {
264 const union MHD_DaemonInfo *dinfo;
265 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
266 if (NULL == dinfo || 0 == dinfo->port)
267 { MHD_stop_daemon (d); return 32; }
268 port = (int)dinfo->port;
269 }
233 c = curl_easy_init (); 270 c = curl_easy_init ();
234 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 271 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
272 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
235 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 273 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
236 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 274 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
237 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 275 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA);
@@ -274,19 +312,38 @@ testMultithreadedPoolPost ()
274 char buf[2048]; 312 char buf[2048];
275 struct CBC cbc; 313 struct CBC cbc;
276 CURLcode errornum; 314 CURLcode errornum;
315 int port;
316
317 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
318 port = 0;
319 else
320 {
321 port = 1372;
322 if (oneone)
323 port += 10;
324 }
277 325
278 cbc.buf = buf; 326 cbc.buf = buf;
279 cbc.size = 2048; 327 cbc.size = 2048;
280 cbc.pos = 0; 328 cbc.pos = 0;
281 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 329 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
282 1081, NULL, NULL, &ahc_echo, NULL, 330 port, NULL, NULL, &ahc_echo, NULL,
283 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, 331 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT,
284 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 332 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
285 MHD_OPTION_END); 333 MHD_OPTION_END);
286 if (d == NULL) 334 if (d == NULL)
287 return 16; 335 return 16;
336 if (0 == port)
337 {
338 const union MHD_DaemonInfo *dinfo;
339 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
340 if (NULL == dinfo || 0 == dinfo->port)
341 { MHD_stop_daemon (d); return 32; }
342 port = (int)dinfo->port;
343 }
288 c = curl_easy_init (); 344 c = curl_easy_init ();
289 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 345 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
346 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
290 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 347 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
291 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 348 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
292 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 349 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA);
@@ -343,19 +400,38 @@ testExternalPost ()
343 struct CURLMsg *msg; 400 struct CURLMsg *msg;
344 time_t start; 401 time_t start;
345 struct timeval tv; 402 struct timeval tv;
403 int port;
404
405 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
406 port = 0;
407 else
408 {
409 port = 1373;
410 if (oneone)
411 port += 10;
412 }
346 413
347 multi = NULL; 414 multi = NULL;
348 cbc.buf = buf; 415 cbc.buf = buf;
349 cbc.size = 2048; 416 cbc.size = 2048;
350 cbc.pos = 0; 417 cbc.pos = 0;
351 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 418 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
352 1082, NULL, NULL, &ahc_echo, NULL, 419 port, NULL, NULL, &ahc_echo, NULL,
353 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 420 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
354 MHD_OPTION_END); 421 MHD_OPTION_END);
355 if (d == NULL) 422 if (d == NULL)
356 return 256; 423 return 256;
424 if (0 == port)
425 {
426 const union MHD_DaemonInfo *dinfo;
427 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
428 if (NULL == dinfo || 0 == dinfo->port)
429 { MHD_stop_daemon (d); return 32; }
430 port = (int)dinfo->port;
431 }
357 c = curl_easy_init (); 432 c = curl_easy_init ();
358 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); 433 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
434 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
359 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 435 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
360 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 436 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
361 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 437 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA);
@@ -550,6 +626,16 @@ testMultithreadedPostCancelPart(int flags)
550 CURLcode cc; 626 CURLcode cc;
551 int result = 0; 627 int result = 0;
552 struct CRBC crbc; 628 struct CRBC crbc;
629 int port;
630
631 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
632 port = 0;
633 else
634 {
635 port = 1374;
636 if (oneone)
637 port += 10;
638 }
553 639
554 /* Don't test features that aren't available with HTTP/1.0 in 640 /* Don't test features that aren't available with HTTP/1.0 in
555 * HTTP/1.0 mode. */ 641 * HTTP/1.0 mode. */
@@ -560,17 +646,26 @@ testMultithreadedPostCancelPart(int flags)
560 cbc.size = 2048; 646 cbc.size = 2048;
561 cbc.pos = 0; 647 cbc.pos = 0;
562 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 648 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
563 1081, NULL, NULL, &ahc_cancel, NULL, 649 port, NULL, NULL, &ahc_cancel, NULL,
564 MHD_OPTION_END); 650 MHD_OPTION_END);
565 if (d == NULL) 651 if (d == NULL)
566 return 32768; 652 return 32768;
653 if (0 == port)
654 {
655 const union MHD_DaemonInfo *dinfo;
656 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
657 if (NULL == dinfo || 0 == dinfo->port)
658 { MHD_stop_daemon (d); return 32; }
659 port = (int)dinfo->port;
660 }
567 661
568 crbc.buffer = "Test content"; 662 crbc.buffer = "Test content";
569 crbc.size = strlen(crbc.buffer); 663 crbc.size = strlen(crbc.buffer);
570 crbc.pos = 0; 664 crbc.pos = 0;
571 665
572 c = curl_easy_init (); 666 c = curl_easy_init ();
573 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 667 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
668 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
574 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 669 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
575 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 670 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
576 curl_easy_setopt (c, CURLOPT_READFUNCTION, (flags & FLAG_SLOW_READ) ? &slowReadBuffer : &readBuffer); 671 curl_easy_setopt (c, CURLOPT_READFUNCTION, (flags & FLAG_SLOW_READ) ? &slowReadBuffer : &readBuffer);
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 5495fd5a..9a4c6db1 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -116,13 +116,31 @@ testInternalPost ()
116 CURLcode errornum; 116 CURLcode errornum;
117 int i; 117 int i;
118 char url[1024]; 118 char url[1024];
119 int port;
120
121 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
122 port = 0;
123 else
124 {
125 port = 1350;
126 if (oneone)
127 port += 10;
128 }
119 129
120 cbc.buf = buf; 130 cbc.buf = buf;
121 cbc.size = 2048; 131 cbc.size = 2048;
122 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 132 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
123 1080, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 133 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END);
124 if (d == NULL) 134 if (d == NULL)
125 return 1; 135 return 1;
136 if (0 == port)
137 {
138 const union MHD_DaemonInfo *dinfo;
139 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
140 if (NULL == dinfo || 0 == dinfo->port)
141 { MHD_stop_daemon (d); return 32; }
142 port = (int)dinfo->port;
143 }
126 for (i = 0; i < LOOPCOUNT; i++) 144 for (i = 0; i < LOOPCOUNT; i++)
127 { 145 {
128 if (99 == i % 100) 146 if (99 == i % 100)
@@ -130,7 +148,7 @@ testInternalPost ()
130 c = curl_easy_init (); 148 c = curl_easy_init ();
131 cbc.pos = 0; 149 cbc.pos = 0;
132 buf[0] = '\0'; 150 buf[0] = '\0';
133 sprintf (url, "http://127.0.0.1:1080/hw%d", i); 151 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
134 curl_easy_setopt (c, CURLOPT_URL, url); 152 curl_easy_setopt (c, CURLOPT_URL, url);
135 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 153 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
136 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 154 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -180,13 +198,31 @@ testMultithreadedPost ()
180 CURLcode errornum; 198 CURLcode errornum;
181 int i; 199 int i;
182 char url[1024]; 200 char url[1024];
201 int port;
202
203 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
204 port = 0;
205 else
206 {
207 port = 1351;
208 if (oneone)
209 port += 10;
210 }
183 211
184 cbc.buf = buf; 212 cbc.buf = buf;
185 cbc.size = 2048; 213 cbc.size = 2048;
186 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 214 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
187 1081, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 215 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END);
188 if (d == NULL) 216 if (d == NULL)
189 return 16; 217 return 16;
218 if (0 == port)
219 {
220 const union MHD_DaemonInfo *dinfo;
221 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
222 if (NULL == dinfo || 0 == dinfo->port)
223 { MHD_stop_daemon (d); return 32; }
224 port = (int)dinfo->port;
225 }
190 for (i = 0; i < LOOPCOUNT; i++) 226 for (i = 0; i < LOOPCOUNT; i++)
191 { 227 {
192 if (99 == i % 100) 228 if (99 == i % 100)
@@ -194,7 +230,7 @@ testMultithreadedPost ()
194 c = curl_easy_init (); 230 c = curl_easy_init ();
195 cbc.pos = 0; 231 cbc.pos = 0;
196 buf[0] = '\0'; 232 buf[0] = '\0';
197 sprintf (url, "http://127.0.0.1:1081/hw%d", i); 233 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
198 curl_easy_setopt (c, CURLOPT_URL, url); 234 curl_easy_setopt (c, CURLOPT_URL, url);
199 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 235 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
200 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 236 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -244,14 +280,32 @@ testMultithreadedPoolPost ()
244 CURLcode errornum; 280 CURLcode errornum;
245 int i; 281 int i;
246 char url[1024]; 282 char url[1024];
283 int port;
284
285 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
286 port = 0;
287 else
288 {
289 port = 1352;
290 if (oneone)
291 port += 10;
292 }
247 293
248 cbc.buf = buf; 294 cbc.buf = buf;
249 cbc.size = 2048; 295 cbc.size = 2048;
250 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 296 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
251 1081, NULL, NULL, &ahc_echo, NULL, 297 port, NULL, NULL, &ahc_echo, NULL,
252 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 298 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
253 if (d == NULL) 299 if (d == NULL)
254 return 16; 300 return 16;
301 if (0 == port)
302 {
303 const union MHD_DaemonInfo *dinfo;
304 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
305 if (NULL == dinfo || 0 == dinfo->port)
306 { MHD_stop_daemon (d); return 32; }
307 port = (int)dinfo->port;
308 }
255 for (i = 0; i < LOOPCOUNT; i++) 309 for (i = 0; i < LOOPCOUNT; i++)
256 { 310 {
257 if (99 == i % 100) 311 if (99 == i % 100)
@@ -259,7 +313,7 @@ testMultithreadedPoolPost ()
259 c = curl_easy_init (); 313 c = curl_easy_init ();
260 cbc.pos = 0; 314 cbc.pos = 0;
261 buf[0] = '\0'; 315 buf[0] = '\0';
262 sprintf (url, "http://127.0.0.1:1081/hw%d", i); 316 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
263 curl_easy_setopt (c, CURLOPT_URL, url); 317 curl_easy_setopt (c, CURLOPT_URL, url);
264 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 318 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
265 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 319 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -325,15 +379,33 @@ testExternalPost ()
325 unsigned long long timeout; 379 unsigned long long timeout;
326 long ctimeout; 380 long ctimeout;
327 char url[1024]; 381 char url[1024];
382 int port;
383
384 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
385 port = 0;
386 else
387 {
388 port = 1353;
389 if (oneone)
390 port += 10;
391 }
328 392
329 multi = NULL; 393 multi = NULL;
330 cbc.buf = buf; 394 cbc.buf = buf;
331 cbc.size = 2048; 395 cbc.size = 2048;
332 cbc.pos = 0; 396 cbc.pos = 0;
333 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 397 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
334 1082, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 398 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END);
335 if (d == NULL) 399 if (d == NULL)
336 return 256; 400 return 256;
401 if (0 == port)
402 {
403 const union MHD_DaemonInfo *dinfo;
404 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
405 if (NULL == dinfo || 0 == dinfo->port)
406 { MHD_stop_daemon (d); return 32; }
407 port = (int)dinfo->port;
408 }
337 multi = curl_multi_init (); 409 multi = curl_multi_init ();
338 if (multi == NULL) 410 if (multi == NULL)
339 { 411 {
@@ -347,7 +419,7 @@ testExternalPost ()
347 c = curl_easy_init (); 419 c = curl_easy_init ();
348 cbc.pos = 0; 420 cbc.pos = 0;
349 buf[0] = '\0'; 421 buf[0] = '\0';
350 sprintf (url, "http://127.0.0.1:1082/hw%d", i); 422 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
351 curl_easy_setopt (c, CURLOPT_URL, url); 423 curl_easy_setopt (c, CURLOPT_URL, url);
352 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 424 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
353 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 425 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
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, &copyBuffer); 213 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
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, &copyBuffer); 288 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
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, &copyBuffer); 364 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
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, &copyBuffer); 454 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
379 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 455 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
380 pd = make_form (); 456 pd = make_form ();
diff --git a/src/testcurl/test_process_arguments.c b/src/testcurl/test_process_arguments.c
index 20556082..def5cd98 100644
--- a/src/testcurl/test_process_arguments.c
+++ b/src/testcurl/test_process_arguments.c
@@ -130,18 +130,37 @@ testExternalGet ()
130 struct CURLMsg *msg; 130 struct CURLMsg *msg;
131 time_t start; 131 time_t start;
132 struct timeval tv; 132 struct timeval tv;
133 int port;
134
135 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
136 port = 0;
137 else
138 {
139 port = 1410;
140 if (oneone)
141 port += 5;
142 }
133 143
134 multi = NULL; 144 multi = NULL;
135 cbc.buf = buf; 145 cbc.buf = buf;
136 cbc.size = 2048; 146 cbc.size = 2048;
137 cbc.pos = 0; 147 cbc.pos = 0;
138 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 148 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
139 21080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 149 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
140 if (d == NULL) 150 if (d == NULL)
141 return 256; 151 return 256;
152 if (0 == port)
153 {
154 const union MHD_DaemonInfo *dinfo;
155 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
156 if (NULL == dinfo || 0 == dinfo->port)
157 { MHD_stop_daemon (d); return 32; }
158 port = (int)dinfo->port;
159 }
142 c = curl_easy_init (); 160 c = curl_easy_init ();
143 curl_easy_setopt (c, CURLOPT_URL, 161 curl_easy_setopt (c, CURLOPT_URL,
144 "http://127.0.0.1:21080/hello+world?k=v+x&hash=%23foo&space=%A0bar"); 162 "http://127.0.0.1/hello+world?k=v+x&hash=%23foo&space=%A0bar");
163 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
145 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 164 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
146 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 165 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
147 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 166 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
diff --git a/src/testcurl/test_process_headers.c b/src/testcurl/test_process_headers.c
index 9c9c94d7..57fc3d31 100644
--- a/src/testcurl/test_process_headers.c
+++ b/src/testcurl/test_process_headers.c
@@ -69,7 +69,7 @@ static int
69kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) 69kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
70{ 70{
71 if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && 71 if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) &&
72 (0 == strcmp (value, "127.0.0.1:21080")) && (kind == MHD_HEADER_KIND)) 72 (0 == strncmp (value, "127.0.0.1", strlen("127.0.0.1"))) && (kind == MHD_HEADER_KIND))
73 { 73 {
74 *((int *) cls) = 1; 74 *((int *) cls) = 1;
75 return MHD_NO; 75 return MHD_NO;
@@ -113,7 +113,7 @@ ahc_echo (void *cls,
113 abort (); 113 abort ();
114 hdr = MHD_lookup_connection_value (connection, 114 hdr = MHD_lookup_connection_value (connection,
115 MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST); 115 MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST);
116 if ((hdr == NULL) || (0 != strcmp (hdr, "127.0.0.1:21080"))) 116 if ((hdr == NULL) || (0 != strncmp (hdr, "127.0.0.1", strlen("127.0.0.1"))))
117 abort (); 117 abort ();
118 MHD_set_connection_value (connection, 118 MHD_set_connection_value (connection,
119 MHD_HEADER_KIND, "FakeHeader", "NowPresent"); 119 MHD_HEADER_KIND, "FakeHeader", "NowPresent");
@@ -153,16 +153,35 @@ testInternalGet ()
153 char buf[2048]; 153 char buf[2048];
154 struct CBC cbc; 154 struct CBC cbc;
155 CURLcode errornum; 155 CURLcode errornum;
156 int port;
157
158 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
159 port = 0;
160 else
161 {
162 port = 1420;
163 if (oneone)
164 port += 10;
165 }
156 166
157 cbc.buf = buf; 167 cbc.buf = buf;
158 cbc.size = 2048; 168 cbc.size = 2048;
159 cbc.pos = 0; 169 cbc.pos = 0;
160 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 170 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
161 21080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 171 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
162 if (d == NULL) 172 if (d == NULL)
163 return 1; 173 return 1;
174 if (0 == port)
175 {
176 const union MHD_DaemonInfo *dinfo;
177 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
178 if (NULL == dinfo || 0 == dinfo->port)
179 { MHD_stop_daemon (d); return 32; }
180 port = (int)dinfo->port;
181 }
164 c = curl_easy_init (); 182 c = curl_easy_init ();
165 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:21080/hello_world"); 183 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
184 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
166 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 185 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
167 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 186 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
168 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 187 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -202,16 +221,35 @@ testMultithreadedGet ()
202 char buf[2048]; 221 char buf[2048];
203 struct CBC cbc; 222 struct CBC cbc;
204 CURLcode errornum; 223 CURLcode errornum;
224 int port;
225
226 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
227 port = 0;
228 else
229 {
230 port = 1421;
231 if (oneone)
232 port += 10;
233 }
205 234
206 cbc.buf = buf; 235 cbc.buf = buf;
207 cbc.size = 2048; 236 cbc.size = 2048;
208 cbc.pos = 0; 237 cbc.pos = 0;
209 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 238 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
210 21080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 239 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
211 if (d == NULL) 240 if (d == NULL)
212 return 16; 241 return 16;
242 if (0 == port)
243 {
244 const union MHD_DaemonInfo *dinfo;
245 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
246 if (NULL == dinfo || 0 == dinfo->port)
247 { MHD_stop_daemon (d); return 32; }
248 port = (int)dinfo->port;
249 }
213 c = curl_easy_init (); 250 c = curl_easy_init ();
214 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:21080/hello_world"); 251 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
252 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
215 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 253 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
216 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 254 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
217 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 255 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -251,17 +289,36 @@ testMultithreadedPoolGet ()
251 char buf[2048]; 289 char buf[2048];
252 struct CBC cbc; 290 struct CBC cbc;
253 CURLcode errornum; 291 CURLcode errornum;
292 int port;
293
294 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
295 port = 0;
296 else
297 {
298 port = 1422;
299 if (oneone)
300 port += 10;
301 }
254 302
255 cbc.buf = buf; 303 cbc.buf = buf;
256 cbc.size = 2048; 304 cbc.size = 2048;
257 cbc.pos = 0; 305 cbc.pos = 0;
258 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 306 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
259 21080, NULL, NULL, &ahc_echo, "GET", 307 port, NULL, NULL, &ahc_echo, "GET",
260 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 308 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
261 if (d == NULL) 309 if (d == NULL)
262 return 16; 310 return 16;
311 if (0 == port)
312 {
313 const union MHD_DaemonInfo *dinfo;
314 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
315 if (NULL == dinfo || 0 == dinfo->port)
316 { MHD_stop_daemon (d); return 32; }
317 port = (int)dinfo->port;
318 }
263 c = curl_easy_init (); 319 c = curl_easy_init ();
264 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:21080/hello_world"); 320 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
321 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
265 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 322 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
266 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 323 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
267 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 324 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -315,17 +372,36 @@ testExternalGet ()
315 struct CURLMsg *msg; 372 struct CURLMsg *msg;
316 time_t start; 373 time_t start;
317 struct timeval tv; 374 struct timeval tv;
375 int port;
376
377 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
378 port = 0;
379 else
380 {
381 port = 1423;
382 if (oneone)
383 port += 10;
384 }
318 385
319 multi = NULL; 386 multi = NULL;
320 cbc.buf = buf; 387 cbc.buf = buf;
321 cbc.size = 2048; 388 cbc.size = 2048;
322 cbc.pos = 0; 389 cbc.pos = 0;
323 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 390 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
324 21080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 391 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
325 if (d == NULL) 392 if (d == NULL)
326 return 256; 393 return 256;
394 if (0 == port)
395 {
396 const union MHD_DaemonInfo *dinfo;
397 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
398 if (NULL == dinfo || 0 == dinfo->port)
399 { MHD_stop_daemon (d); return 32; }
400 port = (int)dinfo->port;
401 }
327 c = curl_easy_init (); 402 c = curl_easy_init ();
328 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:21080/hello_world"); 403 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
404 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
329 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 405 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
330 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 406 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
331 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 407 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c
index 54725374..f448c408 100644
--- a/src/testcurl/test_put.c
+++ b/src/testcurl/test_put.c
@@ -127,17 +127,36 @@ testInternalPut ()
127 unsigned int pos = 0; 127 unsigned int pos = 0;
128 int done_flag = 0; 128 int done_flag = 0;
129 CURLcode errornum; 129 CURLcode errornum;
130 int port;
131
132 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
133 port = 0;
134 else
135 {
136 port = 1450;
137 if (oneone)
138 port += 10;
139 }
130 140
131 cbc.buf = buf; 141 cbc.buf = buf;
132 cbc.size = 2048; 142 cbc.size = 2048;
133 cbc.pos = 0; 143 cbc.pos = 0;
134 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 144 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
135 1080, 145 port,
136 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 146 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
137 if (d == NULL) 147 if (d == NULL)
138 return 1; 148 return 1;
149 if (0 == port)
150 {
151 const union MHD_DaemonInfo *dinfo;
152 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
153 if (NULL == dinfo || 0 == dinfo->port)
154 { MHD_stop_daemon (d); return 32; }
155 port = (int)dinfo->port;
156 }
139 c = curl_easy_init (); 157 c = curl_easy_init ();
140 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); 158 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
159 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
141 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 160 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
142 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 161 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
143 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 162 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -183,17 +202,36 @@ testMultithreadedPut ()
183 unsigned int pos = 0; 202 unsigned int pos = 0;
184 int done_flag = 0; 203 int done_flag = 0;
185 CURLcode errornum; 204 CURLcode errornum;
205 int port;
206
207 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
208 port = 0;
209 else
210 {
211 port = 1451;
212 if (oneone)
213 port += 10;
214 }
186 215
187 cbc.buf = buf; 216 cbc.buf = buf;
188 cbc.size = 2048; 217 cbc.size = 2048;
189 cbc.pos = 0; 218 cbc.pos = 0;
190 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 219 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
191 1081, 220 port,
192 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 221 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
193 if (d == NULL) 222 if (d == NULL)
194 return 16; 223 return 16;
224 if (0 == port)
225 {
226 const union MHD_DaemonInfo *dinfo;
227 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
228 if (NULL == dinfo || 0 == dinfo->port)
229 { MHD_stop_daemon (d); return 32; }
230 port = (int)dinfo->port;
231 }
195 c = curl_easy_init (); 232 c = curl_easy_init ();
196 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 233 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
234 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
197 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 235 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
198 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 236 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
199 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 237 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -240,18 +278,37 @@ testMultithreadedPoolPut ()
240 unsigned int pos = 0; 278 unsigned int pos = 0;
241 int done_flag = 0; 279 int done_flag = 0;
242 CURLcode errornum; 280 CURLcode errornum;
281 int port;
282
283 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
284 port = 0;
285 else
286 {
287 port = 1452;
288 if (oneone)
289 port += 10;
290 }
243 291
244 cbc.buf = buf; 292 cbc.buf = buf;
245 cbc.size = 2048; 293 cbc.size = 2048;
246 cbc.pos = 0; 294 cbc.pos = 0;
247 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 295 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
248 1081, 296 port,
249 NULL, NULL, &ahc_echo, &done_flag, 297 NULL, NULL, &ahc_echo, &done_flag,
250 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 298 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
251 if (d == NULL) 299 if (d == NULL)
252 return 16; 300 return 16;
301 if (0 == port)
302 {
303 const union MHD_DaemonInfo *dinfo;
304 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
305 if (NULL == dinfo || 0 == dinfo->port)
306 { MHD_stop_daemon (d); return 32; }
307 port = (int)dinfo->port;
308 }
253 c = curl_easy_init (); 309 c = curl_easy_init ();
254 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); 310 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
311 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
255 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 312 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
256 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 313 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
257 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 314 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -313,19 +370,38 @@ testExternalPut ()
313 struct timeval tv; 370 struct timeval tv;
314 unsigned int pos = 0; 371 unsigned int pos = 0;
315 int done_flag = 0; 372 int done_flag = 0;
373 int port;
374
375 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
376 port = 0;
377 else
378 {
379 port = 1453;
380 if (oneone)
381 port += 10;
382 }
316 383
317 multi = NULL; 384 multi = NULL;
318 cbc.buf = buf; 385 cbc.buf = buf;
319 cbc.size = 2048; 386 cbc.size = 2048;
320 cbc.pos = 0; 387 cbc.pos = 0;
321 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 388 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
322 1082, 389 port,
323 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 390 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
324 if (d == NULL) 391 if (d == NULL)
325 return 256; 392 return 256;
393 if (0 == port)
394 {
395 const union MHD_DaemonInfo *dinfo;
396 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
397 if (NULL == dinfo || 0 == dinfo->port)
398 { MHD_stop_daemon (d); return 32; }
399 port = (int)dinfo->port;
400 }
326 c = curl_easy_init (); 401 c = curl_easy_init ();
327 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); 402 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
328 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 403 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
404curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
329 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 405 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
330 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 406 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
331 curl_easy_setopt (c, CURLOPT_READDATA, &pos); 407 curl_easy_setopt (c, CURLOPT_READDATA, &pos);
diff --git a/src/testcurl/test_put_chunked.c b/src/testcurl/test_put_chunked.c
index 48fef064..b7a7537c 100644
--- a/src/testcurl/test_put_chunked.c
+++ b/src/testcurl/test_put_chunked.c
@@ -137,17 +137,32 @@ testInternalPut ()
137 unsigned int pos = 0; 137 unsigned int pos = 0;
138 int done_flag = 0; 138 int done_flag = 0;
139 CURLcode errornum; 139 CURLcode errornum;
140 int port;
141
142 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
143 port = 0;
144 else
145 port = 1440;
140 146
141 cbc.buf = buf; 147 cbc.buf = buf;
142 cbc.size = 2048; 148 cbc.size = 2048;
143 cbc.pos = 0; 149 cbc.pos = 0;
144 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 150 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
145 11080, 151 port,
146 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 152 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
147 if (d == NULL) 153 if (d == NULL)
148 return 1; 154 return 1;
155 if (0 == port)
156 {
157 const union MHD_DaemonInfo *dinfo;
158 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
159 if (NULL == dinfo || 0 == dinfo->port)
160 { MHD_stop_daemon (d); return 32; }
161 port = (int)dinfo->port;
162 }
149 c = curl_easy_init (); 163 c = curl_easy_init ();
150 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11080/hello_world"); 164 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
165 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
151 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 166 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
152 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 167 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
153 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 168 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -193,17 +208,32 @@ testMultithreadedPut ()
193 unsigned int pos = 0; 208 unsigned int pos = 0;
194 int done_flag = 0; 209 int done_flag = 0;
195 CURLcode errornum; 210 CURLcode errornum;
211 int port;
212
213 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
214 port = 0;
215 else
216 port = 1441;
196 217
197 cbc.buf = buf; 218 cbc.buf = buf;
198 cbc.size = 2048; 219 cbc.size = 2048;
199 cbc.pos = 0; 220 cbc.pos = 0;
200 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 221 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
201 11081, 222 port,
202 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 223 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
203 if (d == NULL) 224 if (d == NULL)
204 return 16; 225 return 16;
226 if (0 == port)
227 {
228 const union MHD_DaemonInfo *dinfo;
229 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
230 if (NULL == dinfo || 0 == dinfo->port)
231 { MHD_stop_daemon (d); return 32; }
232 port = (int)dinfo->port;
233 }
205 c = curl_easy_init (); 234 c = curl_easy_init ();
206 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); 235 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
236 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
207 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 237 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
208 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 238 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
209 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 239 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -250,18 +280,33 @@ testMultithreadedPoolPut ()
250 unsigned int pos = 0; 280 unsigned int pos = 0;
251 int done_flag = 0; 281 int done_flag = 0;
252 CURLcode errornum; 282 CURLcode errornum;
283 int port;
284
285 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
286 port = 0;
287 else
288 port = 1442;
253 289
254 cbc.buf = buf; 290 cbc.buf = buf;
255 cbc.size = 2048; 291 cbc.size = 2048;
256 cbc.pos = 0; 292 cbc.pos = 0;
257 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 293 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
258 11081, 294 port,
259 NULL, NULL, &ahc_echo, &done_flag, 295 NULL, NULL, &ahc_echo, &done_flag,
260 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 296 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
261 if (d == NULL) 297 if (d == NULL)
262 return 16; 298 return 16;
299 if (0 == port)
300 {
301 const union MHD_DaemonInfo *dinfo;
302 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
303 if (NULL == dinfo || 0 == dinfo->port)
304 { MHD_stop_daemon (d); return 32; }
305 port = (int)dinfo->port;
306 }
263 c = curl_easy_init (); 307 c = curl_easy_init ();
264 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); 308 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
309 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
265 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 310 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
266 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 311 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
267 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 312 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
@@ -323,18 +368,33 @@ testExternalPut ()
323 struct timeval tv; 368 struct timeval tv;
324 unsigned int pos = 0; 369 unsigned int pos = 0;
325 int done_flag = 0; 370 int done_flag = 0;
371 int port;
372
373 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
374 port = 0;
375 else
376 port = 1443;
326 377
327 multi = NULL; 378 multi = NULL;
328 cbc.buf = buf; 379 cbc.buf = buf;
329 cbc.size = 2048; 380 cbc.size = 2048;
330 cbc.pos = 0; 381 cbc.pos = 0;
331 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 382 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
332 11082, 383 port,
333 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); 384 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
334 if (d == NULL) 385 if (d == NULL)
335 return 256; 386 return 256;
387 if (0 == port)
388 {
389 const union MHD_DaemonInfo *dinfo;
390 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
391 if (NULL == dinfo || 0 == dinfo->port)
392 { MHD_stop_daemon (d); return 32; }
393 port = (int)dinfo->port;
394 }
336 c = curl_easy_init (); 395 c = curl_easy_init ();
337 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11082/hello_world"); 396 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
397 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
338 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 398 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
339 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 399 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
340 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); 400 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c
index 682d866e..59eea2d0 100644
--- a/src/testcurl/test_quiesce.c
+++ b/src/testcurl/test_quiesce.c
@@ -55,6 +55,7 @@ struct CBC
55 size_t size; 55 size_t size;
56}; 56};
57 57
58static int port;
58 59
59static size_t 60static size_t
60copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) 61copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
@@ -126,7 +127,7 @@ ServeOneRequest(void *param)
126 fd = (MHD_socket) (intptr_t) param; 127 fd = (MHD_socket) (intptr_t) param;
127 128
128 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 129 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
129 1082, NULL, NULL, &ahc_echo, "GET", 130 0, NULL, NULL, &ahc_echo, "GET",
130 MHD_OPTION_LISTEN_SOCKET, fd, 131 MHD_OPTION_LISTEN_SOCKET, fd,
131 MHD_OPTION_NOTIFY_COMPLETED, &request_completed, &done, 132 MHD_OPTION_NOTIFY_COMPLETED, &request_completed, &done,
132 MHD_OPTION_END); 133 MHD_OPTION_END);
@@ -172,7 +173,8 @@ setupCURL (void *cbc)
172 CURL *c; 173 CURL *c;
173 174
174 c = curl_easy_init (); 175 c = curl_easy_init ();
175 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11080/hello_world"); 176 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
177 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
176 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 178 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
177 curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc); 179 curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc);
178 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 180 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -200,20 +202,33 @@ testGet (int type, int pool_count, int poll_flag)
200 pthread_t thrd; 202 pthread_t thrd;
201 const char *thrdRet; 203 const char *thrdRet;
202 204
205 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
206 port = 0;
207 else
208 port = 1480;
209
203 cbc.buf = buf; 210 cbc.buf = buf;
204 cbc.size = 2048; 211 cbc.size = 2048;
205 cbc.pos = 0; 212 cbc.pos = 0;
206 if (pool_count > 0) { 213 if (pool_count > 0) {
207 d = MHD_start_daemon (type | MHD_USE_ERROR_LOG | MHD_USE_ITC | poll_flag, 214 d = MHD_start_daemon (type | MHD_USE_ERROR_LOG | MHD_USE_ITC | poll_flag,
208 11080, NULL, NULL, &ahc_echo, "GET", 215 port, NULL, NULL, &ahc_echo, "GET",
209 MHD_OPTION_THREAD_POOL_SIZE, pool_count, MHD_OPTION_END); 216 MHD_OPTION_THREAD_POOL_SIZE, pool_count, MHD_OPTION_END);
210 217
211 } else { 218 } else {
212 d = MHD_start_daemon (type | MHD_USE_ERROR_LOG | MHD_USE_ITC | poll_flag, 219 d = MHD_start_daemon (type | MHD_USE_ERROR_LOG | MHD_USE_ITC | poll_flag,
213 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 220 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
214 } 221 }
215 if (d == NULL) 222 if (d == NULL)
216 return 1; 223 return 1;
224 if (0 == port)
225 {
226 const union MHD_DaemonInfo *dinfo;
227 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
228 if (NULL == dinfo || 0 == dinfo->port)
229 { MHD_stop_daemon (d); return 32; }
230 port = (int)dinfo->port;
231 }
217 232
218 c = setupCURL(&cbc); 233 c = setupCURL(&cbc);
219 234
@@ -342,17 +357,30 @@ testExternalGet ()
342 int i; 357 int i;
343 MHD_socket fd; 358 MHD_socket fd;
344 359
360 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
361 port = 0;
362 else
363 port = 1481;
364
345 multi = NULL; 365 multi = NULL;
346 cbc.buf = buf; 366 cbc.buf = buf;
347 cbc.size = 2048; 367 cbc.size = 2048;
348 cbc.pos = 0; 368 cbc.pos = 0;
349 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 369 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
350 11080, 370 port,
351 NULL, NULL, 371 NULL, NULL,
352 &ahc_echo, "GET", 372 &ahc_echo, "GET",
353 MHD_OPTION_END); 373 MHD_OPTION_END);
354 if (d == NULL) 374 if (d == NULL)
355 return 256; 375 return 256;
376 if (0 == port)
377 {
378 const union MHD_DaemonInfo *dinfo;
379 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
380 if (NULL == dinfo || 0 == dinfo->port)
381 { MHD_stop_daemon (d); return 32; }
382 port = (int)dinfo->port;
383 }
356 c = setupCURL(&cbc); 384 c = setupCURL(&cbc);
357 385
358 multi = curl_multi_init (); 386 multi = curl_multi_init ();
diff --git a/src/testcurl/test_quiesce_stream.c b/src/testcurl/test_quiesce_stream.c
index 38263e07..62dc97de 100644
--- a/src/testcurl/test_quiesce_stream.c
+++ b/src/testcurl/test_quiesce_stream.c
@@ -22,6 +22,7 @@
22 * @brief Testcase for libmicrohttpd quiescing 22 * @brief Testcase for libmicrohttpd quiescing
23 * @author Markus Doppelbauer 23 * @author Markus Doppelbauer
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Karlson2k (Evgeny Grin)
25 */ 26 */
26#include "mhd_options.h" 27#include "mhd_options.h"
27#include <stdlib.h> 28#include <stdlib.h>
@@ -166,8 +167,16 @@ http_AccessHandlerCallback (void *cls,
166 167
167 168
168int 169int
169main() 170main(void)
170{ 171{
172 int port;
173 char command_line[1024];
174
175 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
176 port = 0;
177 else
178 port = 1470;
179
171 /* Panic callback */ 180 /* Panic callback */
172 MHD_set_panic_func (&http_PanicCallback, 181 MHD_set_panic_func (&http_PanicCallback,
173 NULL); 182 NULL);
@@ -181,7 +190,7 @@ main()
181 190
182 /* Create daemon */ 191 /* Create daemon */
183 struct MHD_Daemon *daemon = MHD_start_daemon (daemon_flags, 192 struct MHD_Daemon *daemon = MHD_start_daemon (daemon_flags,
184 8000, 193 port,
185 NULL, 194 NULL,
186 NULL, 195 NULL,
187 &http_AccessHandlerCallback, 196 &http_AccessHandlerCallback,
@@ -189,7 +198,17 @@ main()
189 MHD_OPTION_END); 198 MHD_OPTION_END);
190 if (NULL == daemon) 199 if (NULL == daemon)
191 return 1; 200 return 1;
192 if (0 != system ("curl -s http://127.0.0.1:8000")) 201 if (0 == port)
202 {
203 const union MHD_DaemonInfo *dinfo;
204 dinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_BIND_PORT);
205 if (NULL == dinfo || 0 == dinfo->port)
206 { MHD_stop_daemon (daemon); return 32; }
207 port = (int)dinfo->port;
208 }
209 sprintf(command_line, "curl -s http://127.0.0.1:%d", port);
210
211 if (0 != system (command_line))
193 { 212 {
194 MHD_stop_daemon (daemon); 213 MHD_stop_daemon (daemon);
195 return 1; 214 return 1;
diff --git a/src/testcurl/test_start_stop.c b/src/testcurl/test_start_stop.c
index 7a4e36e4..71d50f54 100644
--- a/src/testcurl/test_start_stop.c
+++ b/src/testcurl/test_start_stop.c
@@ -55,7 +55,7 @@ testInternalGet (int poll_flag)
55 struct MHD_Daemon *d; 55 struct MHD_Daemon *d;
56 56
57 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 57 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
58 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 58 0, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
59 if (d == NULL) 59 if (d == NULL)
60 return 1; 60 return 1;
61 MHD_stop_daemon (d); 61 MHD_stop_daemon (d);
@@ -68,7 +68,7 @@ testMultithreadedGet (int poll_flag)
68 struct MHD_Daemon *d; 68 struct MHD_Daemon *d;
69 69
70 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 70 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
71 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 71 0, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
72 if (d == NULL) 72 if (d == NULL)
73 return 2; 73 return 2;
74 MHD_stop_daemon (d); 74 MHD_stop_daemon (d);
@@ -81,7 +81,7 @@ testMultithreadedPoolGet (int poll_flag)
81 struct MHD_Daemon *d; 81 struct MHD_Daemon *d;
82 82
83 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 83 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
84 1081, NULL, NULL, &ahc_echo, "GET", 84 0, NULL, NULL, &ahc_echo, "GET",
85 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 85 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
86 if (d == NULL) 86 if (d == NULL)
87 return 4; 87 return 4;
@@ -95,7 +95,7 @@ testExternalGet ()
95 struct MHD_Daemon *d; 95 struct MHD_Daemon *d;
96 96
97 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 97 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
98 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 98 0, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
99 if (d == NULL) 99 if (d == NULL)
100 return 8; 100 return 8;
101 MHD_stop_daemon (d); 101 MHD_stop_daemon (d);
diff --git a/src/testcurl/test_termination.c b/src/testcurl/test_termination.c
index fc67c1e2..31466ff3 100644
--- a/src/testcurl/test_termination.c
+++ b/src/testcurl/test_termination.c
@@ -23,7 +23,6 @@
23 * @brief Testcase for libmicrohttpd tolerating client not closing immediately 23 * @brief Testcase for libmicrohttpd tolerating client not closing immediately
24 * @author hollosig 24 * @author hollosig
25 */ 25 */
26#define PORT 12345
27 26
28#include "platform.h" 27#include "platform.h"
29#include <stdio.h> 28#include <stdio.h>
@@ -90,9 +89,16 @@ int
90main () 89main ()
91{ 90{
92 struct MHD_Daemon *daemon; 91 struct MHD_Daemon *daemon;
92 int port;
93
94 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
95 port = 0;
96 else
97 port = 1490;
98
93 99
94 daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 100 daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
95 PORT, 101 port,
96 NULL, 102 NULL,
97 NULL, connection_handler, NULL, MHD_OPTION_END); 103 NULL, connection_handler, NULL, MHD_OPTION_END);
98 104
@@ -101,11 +107,19 @@ main ()
101 fprintf (stderr, "Daemon cannot be started!"); 107 fprintf (stderr, "Daemon cannot be started!");
102 exit (1); 108 exit (1);
103 } 109 }
110 if (0 == port)
111 {
112 const union MHD_DaemonInfo *dinfo;
113 dinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_BIND_PORT);
114 if (NULL == dinfo || 0 == dinfo->port)
115 { MHD_stop_daemon (daemon); return 32; }
116 port = (int)dinfo->port;
117 }
104 118
105 CURL *curl = curl_easy_init (); 119 CURL *curl = curl_easy_init ();
106 //curl_easy_setopt(curl, CURLOPT_POST, 1L); 120 //curl_easy_setopt(curl, CURLOPT_POST, 1L);
107 char url[255]; 121 char url[255];
108 sprintf (url, "http://127.0.0.1:%d", PORT); 122 sprintf (url, "http://127.0.0.1:%d", port);
109 curl_easy_setopt (curl, CURLOPT_URL, url); 123 curl_easy_setopt (curl, CURLOPT_URL, url);
110 curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data); 124 curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data);
111 125
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, &copyBuffer); 204 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
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, &copyBuffer); 278 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
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);
diff --git a/src/testcurl/test_urlparse.c b/src/testcurl/test_urlparse.c
index 9c1e64a8..980a46b2 100644
--- a/src/testcurl/test_urlparse.c
+++ b/src/testcurl/test_urlparse.c
@@ -130,16 +130,35 @@ testInternalGet (int poll_flag)
130 char buf[2048]; 130 char buf[2048];
131 struct CBC cbc; 131 struct CBC cbc;
132 CURLcode errornum; 132 CURLcode errornum;
133 int port;
134
135 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
136 port = 0;
137 else
138 {
139 port = 1510;
140 if (oneone)
141 port += 5;
142 }
133 143
134 cbc.buf = buf; 144 cbc.buf = buf;
135 cbc.size = 2048; 145 cbc.size = 2048;
136 cbc.pos = 0; 146 cbc.pos = 0;
137 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 147 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
138 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 148 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
139 if (d == NULL) 149 if (d == NULL)
140 return 1; 150 return 1;
151 if (0 == port)
152 {
153 const union MHD_DaemonInfo *dinfo;
154 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
155 if (NULL == dinfo || 0 == dinfo->port)
156 { MHD_stop_daemon (d); return 32; }
157 port = (int)dinfo->port;
158 }
141 c = curl_easy_init (); 159 c = curl_easy_init ();
142 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11080/hello_world?a=b&c=&d"); 160 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world?a=b&c=&d");
161 curl_easy_setopt (c, CURLOPT_PORT, (long)port);
143 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 162 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
144 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 163 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
145 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 164 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);