aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_post.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_post.c')
-rw-r--r--src/testcurl/test_post.c115
1 files changed, 105 insertions, 10 deletions
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);