146
144
apr_array_header_t *accepted_requests, *handled_requests, *sent_requests;
148
146
test_server_message_t message_list[] = {
149
{"GET / HTTP/1.1" CRLF
150
"Transfer-Encoding: chunked" CRLF
156
{"GET / HTTP/1.1" CRLF
157
"Transfer-Encoding: chunked" CRLF
147
{CHUNKED_REQUEST(1, "1")},
148
{CHUNKED_REQUEST(1, "2")},
165
151
test_server_action_t action_list[] = {
167
"HTTP/1.1 200 OK" CRLF
168
"Transfer-Encoding: chunked" CRLF
173
"HTTP/1.1 200 OK" CRLF
174
"Transfer-Encoding: chunked" CRLF
152
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
153
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
155
apr_pool_t *test_pool = test_setup();
180
157
accepted_requests = apr_array_make(test_pool, 2, sizeof(int));
181
158
sent_requests = apr_array_make(test_pool, 2, sizeof(int));
182
159
handled_requests = apr_array_make(test_pool, 2, sizeof(int));
184
161
/* Set up a test context with a server */
185
status = test_server_create(&tb,
187
action_list, 2, 0, NULL, NULL, NULL,
162
status = test_server_setup(&tb,
164
action_list, 2, 0, NULL,
189
166
CuAssertIntEquals(tc, APR_SUCCESS, status);
191
168
handler_ctx.method = "GET";
199
176
handler_ctx.accepted_requests = accepted_requests;
200
177
handler_ctx.sent_requests = sent_requests;
201
178
handler_ctx.handled_requests = handled_requests;
202
handler_ctx.use_proxy = FALSE;
203
handler_ctx.server_root = NULL;
205
180
request1 = serf_connection_request_create(tb->connection,
220
195
apr_pool_clear(iter_pool);
222
status = test_server_run(tb, 0, iter_pool);
197
status = test_server_run(tb->serv_ctx, 0, iter_pool);
223
198
if (APR_STATUS_IS_TIMEUP(status))
224
199
status = APR_SUCCESS;
225
200
CuAssertIntEquals(tc, APR_SUCCESS, status);
228
203
if (APR_STATUS_IS_TIMEUP(status))
229
204
status = APR_SUCCESS;
230
205
CuAssertIntEquals(tc, APR_SUCCESS, status);
232
/* Debugging purposes only! */
233
serf_debug__closed_conn(tb->bkt_alloc);
235
207
apr_pool_destroy(iter_pool);
251
223
CuAssertIntEquals(tc, i + 1, req_nr);
254
test_server_destroy(tb, test_pool);
226
test_server_teardown(tb, test_pool);
227
test_teardown(test_pool);
257
230
/* Validate that priority requests are sent and completed before normal
269
242
test_server_message_t message_list[] = {
270
{CHUNCKED_REQUEST(1, "1")},
271
{CHUNCKED_REQUEST(1, "2")},
272
{CHUNCKED_REQUEST(1, "3")},
243
{CHUNKED_REQUEST(1, "1")},
244
{CHUNKED_REQUEST(1, "2")},
245
{CHUNKED_REQUEST(1, "3")},
275
248
test_server_action_t action_list[] = {
278
251
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
254
apr_pool_t *test_pool = test_setup();
281
256
accepted_requests = apr_array_make(test_pool, 3, sizeof(int));
282
257
sent_requests = apr_array_make(test_pool, 3, sizeof(int));
283
258
handled_requests = apr_array_make(test_pool, 3, sizeof(int));
285
260
/* Set up a test context with a server */
286
status = test_server_create(&tb,
288
action_list, 3, 0, NULL, NULL, NULL,
261
status = test_server_setup(&tb,
263
action_list, 3, 0, NULL,
290
265
CuAssertIntEquals(tc, APR_SUCCESS, status);
292
267
handler_ctx.method = "GET";
300
275
handler_ctx.accepted_requests = accepted_requests;
301
276
handler_ctx.sent_requests = sent_requests;
302
277
handler_ctx.handled_requests = handled_requests;
303
handler_ctx.use_proxy = FALSE;
304
handler_ctx.server_root = NULL;
306
279
request1 = serf_connection_request_create(tb->connection,
327
300
apr_pool_clear(iter_pool);
329
status = test_server_run(tb, 0, iter_pool);
302
status = test_server_run(tb->serv_ctx, 0, iter_pool);
330
303
if (APR_STATUS_IS_TIMEUP(status))
331
304
status = APR_SUCCESS;
332
305
CuAssertIntEquals(tc, APR_SUCCESS, status);
358
331
CuAssertIntEquals(tc, i + 1, req_nr);
361
test_server_destroy(tb, test_pool);
334
test_server_teardown(tb, test_pool);
335
test_teardown(test_pool);
364
338
/* Test that serf correctly handles the 'Connection:close' header when the
373
347
int done = FALSE, i;
375
349
test_server_message_t message_list[] = {
376
{CHUNCKED_REQUEST(1, "1")},
377
{CHUNCKED_REQUEST(1, "2")},
378
{CHUNCKED_REQUEST(1, "3")},
379
{CHUNCKED_REQUEST(1, "4")},
380
{CHUNCKED_REQUEST(1, "5")},
381
{CHUNCKED_REQUEST(1, "6")},
382
{CHUNCKED_REQUEST(1, "7")},
383
{CHUNCKED_REQUEST(1, "8")},
384
{CHUNCKED_REQUEST(1, "9")},
385
{CHUNCKED_REQUEST(2, "10")}
350
{CHUNKED_REQUEST(1, "1")},
351
{CHUNKED_REQUEST(1, "2")},
352
{CHUNKED_REQUEST(1, "3")},
353
{CHUNKED_REQUEST(1, "4")},
354
{CHUNKED_REQUEST(1, "5")},
355
{CHUNKED_REQUEST(1, "6")},
356
{CHUNKED_REQUEST(1, "7")},
357
{CHUNKED_REQUEST(1, "8")},
358
{CHUNKED_REQUEST(1, "9")},
359
{CHUNKED_REQUEST(2, "10")}
388
362
test_server_action_t action_list[] = {
414
388
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
391
apr_pool_t *test_pool = test_setup();
417
393
accepted_requests = apr_array_make(test_pool, NUM_REQUESTS, sizeof(int));
418
394
sent_requests = apr_array_make(test_pool, NUM_REQUESTS, sizeof(int));
419
395
handled_requests = apr_array_make(test_pool, NUM_REQUESTS, sizeof(int));
421
397
/* Set up a test context with a server. */
422
status = test_server_create(&tb,
398
status = test_server_setup(&tb,
428
404
CuAssertIntEquals(tc, APR_SUCCESS, status);
430
406
for (i = 0 ; i < NUM_REQUESTS ; i++) {
441
417
handler_ctx[i].sent_requests = sent_requests;
442
418
handler_ctx[i].handled_requests = handled_requests;
443
419
handler_ctx[i].tb = tb;
444
handler_ctx[i].use_proxy = FALSE;
445
handler_ctx[i].server_root = NULL;
447
421
serf_connection_request_create(tb->connection,
453
status = test_server_run(tb, 0, test_pool);
427
status = test_server_run(tb->serv_ctx, 0, test_pool);
454
428
if (APR_STATUS_IS_TIMEUP(status))
455
429
status = APR_SUCCESS;
456
430
CuAssertIntEquals(tc, APR_SUCCESS, status);
479
453
CuAssertIntEquals(tc, NUM_REQUESTS, handled_requests->nelts);
482
test_server_destroy(tb, test_pool);
456
test_server_teardown(tb, test_pool);
457
test_teardown(test_pool);
484
459
#undef NUM_REQUESTS
512
487
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
490
apr_pool_t *test_pool = test_setup();
515
492
accepted_requests = apr_array_make(test_pool, numrequests, sizeof(int));
516
493
sent_requests = apr_array_make(test_pool, numrequests, sizeof(int));
517
494
handled_requests = apr_array_make(test_pool, numrequests, sizeof(int));
519
496
/* Set up a test context with a server, no messages expected. */
520
status = test_server_create(&tb_server,
523
"http://localhost:" SERV_PORT_STR, NULL,
525
CuAssertIntEquals(tc, APR_SUCCESS, status);
527
/* Set up another test context for the proxy server */
528
status = apr_sockaddr_info_get(&proxy_address,
529
"localhost", APR_INET, 21212, 0,
531
CuAssertIntEquals(tc, APR_SUCCESS, status);
533
status = test_server_create(&tb_proxy,
535
action_list_proxy, 1, 0,
536
NULL, proxy_address, NULL,
497
status = test_server_proxy_setup(&tb,
498
/* server messages and actions */
501
/* server messages and actions */
503
action_list_proxy, 1,
539
506
CuAssertIntEquals(tc, APR_SUCCESS, status);
541
508
handler_ctx.method = "GET";
549
516
handler_ctx.accepted_requests = accepted_requests;
550
517
handler_ctx.sent_requests = sent_requests;
551
518
handler_ctx.handled_requests = handled_requests;
552
handler_ctx.use_proxy = TRUE;
553
handler_ctx.server_root = "http://localhost:" SERV_PORT_STR;
555
/* Configure serf to use the proxy server */
556
serf_config_proxy(tb_server->context, proxy_address);
558
request = serf_connection_request_create(tb_server->connection,
520
request = serf_connection_request_create(tb->connection,
566
528
apr_pool_clear(iter_pool);
568
status = test_server_run(tb_server, 0, iter_pool);
569
if (APR_STATUS_IS_TIMEUP(status))
570
status = APR_SUCCESS;
571
CuAssertIntEquals(tc, APR_SUCCESS, status);
573
status = test_server_run(tb_proxy, 0, iter_pool);
574
if (APR_STATUS_IS_TIMEUP(status))
575
status = APR_SUCCESS;
576
CuAssertIntEquals(tc, APR_SUCCESS, status);
578
status = serf_context_run(tb_server->context, 0, iter_pool);
530
status = test_server_run(tb->serv_ctx, 0, iter_pool);
531
if (APR_STATUS_IS_TIMEUP(status))
532
status = APR_SUCCESS;
533
CuAssertIntEquals(tc, APR_SUCCESS, status);
535
status = test_server_run(tb->proxy_ctx, 0, iter_pool);
536
if (APR_STATUS_IS_TIMEUP(status))
537
status = APR_SUCCESS;
538
CuAssertIntEquals(tc, APR_SUCCESS, status);
540
status = serf_context_run(tb->context, 0, iter_pool);
579
541
if (APR_STATUS_IS_TIMEUP(status))
580
542
status = APR_SUCCESS;
581
543
CuAssertIntEquals(tc, APR_SUCCESS, status);
583
545
/* Debugging purposes only! */
584
serf_debug__closed_conn(tb_server->bkt_alloc);
546
serf_debug__closed_conn(tb->bkt_alloc);
586
548
apr_pool_destroy(iter_pool);
602
564
CuAssertIntEquals(tc, i + 1, req_nr);
605
test_server_destroy(tb_server, test_pool);
567
test_server_teardown(tb, test_pool);
568
test_teardown(test_pool);
608
571
/*****************************************************************************
661
624
int done = FALSE, i;
663
626
test_server_message_t message_list[] = {
664
{CHUNCKED_REQUEST(1, "1")},
665
{CHUNCKED_REQUEST(1, "1")},
666
{CHUNCKED_REQUEST(1, "1")},
667
{CHUNCKED_REQUEST(1, "2")},
668
{CHUNCKED_REQUEST(1, "3")},
669
{CHUNCKED_REQUEST(1, "4")},
670
{CHUNCKED_REQUEST(1, "5")},
627
{CHUNKED_REQUEST(1, "1")},
628
{CHUNKED_REQUEST(1, "1")},
629
{CHUNKED_REQUEST(1, "1")},
630
{CHUNKED_REQUEST(1, "2")},
631
{CHUNKED_REQUEST(1, "3")},
632
{CHUNKED_REQUEST(1, "4")},
633
{CHUNKED_REQUEST(1, "5")},
673
636
test_server_action_t action_list[] = {
680
643
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
646
apr_pool_t *test_pool = test_setup();
683
648
accepted_requests = apr_array_make(test_pool, RCVD_REQUESTS, sizeof(int));
684
649
sent_requests = apr_array_make(test_pool, RCVD_REQUESTS, sizeof(int));
685
650
handled_requests = apr_array_make(test_pool, RCVD_REQUESTS, sizeof(int));
687
652
/* Set up a test context with a server. */
688
status = test_server_create(&tb,
690
action_list, 7, 0, NULL, NULL, NULL,
653
status = test_server_setup(&tb,
655
action_list, 7, 0, NULL,
692
657
CuAssertIntEquals(tc, APR_SUCCESS, status);
694
659
for (i = 0 ; i < SEND_REQUESTS ; i++) {
705
670
handler_ctx[i].sent_requests = sent_requests;
706
671
handler_ctx[i].handled_requests = handled_requests;
707
672
handler_ctx[i].tb = tb;
708
handler_ctx[i].use_proxy = FALSE;
709
handler_ctx[i].server_root = NULL;
711
674
serf_connection_request_create(tb->connection,
718
status = test_server_run(tb, 0, test_pool);
681
status = test_server_run(tb->serv_ctx, 0, test_pool);
719
682
if (APR_STATUS_IS_TIMEUP(status))
720
683
status = APR_SUCCESS;
721
684
CuAssertIntEquals(tc, APR_SUCCESS, status);
744
707
CuAssertIntEquals(tc, RCVD_REQUESTS, handled_requests->nelts);
747
test_server_destroy(tb, test_pool);
710
test_server_teardown(tb, test_pool);
711
test_teardown(test_pool);
749
713
#undef SEND_REQUESTS
750
714
#undef RCVD_REQUESTS
814
778
int done = FALSE, i;
816
780
test_server_message_t message_list[] = {
817
{CHUNCKED_REQUEST(1, "1")},
818
{CHUNCKED_REQUEST(1, "1")},
819
{CHUNCKED_REQUEST(1, "1")},
820
{CHUNCKED_REQUEST(1, "2")},
821
{CHUNCKED_REQUEST(1, "3")},
822
{CHUNCKED_REQUEST(1, "4")},
823
{CHUNCKED_REQUEST(1, "5")},
781
{CHUNKED_REQUEST(1, "1")},
782
{CHUNKED_REQUEST(1, "1")},
783
{CHUNKED_REQUEST(1, "1")},
784
{CHUNKED_REQUEST(1, "2")},
785
{CHUNKED_REQUEST(1, "3")},
786
{CHUNKED_REQUEST(1, "4")},
787
{CHUNKED_REQUEST(1, "5")},
826
790
test_server_action_t action_list[] = {
833
797
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
800
apr_pool_t *test_pool = test_setup();
836
802
accepted_requests = apr_array_make(test_pool, RCVD_REQUESTS, sizeof(int));
837
803
sent_requests = apr_array_make(test_pool, RCVD_REQUESTS, sizeof(int));
838
804
handled_requests = apr_array_make(test_pool, RCVD_REQUESTS, sizeof(int));
840
806
/* Set up a test context with a server. */
841
status = test_server_create(&tb,
843
action_list, 7, 0, NULL, NULL, NULL,
807
status = test_server_setup(&tb,
809
action_list, 7, 0, NULL,
845
811
CuAssertIntEquals(tc, APR_SUCCESS, status);
847
813
for (i = 0 ; i < SEND_REQUESTS ; i++) {
858
824
handler_ctx[i].sent_requests = sent_requests;
859
825
handler_ctx[i].handled_requests = handled_requests;
860
826
handler_ctx[i].tb = tb;
861
handler_ctx[i].use_proxy = FALSE;
862
handler_ctx[i].server_root = NULL;
864
828
serf_connection_request_create(tb->connection,
871
status = test_server_run(tb, 0, test_pool);
835
status = test_server_run(tb->serv_ctx, 0, test_pool);
872
836
if (APR_STATUS_IS_TIMEUP(status))
873
837
status = APR_SUCCESS;
874
838
CuAssertIntEquals(tc, APR_SUCCESS, status);
897
861
CuAssertIntEquals(tc, RCVD_REQUESTS, handled_requests->nelts);
900
test_server_destroy(tb, test_pool);
864
test_server_teardown(tb, test_pool);
865
test_teardown(test_pool);
902
867
#undef SEND_REQUESTS
903
868
#undef RCVD_REQUESTS
939
904
progress_baton_t *pb;
941
906
test_server_message_t message_list[] = {
942
{CHUNCKED_REQUEST(1, "1")},
943
{CHUNCKED_REQUEST(1, "2")},
944
{CHUNCKED_REQUEST(1, "3")},
945
{CHUNCKED_REQUEST(1, "4")},
946
{CHUNCKED_REQUEST(1, "5")},
907
{CHUNKED_REQUEST(1, "1")},
908
{CHUNKED_REQUEST(1, "2")},
909
{CHUNKED_REQUEST(1, "3")},
910
{CHUNKED_REQUEST(1, "4")},
911
{CHUNKED_REQUEST(1, "5")},
949
914
test_server_action_t action_list[] = {
954
919
{SERVER_RESPOND, CHUNKED_EMPTY_RESPONSE},
922
apr_pool_t *test_pool = test_setup();
957
924
accepted_requests = apr_array_make(test_pool, NUM_REQUESTS, sizeof(int));
958
925
sent_requests = apr_array_make(test_pool, NUM_REQUESTS, sizeof(int));
959
926
handled_requests = apr_array_make(test_pool, NUM_REQUESTS, sizeof(int));
961
928
/* Set up a test context with a server. */
962
status = test_server_create(&tb,
964
action_list, 5, 0, NULL, NULL,
965
progress_conn_setup, test_pool);
929
status = test_server_setup(&tb,
932
progress_conn_setup, test_pool);
966
933
CuAssertIntEquals(tc, APR_SUCCESS, status);
968
935
/* Set up the progress callback. */
984
951
handler_ctx[i].sent_requests = sent_requests;
985
952
handler_ctx[i].handled_requests = handled_requests;
986
953
handler_ctx[i].tb = tb;
987
handler_ctx[i].use_proxy = FALSE;
988
handler_ctx[i].server_root = NULL;
990
955
serf_connection_request_create(tb->connection,
996
status = test_server_run(tb, 0, test_pool);
961
status = test_server_run(tb->serv_ctx, 0, test_pool);
997
962
if (APR_STATUS_IS_TIMEUP(status))
998
963
status = APR_SUCCESS;
999
964
CuAssertIntEquals(tc, APR_SUCCESS, status);
1026
991
CuAssertTrue(tc, pb->read > 0);
1029
test_server_destroy(tb, test_pool);
994
test_server_teardown(tb, test_pool);
995
test_teardown(test_pool);
1031
997
#undef NUM_REQUESTS