- Timestamp:
- Apr 27, 2010 8:31:08 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util-test/http_client.c
r3095 r3147 271 271 pj_http_req_callback hcb; 272 272 pj_http_req_param param; 273 char urlbuf[80]; 273 274 274 275 pj_bzero(&hcb, sizeof(hcb)); … … 287 288 #ifdef USE_LOCAL_SERVER 288 289 289 pj_cstr(&url, "http://127.0.0.1:8080/about-us/");290 290 thread_quit = PJ_FALSE; 291 291 g_server.action = ACTION_REPLY; 292 292 g_server.send_content_length = PJ_TRUE; 293 293 g_server.data_size = 2970; 294 g_server.port = 8080;295 294 g_server.buf_size = 1024; 296 295 … … 300 299 return -41; 301 300 302 pj_sockaddr_in_init(&addr, NULL, (pj_uint16_t)g_server.port);301 pj_sockaddr_in_init(&addr, NULL, 0); 303 302 304 303 sstatus = pj_sock_bind(g_server.sock, &addr, sizeof(addr)); 305 304 if (sstatus != PJ_SUCCESS) 306 305 return -43; 306 307 { 308 pj_sockaddr_in addr; 309 int addr_len = sizeof(addr); 310 sstatus = pj_sock_getsockname(g_server.sock, &addr, &addr_len); 311 if (sstatus != PJ_SUCCESS) 312 return -44; 313 g_server.port = pj_sockaddr_in_get_port(&addr); 314 pj_ansi_snprintf(urlbuf, sizeof(urlbuf), 315 "http://127.0.0.1:%d/about-us/", 316 g_server.port); 317 url = pj_str(urlbuf); 318 } 307 319 308 320 sstatus = pj_sock_listen(g_server.sock, 8); … … 367 379 pj_http_req_param param; 368 380 pj_time_val timeout; 381 char urlbuf[80]; 369 382 370 383 pj_bzero(&hcb, sizeof(hcb)); … … 390 403 g_server.send_content_length = PJ_FALSE; 391 404 g_server.data_size = 4173; 392 g_server.port = 380;393 405 g_server.buf_size = 1024; 394 406 … … 398 410 return -41; 399 411 400 pj_sockaddr_in_init(&addr, NULL, (pj_uint16_t)g_server.port);412 pj_sockaddr_in_init(&addr, NULL, 0); 401 413 402 414 sstatus = pj_sock_bind(g_server.sock, &addr, sizeof(addr)); 403 415 if (sstatus != PJ_SUCCESS) 404 416 return -43; 417 418 { 419 pj_sockaddr_in addr; 420 int addr_len = sizeof(addr); 421 sstatus = pj_sock_getsockname(g_server.sock, &addr, &addr_len); 422 if (sstatus != PJ_SUCCESS) 423 return -44; 424 g_server.port = pj_sockaddr_in_get_port(&addr); 425 pj_ansi_snprintf(urlbuf, sizeof(urlbuf), 426 "http://127.0.0.1:%d", 427 g_server.port); 428 url = pj_str(urlbuf); 429 } 405 430 406 431 sstatus = pj_sock_listen(g_server.sock, 8); … … 487 512 char *data; 488 513 int length = 3875; 514 char urlbuf[80]; 489 515 490 516 pj_bzero(&hcb, sizeof(hcb)); … … 501 527 502 528 #ifdef USE_LOCAL_SERVER 503 pj_cstr(&url, "http://127.0.0.1:380/test/test.txt");504 529 thread_quit = PJ_FALSE; 505 530 g_server.action = ACTION_REPLY; 506 531 g_server.send_content_length = PJ_TRUE; 507 532 g_server.data_size = 0; 508 g_server.port = 380;509 533 g_server.buf_size = 4096; 510 534 … … 514 538 return -41; 515 539 516 pj_sockaddr_in_init(&addr, NULL, (pj_uint16_t)g_server.port);540 pj_sockaddr_in_init(&addr, NULL, 0); 517 541 518 542 sstatus = pj_sock_bind(g_server.sock, &addr, sizeof(addr)); 519 543 if (sstatus != PJ_SUCCESS) 520 544 return -43; 545 546 { 547 pj_sockaddr_in addr; 548 int addr_len = sizeof(addr); 549 sstatus = pj_sock_getsockname(g_server.sock, &addr, &addr_len); 550 if (sstatus != PJ_SUCCESS) 551 return -44; 552 g_server.port = pj_sockaddr_in_get_port(&addr); 553 pj_ansi_snprintf(urlbuf, sizeof(urlbuf), 554 "http://127.0.0.1:%d/test/test.txt", 555 g_server.port); 556 url = pj_str(urlbuf); 557 } 521 558 522 559 sstatus = pj_sock_listen(g_server.sock, 8); … … 576 613 pj_http_req_callback hcb; 577 614 pj_http_req_param param; 615 char urlbuf[80]; 578 616 579 617 pj_bzero(&hcb, sizeof(hcb)); … … 591 629 592 630 #ifdef USE_LOCAL_SERVER 593 pj_cstr(&url, "http://127.0.0.1:380/test/test2.txt");594 631 thread_quit = PJ_FALSE; 595 632 g_server.action = ACTION_REPLY; 596 633 g_server.send_content_length = PJ_TRUE; 597 634 g_server.data_size = 0; 598 g_server.port = 380;599 635 g_server.buf_size = 16384; 600 636 … … 604 640 return -41; 605 641 606 pj_sockaddr_in_init(&addr, NULL, (pj_uint16_t)g_server.port);642 pj_sockaddr_in_init(&addr, NULL, 0); 607 643 608 644 sstatus = pj_sock_bind(g_server.sock, &addr, sizeof(addr)); 609 645 if (sstatus != PJ_SUCCESS) 610 646 return -43; 647 648 { 649 pj_sockaddr_in addr; 650 int addr_len = sizeof(addr); 651 sstatus = pj_sock_getsockname(g_server.sock, &addr, &addr_len); 652 if (sstatus != PJ_SUCCESS) 653 return -44; 654 g_server.port = pj_sockaddr_in_get_port(&addr); 655 pj_ansi_snprintf(urlbuf, sizeof(urlbuf), 656 "http://127.0.0.1:%d/test/test2.txt", 657 g_server.port); 658 url = pj_str(urlbuf); 659 } 611 660 612 661 sstatus = pj_sock_listen(g_server.sock, 8); … … 660 709 pj_http_req_callback hcb; 661 710 pj_http_req_param param; 711 char urlbuf[80]; 662 712 663 713 pj_bzero(&hcb, sizeof(hcb)); … … 673 723 674 724 #ifdef USE_LOCAL_SERVER 675 pj_cstr(&url, "http://127.0.0.1:380/test/test2.txt");676 725 thread_quit = PJ_FALSE; 677 726 g_server.action = ACTION_REPLY; 678 727 g_server.send_content_length = PJ_TRUE; 679 728 g_server.data_size = 0; 680 g_server.port = 380;681 729 g_server.buf_size = 1024; 682 730 … … 686 734 return -41; 687 735 688 pj_sockaddr_in_init(&addr, NULL, (pj_uint16_t)g_server.port);736 pj_sockaddr_in_init(&addr, NULL, 0); 689 737 690 738 sstatus = pj_sock_bind(g_server.sock, &addr, sizeof(addr)); 691 739 if (sstatus != PJ_SUCCESS) 692 740 return -43; 741 742 { 743 pj_sockaddr_in addr; 744 int addr_len = sizeof(addr); 745 sstatus = pj_sock_getsockname(g_server.sock, &addr, &addr_len); 746 if (sstatus != PJ_SUCCESS) 747 return -44; 748 g_server.port = pj_sockaddr_in_get_port(&addr); 749 pj_ansi_snprintf(urlbuf, sizeof(urlbuf), 750 "http://127.0.0.1:%d/test/test2.txt", 751 g_server.port); 752 url = pj_str(urlbuf); 753 } 693 754 694 755 sstatus = pj_sock_listen(g_server.sock, 8);
Note: See TracChangeset
for help on using the changeset viewer.