Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 113760: Revert "Temporarily landing my ClientSocketPool refactor. Will revert right after." (Closed)
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <math.h> // ceil 5 #include <math.h> // ceil
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "net/base/client_socket_factory.h" 8 #include "net/base/client_socket_factory.h"
9 #include "net/base/completion_callback.h" 9 #include "net/base/completion_callback.h"
10 #include "net/base/ssl_client_socket.h" 10 #include "net/base/ssl_client_socket.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return ProxyService::CreateNull(); 344 return ProxyService::CreateNull();
345 } 345 }
346 346
347 ProxyService* CreateFixedProxyService(const std::string& proxy) { 347 ProxyService* CreateFixedProxyService(const std::string& proxy) {
348 net::ProxyConfig proxy_config; 348 net::ProxyConfig proxy_config;
349 proxy_config.proxy_rules.ParseFromString(proxy); 349 proxy_config.proxy_rules.ParseFromString(proxy);
350 return ProxyService::Create(&proxy_config); 350 return ProxyService::Create(&proxy_config);
351 } 351 }
352 352
353 353
354 HttpNetworkSession* CreateSession(ProxyService* proxy_service, 354 HttpNetworkSession* CreateSession(ProxyService* proxy_service) {
355 ClientSocketFactory* client_socket_factory) { 355 return new HttpNetworkSession(proxy_service);
356 return new HttpNetworkSession(proxy_service, client_socket_factory);
357 } 356 }
358 357
359 class HttpNetworkTransactionTest : public PlatformTest { 358 class HttpNetworkTransactionTest : public PlatformTest {
360 public: 359 public:
361 virtual void SetUp() { 360 virtual void SetUp() {
362 PlatformTest::SetUp(); 361 PlatformTest::SetUp();
363 mock_sockets[0] = NULL; 362 mock_sockets[0] = NULL;
364 mock_sockets_index = 0; 363 mock_sockets_index = 0;
365 mock_ssl_sockets_index = 0; 364 mock_ssl_sockets_index = 0;
366 } 365 }
(...skipping 11 matching lines...) Expand all
378 struct SimpleGetHelperResult { 377 struct SimpleGetHelperResult {
379 int rv; 378 int rv;
380 std::string status_line; 379 std::string status_line;
381 std::string response_data; 380 std::string response_data;
382 }; 381 };
383 382
384 SimpleGetHelperResult SimpleGetHelper(MockRead data_reads[]) { 383 SimpleGetHelperResult SimpleGetHelper(MockRead data_reads[]) {
385 SimpleGetHelperResult out; 384 SimpleGetHelperResult out;
386 385
387 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 386 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
388 scoped_ptr<HttpTransaction> trans( 387 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
389 new HttpNetworkTransaction( 388 CreateSession(proxy_service.get()), &mock_socket_factory));
390 CreateSession(proxy_service.get(), &mock_socket_factory),
391 &mock_socket_factory));
392 389
393 HttpRequestInfo request; 390 HttpRequestInfo request;
394 request.method = "GET"; 391 request.method = "GET";
395 request.url = GURL("http://www.google.com/"); 392 request.url = GURL("http://www.google.com/");
396 request.load_flags = 0; 393 request.load_flags = 0;
397 394
398 MockSocket data; 395 MockSocket data;
399 data.reads = data_reads; 396 data.reads = data_reads;
400 mock_sockets[0] = &data; 397 mock_sockets[0] = &data;
401 mock_sockets[1] = NULL; 398 mock_sockets[1] = NULL;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 459 }
463 460
464 std::string MockGetHostName() { 461 std::string MockGetHostName() {
465 return "WTC-WIN7"; 462 return "WTC-WIN7";
466 } 463 }
467 464
468 //----------------------------------------------------------------------------- 465 //-----------------------------------------------------------------------------
469 466
470 TEST_F(HttpNetworkTransactionTest, Basic) { 467 TEST_F(HttpNetworkTransactionTest, Basic) {
471 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 468 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
472 scoped_ptr<HttpTransaction> trans( 469 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
473 new HttpNetworkTransaction( 470 CreateSession(proxy_service.get()), &mock_socket_factory));
474 CreateSession(proxy_service.get(), &mock_socket_factory),
475 &mock_socket_factory));
476 } 471 }
477 472
478 TEST_F(HttpNetworkTransactionTest, SimpleGET) { 473 TEST_F(HttpNetworkTransactionTest, SimpleGET) {
479 MockRead data_reads[] = { 474 MockRead data_reads[] = {
480 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 475 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
481 MockRead("hello world"), 476 MockRead("hello world"),
482 MockRead(false, OK), 477 MockRead(false, OK),
483 }; 478 };
484 SimpleGetHelperResult out = SimpleGetHelper(data_reads); 479 SimpleGetHelperResult out = SimpleGetHelper(data_reads);
485 EXPECT_EQ(OK, out.rv); 480 EXPECT_EQ(OK, out.rv);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 SimpleGetHelperResult out = SimpleGetHelper(data_reads); 570 SimpleGetHelperResult out = SimpleGetHelper(data_reads);
576 EXPECT_EQ(OK, out.rv); 571 EXPECT_EQ(OK, out.rv);
577 EXPECT_EQ("HTTP/1.1 204 No Content", out.status_line); 572 EXPECT_EQ("HTTP/1.1 204 No Content", out.status_line);
578 EXPECT_EQ("", out.response_data); 573 EXPECT_EQ("", out.response_data);
579 } 574 }
580 575
581 // Do a request using the HEAD method. Verify that we don't try to read the 576 // Do a request using the HEAD method. Verify that we don't try to read the
582 // message body (since HEAD has none). 577 // message body (since HEAD has none).
583 TEST_F(HttpNetworkTransactionTest, Head) { 578 TEST_F(HttpNetworkTransactionTest, Head) {
584 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 579 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
585 scoped_ptr<HttpTransaction> trans( 580 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
586 new HttpNetworkTransaction( 581 CreateSession(proxy_service.get()), &mock_socket_factory));
587 CreateSession(proxy_service.get(), &mock_socket_factory),
588 &mock_socket_factory));
589 582
590 HttpRequestInfo request; 583 HttpRequestInfo request;
591 request.method = "HEAD"; 584 request.method = "HEAD";
592 request.url = GURL("http://www.google.com/"); 585 request.url = GURL("http://www.google.com/");
593 request.load_flags = 0; 586 request.load_flags = 0;
594 587
595 MockWrite data_writes1[] = { 588 MockWrite data_writes1[] = {
596 MockWrite("HEAD / HTTP/1.1\r\n" 589 MockWrite("HEAD / HTTP/1.1\r\n"
597 "Host: www.google.com\r\n" 590 "Host: www.google.com\r\n"
598 "Connection: keep-alive\r\n" 591 "Connection: keep-alive\r\n"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // (despite non-zero content-length). 633 // (despite non-zero content-length).
641 std::string response_data; 634 std::string response_data;
642 rv = ReadTransaction(trans.get(), &response_data); 635 rv = ReadTransaction(trans.get(), &response_data);
643 EXPECT_EQ(OK, rv); 636 EXPECT_EQ(OK, rv);
644 EXPECT_EQ("", response_data); 637 EXPECT_EQ("", response_data);
645 } 638 }
646 639
647 TEST_F(HttpNetworkTransactionTest, ReuseConnection) { 640 TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
648 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 641 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
649 scoped_refptr<HttpNetworkSession> session = 642 scoped_refptr<HttpNetworkSession> session =
650 CreateSession(proxy_service.get(), &mock_socket_factory); 643 CreateSession(proxy_service.get());
651 644
652 MockRead data_reads[] = { 645 MockRead data_reads[] = {
653 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 646 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
654 MockRead("hello"), 647 MockRead("hello"),
655 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 648 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
656 MockRead("world"), 649 MockRead("world"),
657 MockRead(false, OK), 650 MockRead(false, OK),
658 }; 651 };
659 MockSocket data; 652 MockSocket data;
660 data.reads = data_reads; 653 data.reads = data_reads;
(...skipping 29 matching lines...) Expand all
690 683
691 std::string response_data; 684 std::string response_data;
692 rv = ReadTransaction(trans.get(), &response_data); 685 rv = ReadTransaction(trans.get(), &response_data);
693 EXPECT_EQ(OK, rv); 686 EXPECT_EQ(OK, rv);
694 EXPECT_EQ(kExpectedResponseData[i], response_data); 687 EXPECT_EQ(kExpectedResponseData[i], response_data);
695 } 688 }
696 } 689 }
697 690
698 TEST_F(HttpNetworkTransactionTest, Ignores100) { 691 TEST_F(HttpNetworkTransactionTest, Ignores100) {
699 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 692 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
700 scoped_ptr<HttpTransaction> trans( 693 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
701 new HttpNetworkTransaction( 694 CreateSession(proxy_service.get()), &mock_socket_factory));
702 CreateSession(proxy_service.get(), &mock_socket_factory),
703 &mock_socket_factory));
704 695
705 HttpRequestInfo request; 696 HttpRequestInfo request;
706 request.method = "POST"; 697 request.method = "POST";
707 request.url = GURL("http://www.foo.com/"); 698 request.url = GURL("http://www.foo.com/");
708 request.upload_data = new UploadData; 699 request.upload_data = new UploadData;
709 request.upload_data->AppendBytes("foo", 3); 700 request.upload_data->AppendBytes("foo", 3);
710 request.load_flags = 0; 701 request.load_flags = 0;
711 702
712 MockRead data_reads[] = { 703 MockRead data_reads[] = {
713 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), 704 MockRead("HTTP/1.0 100 Continue\r\n\r\n"),
(...skipping 24 matching lines...) Expand all
738 rv = ReadTransaction(trans.get(), &response_data); 729 rv = ReadTransaction(trans.get(), &response_data);
739 EXPECT_EQ(OK, rv); 730 EXPECT_EQ(OK, rv);
740 EXPECT_EQ("hello world", response_data); 731 EXPECT_EQ("hello world", response_data);
741 } 732 }
742 733
743 // This test is almost the same as Ignores100 above, but the response contains 734 // This test is almost the same as Ignores100 above, but the response contains
744 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is 735 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is
745 // HTTP/1.1. 736 // HTTP/1.1.
746 TEST_F(HttpNetworkTransactionTest, Ignores1xx) { 737 TEST_F(HttpNetworkTransactionTest, Ignores1xx) {
747 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 738 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
748 scoped_ptr<HttpTransaction> trans( 739 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
749 new HttpNetworkTransaction( 740 CreateSession(proxy_service.get()), &mock_socket_factory));
750 CreateSession(proxy_service.get(), &mock_socket_factory),
751 &mock_socket_factory));
752 741
753 HttpRequestInfo request; 742 HttpRequestInfo request;
754 request.method = "GET"; 743 request.method = "GET";
755 request.url = GURL("http://www.foo.com/"); 744 request.url = GURL("http://www.foo.com/");
756 request.load_flags = 0; 745 request.load_flags = 0;
757 746
758 MockRead data_reads[] = { 747 MockRead data_reads[] = {
759 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"), 748 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"),
760 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 749 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
761 MockRead("hello world"), 750 MockRead("hello world"),
(...skipping 23 matching lines...) Expand all
785 EXPECT_EQ(OK, rv); 774 EXPECT_EQ(OK, rv);
786 EXPECT_EQ("hello world", response_data); 775 EXPECT_EQ("hello world", response_data);
787 } 776 }
788 777
789 // read_failure specifies a read failure that should cause the network 778 // read_failure specifies a read failure that should cause the network
790 // transaction to resend the request. 779 // transaction to resend the request.
791 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( 780 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest(
792 const MockRead& read_failure) { 781 const MockRead& read_failure) {
793 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 782 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
794 scoped_refptr<HttpNetworkSession> session = 783 scoped_refptr<HttpNetworkSession> session =
795 CreateSession(proxy_service.get(), &mock_socket_factory); 784 CreateSession(proxy_service.get());
796 785
797 HttpRequestInfo request; 786 HttpRequestInfo request;
798 request.method = "GET"; 787 request.method = "GET";
799 request.url = GURL("http://www.foo.com/"); 788 request.url = GURL("http://www.foo.com/");
800 request.load_flags = 0; 789 request.load_flags = 0;
801 790
802 MockRead data1_reads[] = { 791 MockRead data1_reads[] = {
803 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 792 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
804 MockRead("hello"), 793 MockRead("hello"),
805 read_failure, // Now, we reuse the connection and fail the first read. 794 read_failure, // Now, we reuse the connection and fail the first read.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 KeepAliveConnectionResendRequestTest(read_failure); 840 KeepAliveConnectionResendRequestTest(read_failure);
852 } 841 }
853 842
854 TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) { 843 TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) {
855 MockRead read_failure(false, OK); // EOF 844 MockRead read_failure(false, OK); // EOF
856 KeepAliveConnectionResendRequestTest(read_failure); 845 KeepAliveConnectionResendRequestTest(read_failure);
857 } 846 }
858 847
859 TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) { 848 TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) {
860 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 849 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
861 scoped_ptr<HttpTransaction> trans( 850 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
862 new HttpNetworkTransaction( 851 CreateSession(proxy_service.get()), &mock_socket_factory));
863 CreateSession(proxy_service.get(), &mock_socket_factory),
864 &mock_socket_factory));
865 852
866 HttpRequestInfo request; 853 HttpRequestInfo request;
867 request.method = "GET"; 854 request.method = "GET";
868 request.url = GURL("http://www.google.com/"); 855 request.url = GURL("http://www.google.com/");
869 request.load_flags = 0; 856 request.load_flags = 0;
870 857
871 MockRead data_reads[] = { 858 MockRead data_reads[] = {
872 MockRead(true, ERR_CONNECTION_RESET), 859 MockRead(true, ERR_CONNECTION_RESET),
873 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used 860 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used
874 MockRead("hello world"), 861 MockRead("hello world"),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 MockRead(false, OK), 895 MockRead(false, OK),
909 }; 896 };
910 SimpleGetHelperResult out = SimpleGetHelper(data_reads); 897 SimpleGetHelperResult out = SimpleGetHelper(data_reads);
911 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv); 898 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv);
912 } 899 }
913 900
914 // Test the request-challenge-retry sequence for basic auth. 901 // Test the request-challenge-retry sequence for basic auth.
915 // (basic auth is the easiest to mock, because it has no randomness). 902 // (basic auth is the easiest to mock, because it has no randomness).
916 TEST_F(HttpNetworkTransactionTest, BasicAuth) { 903 TEST_F(HttpNetworkTransactionTest, BasicAuth) {
917 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 904 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
918 scoped_ptr<HttpTransaction> trans( 905 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
919 new HttpNetworkTransaction( 906 CreateSession(proxy_service.get()), &mock_socket_factory));
920 CreateSession(proxy_service.get(), &mock_socket_factory),
921 &mock_socket_factory));
922 907
923 HttpRequestInfo request; 908 HttpRequestInfo request;
924 request.method = "GET"; 909 request.method = "GET";
925 request.url = GURL("http://www.google.com/"); 910 request.url = GURL("http://www.google.com/");
926 request.load_flags = 0; 911 request.load_flags = 0;
927 912
928 MockWrite data_writes1[] = { 913 MockWrite data_writes1[] = {
929 MockWrite("GET / HTTP/1.1\r\n" 914 MockWrite("GET / HTTP/1.1\r\n"
930 "Host: www.google.com\r\n" 915 "Host: www.google.com\r\n"
931 "Connection: keep-alive\r\n\r\n"), 916 "Connection: keep-alive\r\n\r\n"),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 response = trans->GetResponseInfo(); 985 response = trans->GetResponseInfo();
1001 EXPECT_FALSE(response == NULL); 986 EXPECT_FALSE(response == NULL);
1002 EXPECT_TRUE(response->auth_challenge.get() == NULL); 987 EXPECT_TRUE(response->auth_challenge.get() == NULL);
1003 EXPECT_EQ(100, response->headers->GetContentLength()); 988 EXPECT_EQ(100, response->headers->GetContentLength());
1004 } 989 }
1005 990
1006 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 991 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
1007 // connection. 992 // connection.
1008 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) { 993 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) {
1009 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 994 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
1010 scoped_ptr<HttpTransaction> trans( 995 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1011 new HttpNetworkTransaction( 996 CreateSession(proxy_service.get()), &mock_socket_factory));
1012 CreateSession(proxy_service.get(), &mock_socket_factory),
1013 &mock_socket_factory));
1014 997
1015 HttpRequestInfo request; 998 HttpRequestInfo request;
1016 request.method = "GET"; 999 request.method = "GET";
1017 request.url = GURL("http://www.google.com/"); 1000 request.url = GURL("http://www.google.com/");
1018 request.load_flags = 0; 1001 request.load_flags = 0;
1019 1002
1020 MockWrite data_writes1[] = { 1003 MockWrite data_writes1[] = {
1021 MockWrite("GET / HTTP/1.1\r\n" 1004 MockWrite("GET / HTTP/1.1\r\n"
1022 "Host: www.google.com\r\n" 1005 "Host: www.google.com\r\n"
1023 "Connection: keep-alive\r\n\r\n"), 1006 "Connection: keep-alive\r\n\r\n"),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 response = trans->GetResponseInfo(); 1062 response = trans->GetResponseInfo();
1080 EXPECT_FALSE(response == NULL); 1063 EXPECT_FALSE(response == NULL);
1081 EXPECT_TRUE(response->auth_challenge.get() == NULL); 1064 EXPECT_TRUE(response->auth_challenge.get() == NULL);
1082 EXPECT_EQ(100, response->headers->GetContentLength()); 1065 EXPECT_EQ(100, response->headers->GetContentLength());
1083 } 1066 }
1084 1067
1085 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 1068 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
1086 // connection and with no response body to drain. 1069 // connection and with no response body to drain.
1087 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { 1070 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) {
1088 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 1071 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
1089 scoped_ptr<HttpTransaction> trans( 1072 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1090 new HttpNetworkTransaction( 1073 CreateSession(proxy_service.get()), &mock_socket_factory));
1091 CreateSession(proxy_service.get(), &mock_socket_factory),
1092 &mock_socket_factory));
1093 1074
1094 HttpRequestInfo request; 1075 HttpRequestInfo request;
1095 request.method = "GET"; 1076 request.method = "GET";
1096 request.url = GURL("http://www.google.com/"); 1077 request.url = GURL("http://www.google.com/");
1097 request.load_flags = 0; 1078 request.load_flags = 0;
1098 1079
1099 MockWrite data_writes1[] = { 1080 MockWrite data_writes1[] = {
1100 MockWrite("GET / HTTP/1.1\r\n" 1081 MockWrite("GET / HTTP/1.1\r\n"
1101 "Host: www.google.com\r\n" 1082 "Host: www.google.com\r\n"
1102 "Connection: keep-alive\r\n\r\n"), 1083 "Connection: keep-alive\r\n\r\n"),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 response = trans->GetResponseInfo(); 1142 response = trans->GetResponseInfo();
1162 EXPECT_FALSE(response == NULL); 1143 EXPECT_FALSE(response == NULL);
1163 EXPECT_TRUE(response->auth_challenge.get() == NULL); 1144 EXPECT_TRUE(response->auth_challenge.get() == NULL);
1164 EXPECT_EQ(100, response->headers->GetContentLength()); 1145 EXPECT_EQ(100, response->headers->GetContentLength());
1165 } 1146 }
1166 1147
1167 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 1148 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
1168 // connection and with a large response body to drain. 1149 // connection and with a large response body to drain.
1169 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { 1150 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) {
1170 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 1151 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
1171 scoped_ptr<HttpTransaction> trans( 1152 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1172 new HttpNetworkTransaction( 1153 CreateSession(proxy_service.get()), &mock_socket_factory));
1173 CreateSession(proxy_service.get(), &mock_socket_factory),
1174 &mock_socket_factory));
1175 1154
1176 HttpRequestInfo request; 1155 HttpRequestInfo request;
1177 request.method = "GET"; 1156 request.method = "GET";
1178 request.url = GURL("http://www.google.com/"); 1157 request.url = GURL("http://www.google.com/");
1179 request.load_flags = 0; 1158 request.load_flags = 0;
1180 1159
1181 MockWrite data_writes1[] = { 1160 MockWrite data_writes1[] = {
1182 MockWrite("GET / HTTP/1.1\r\n" 1161 MockWrite("GET / HTTP/1.1\r\n"
1183 "Host: www.google.com\r\n" 1162 "Host: www.google.com\r\n"
1184 "Connection: keep-alive\r\n\r\n"), 1163 "Connection: keep-alive\r\n\r\n"),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 } 1229 }
1251 1230
1252 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 1231 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
1253 // proxy connection, when setting up an SSL tunnel. 1232 // proxy connection, when setting up an SSL tunnel.
1254 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) { 1233 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) {
1255 // Configure against proxy server "myproxy:70". 1234 // Configure against proxy server "myproxy:70".
1256 scoped_ptr<ProxyService> proxy_service( 1235 scoped_ptr<ProxyService> proxy_service(
1257 CreateFixedProxyService("myproxy:70")); 1236 CreateFixedProxyService("myproxy:70"));
1258 1237
1259 scoped_refptr<HttpNetworkSession> session( 1238 scoped_refptr<HttpNetworkSession> session(
1260 CreateSession(proxy_service.get(), &mock_socket_factory)); 1239 CreateSession(proxy_service.get()));
1261 1240
1262 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 1241 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1263 session.get(), &mock_socket_factory)); 1242 session.get(), &mock_socket_factory));
1264 1243
1265 HttpRequestInfo request; 1244 HttpRequestInfo request;
1266 request.method = "GET"; 1245 request.method = "GET";
1267 request.url = GURL("https://www.google.com/"); 1246 request.url = GURL("https://www.google.com/");
1268 request.load_flags = 0; 1247 request.load_flags = 0;
1269 1248
1270 // Since we have proxy, should try to establish tunnel. 1249 // Since we have proxy, should try to establish tunnel.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 } 1330 }
1352 1331
1353 // Test that we don't read the response body when we fail to establish a tunnel, 1332 // Test that we don't read the response body when we fail to establish a tunnel,
1354 // even if the user cancels the proxy's auth attempt. 1333 // even if the user cancels the proxy's auth attempt.
1355 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { 1334 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) {
1356 // Configure against proxy server "myproxy:70". 1335 // Configure against proxy server "myproxy:70".
1357 scoped_ptr<ProxyService> proxy_service( 1336 scoped_ptr<ProxyService> proxy_service(
1358 CreateFixedProxyService("myproxy:70")); 1337 CreateFixedProxyService("myproxy:70"));
1359 1338
1360 scoped_refptr<HttpNetworkSession> session( 1339 scoped_refptr<HttpNetworkSession> session(
1361 CreateSession(proxy_service.get(), &mock_socket_factory)); 1340 CreateSession(proxy_service.get()));
1362 1341
1363 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 1342 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1364 session.get(), &mock_socket_factory)); 1343 session.get(), &mock_socket_factory));
1365 1344
1366 HttpRequestInfo request; 1345 HttpRequestInfo request;
1367 request.method = "GET"; 1346 request.method = "GET";
1368 request.url = GURL("https://www.google.com/"); 1347 request.url = GURL("https://www.google.com/");
1369 request.load_flags = 0; 1348 request.load_flags = 0;
1370 1349
1371 // Since we have proxy, should try to establish tunnel. 1350 // Since we have proxy, should try to establish tunnel.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 1388 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
1410 } 1389 }
1411 1390
1412 static void ConnectStatusHelperWithExpectedStatus( 1391 static void ConnectStatusHelperWithExpectedStatus(
1413 const MockRead& status, int expected_status) { 1392 const MockRead& status, int expected_status) {
1414 // Configure against proxy server "myproxy:70". 1393 // Configure against proxy server "myproxy:70".
1415 scoped_ptr<ProxyService> proxy_service( 1394 scoped_ptr<ProxyService> proxy_service(
1416 CreateFixedProxyService("myproxy:70")); 1395 CreateFixedProxyService("myproxy:70"));
1417 1396
1418 scoped_refptr<HttpNetworkSession> session( 1397 scoped_refptr<HttpNetworkSession> session(
1419 CreateSession(proxy_service.get(), &mock_socket_factory)); 1398 CreateSession(proxy_service.get()));
1420 1399
1421 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 1400 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1422 session.get(), &mock_socket_factory)); 1401 session.get(), &mock_socket_factory));
1423 1402
1424 HttpRequestInfo request; 1403 HttpRequestInfo request;
1425 request.method = "GET"; 1404 request.method = "GET";
1426 request.url = GURL("https://www.google.com/"); 1405 request.url = GURL("https://www.google.com/");
1427 request.load_flags = 0; 1406 request.load_flags = 0;
1428 1407
1429 // Since we have proxy, should try to establish tunnel. 1408 // Since we have proxy, should try to establish tunnel.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 1604
1626 // Test the flow when both the proxy server AND origin server require 1605 // Test the flow when both the proxy server AND origin server require
1627 // authentication. Again, this uses basic auth for both since that is 1606 // authentication. Again, this uses basic auth for both since that is
1628 // the simplest to mock. 1607 // the simplest to mock.
1629 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { 1608 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) {
1630 scoped_ptr<ProxyService> proxy_service( 1609 scoped_ptr<ProxyService> proxy_service(
1631 CreateFixedProxyService("myproxy:70")); 1610 CreateFixedProxyService("myproxy:70"));
1632 1611
1633 // Configure against proxy server "myproxy:70". 1612 // Configure against proxy server "myproxy:70".
1634 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 1613 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1635 CreateSession(proxy_service.get(), &mock_socket_factory), 1614 CreateSession(proxy_service.get()),
1636 &mock_socket_factory)); 1615 &mock_socket_factory));
1637 1616
1638 HttpRequestInfo request; 1617 HttpRequestInfo request;
1639 request.method = "GET"; 1618 request.method = "GET";
1640 request.url = GURL("http://www.google.com/"); 1619 request.url = GURL("http://www.google.com/");
1641 request.load_flags = 0; 1620 request.load_flags = 0;
1642 1621
1643 MockWrite data_writes1[] = { 1622 MockWrite data_writes1[] = {
1644 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" 1623 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n"
1645 "Host: www.google.com\r\n" 1624 "Host: www.google.com\r\n"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 // The NTLM authentication unit tests were generated by capturing the HTTP 1742 // The NTLM authentication unit tests were generated by capturing the HTTP
1764 // requests and responses using Fiddler 2 and inspecting the generated random 1743 // requests and responses using Fiddler 2 and inspecting the generated random
1765 // bytes in the debugger. 1744 // bytes in the debugger.
1766 1745
1767 // Enter the correct password and authenticate successfully. 1746 // Enter the correct password and authenticate successfully.
1768 TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { 1747 TEST_F(HttpNetworkTransactionTest, NTLMAuth1) {
1769 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1, 1748 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1,
1770 MockGetHostName); 1749 MockGetHostName);
1771 1750
1772 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 1751 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
1773 scoped_ptr<HttpTransaction> trans( 1752 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1774 new HttpNetworkTransaction( 1753 CreateSession(proxy_service.get()), &mock_socket_factory));
1775 CreateSession(proxy_service.get(), &mock_socket_factory),
1776 &mock_socket_factory));
1777 1754
1778 HttpRequestInfo request; 1755 HttpRequestInfo request;
1779 request.method = "GET"; 1756 request.method = "GET";
1780 request.url = GURL("http://172.22.68.17/kids/login.aspx"); 1757 request.url = GURL("http://172.22.68.17/kids/login.aspx");
1781 request.load_flags = 0; 1758 request.load_flags = 0;
1782 1759
1783 MockWrite data_writes1[] = { 1760 MockWrite data_writes1[] = {
1784 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" 1761 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n"
1785 "Host: 172.22.68.17\r\n" 1762 "Host: 172.22.68.17\r\n"
1786 "Connection: keep-alive\r\n\r\n"), 1763 "Connection: keep-alive\r\n\r\n"),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 EXPECT_TRUE(response->auth_challenge.get() == NULL); 1869 EXPECT_TRUE(response->auth_challenge.get() == NULL);
1893 EXPECT_EQ(13, response->headers->GetContentLength()); 1870 EXPECT_EQ(13, response->headers->GetContentLength());
1894 } 1871 }
1895 1872
1896 // Enter a wrong password, and then the correct one. 1873 // Enter a wrong password, and then the correct one.
1897 TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { 1874 TEST_F(HttpNetworkTransactionTest, NTLMAuth2) {
1898 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, 1875 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2,
1899 MockGetHostName); 1876 MockGetHostName);
1900 1877
1901 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 1878 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
1902 scoped_ptr<HttpTransaction> trans( 1879 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
1903 new HttpNetworkTransaction( 1880 CreateSession(proxy_service.get()), &mock_socket_factory));
1904 CreateSession(proxy_service.get(), &mock_socket_factory),
1905 &mock_socket_factory));
1906 1881
1907 HttpRequestInfo request; 1882 HttpRequestInfo request;
1908 request.method = "GET"; 1883 request.method = "GET";
1909 request.url = GURL("http://172.22.68.17/kids/login.aspx"); 1884 request.url = GURL("http://172.22.68.17/kids/login.aspx");
1910 request.load_flags = 0; 1885 request.load_flags = 0;
1911 1886
1912 MockWrite data_writes1[] = { 1887 MockWrite data_writes1[] = {
1913 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" 1888 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n"
1914 "Host: 172.22.68.17\r\n" 1889 "Host: 172.22.68.17\r\n"
1915 "Connection: keep-alive\r\n\r\n"), 1890 "Connection: keep-alive\r\n\r\n"),
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 response = trans->GetResponseInfo(); 2076 response = trans->GetResponseInfo();
2102 EXPECT_TRUE(response->auth_challenge.get() == NULL); 2077 EXPECT_TRUE(response->auth_challenge.get() == NULL);
2103 EXPECT_EQ(13, response->headers->GetContentLength()); 2078 EXPECT_EQ(13, response->headers->GetContentLength());
2104 } 2079 }
2105 2080
2106 // Test reading a server response which has only headers, and no body. 2081 // Test reading a server response which has only headers, and no body.
2107 // After some maximum number of bytes is consumed, the transaction should 2082 // After some maximum number of bytes is consumed, the transaction should
2108 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. 2083 // fail with ERR_RESPONSE_HEADERS_TOO_BIG.
2109 TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) { 2084 TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) {
2110 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2085 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2111 scoped_ptr<HttpTransaction> trans( 2086 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
2112 new HttpNetworkTransaction( 2087 CreateSession(proxy_service.get()), &mock_socket_factory));
2113 CreateSession(proxy_service.get(), &mock_socket_factory),
2114 &mock_socket_factory));
2115 2088
2116 HttpRequestInfo request; 2089 HttpRequestInfo request;
2117 request.method = "GET"; 2090 request.method = "GET";
2118 request.url = GURL("http://www.google.com/"); 2091 request.url = GURL("http://www.google.com/");
2119 request.load_flags = 0; 2092 request.load_flags = 0;
2120 2093
2121 // Respond with 50 kb of headers (we should fail after 32 kb). 2094 // Respond with 50 kb of headers (we should fail after 32 kb).
2122 std::string large_headers_string; 2095 std::string large_headers_string;
2123 FillLargeHeadersString(&large_headers_string, 50 * 1024); 2096 FillLargeHeadersString(&large_headers_string, 50 * 1024);
2124 2097
(...skipping 22 matching lines...) Expand all
2147 2120
2148 // Make sure that we don't try to reuse a TCPClientSocket when failing to 2121 // Make sure that we don't try to reuse a TCPClientSocket when failing to
2149 // establish tunnel. 2122 // establish tunnel.
2150 // http://code.google.com/p/chromium/issues/detail?id=3772 2123 // http://code.google.com/p/chromium/issues/detail?id=3772
2151 TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) { 2124 TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) {
2152 // Configure against proxy server "myproxy:70". 2125 // Configure against proxy server "myproxy:70".
2153 scoped_ptr<ProxyService> proxy_service( 2126 scoped_ptr<ProxyService> proxy_service(
2154 CreateFixedProxyService("myproxy:70")); 2127 CreateFixedProxyService("myproxy:70"));
2155 2128
2156 scoped_refptr<HttpNetworkSession> session( 2129 scoped_refptr<HttpNetworkSession> session(
2157 CreateSession(proxy_service.get(), &mock_socket_factory)); 2130 CreateSession(proxy_service.get()));
2158 2131
2159 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 2132 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
2160 session.get(), &mock_socket_factory)); 2133 session.get(), &mock_socket_factory));
2161 2134
2162 HttpRequestInfo request; 2135 HttpRequestInfo request;
2163 request.method = "GET"; 2136 request.method = "GET";
2164 request.url = GURL("https://www.google.com/"); 2137 request.url = GURL("https://www.google.com/");
2165 request.load_flags = 0; 2138 request.load_flags = 0;
2166 2139
2167 // Since we have proxy, should try to establish tunnel. 2140 // Since we have proxy, should try to establish tunnel.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 trans.reset(); 2179 trans.reset();
2207 MessageLoop::current()->RunAllPending(); 2180 MessageLoop::current()->RunAllPending();
2208 // Make sure that the socket didn't get recycled after calling the destructor. 2181 // Make sure that the socket didn't get recycled after calling the destructor.
2209 EXPECT_EQ(0, session->connection_pool()->idle_socket_count()); 2182 EXPECT_EQ(0, session->connection_pool()->idle_socket_count());
2210 } 2183 }
2211 2184
2212 // Make sure that we recycle a socket after reading all of the response body. 2185 // Make sure that we recycle a socket after reading all of the response body.
2213 TEST_F(HttpNetworkTransactionTest, RecycleSocket) { 2186 TEST_F(HttpNetworkTransactionTest, RecycleSocket) {
2214 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2187 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2215 scoped_refptr<HttpNetworkSession> session( 2188 scoped_refptr<HttpNetworkSession> session(
2216 CreateSession(proxy_service.get(), &mock_socket_factory)); 2189 CreateSession(proxy_service.get()));
2217 2190
2218 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 2191 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
2219 session.get(), &mock_socket_factory)); 2192 session.get(), &mock_socket_factory));
2220 2193
2221 HttpRequestInfo request; 2194 HttpRequestInfo request;
2222 request.method = "GET"; 2195 request.method = "GET";
2223 request.url = GURL("http://www.google.com/"); 2196 request.url = GURL("http://www.google.com/");
2224 request.load_flags = 0; 2197 request.load_flags = 0;
2225 2198
2226 MockRead data_reads[] = { 2199 MockRead data_reads[] = {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 2239
2267 // We now check to make sure the socket was added back to the pool. 2240 // We now check to make sure the socket was added back to the pool.
2268 EXPECT_EQ(1, session->connection_pool()->idle_socket_count()); 2241 EXPECT_EQ(1, session->connection_pool()->idle_socket_count());
2269 } 2242 }
2270 2243
2271 // Make sure that we recycle a socket after a zero-length response. 2244 // Make sure that we recycle a socket after a zero-length response.
2272 // http://crbug.com/9880 2245 // http://crbug.com/9880
2273 TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { 2246 TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) {
2274 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2247 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2275 scoped_refptr<HttpNetworkSession> session( 2248 scoped_refptr<HttpNetworkSession> session(
2276 CreateSession(proxy_service.get(), &mock_socket_factory)); 2249 CreateSession(proxy_service.get()));
2277 2250
2278 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 2251 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
2279 session.get(), &mock_socket_factory)); 2252 session.get(), &mock_socket_factory));
2280 2253
2281 HttpRequestInfo request; 2254 HttpRequestInfo request;
2282 request.method = "GET"; 2255 request.method = "GET";
2283 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" 2256 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&"
2284 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" 2257 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&"
2285 "e=17259,18167,19592,19773,19981,20133,20173,20233&" 2258 "e=17259,18167,19592,19773,19981,20133,20173,20233&"
2286 "rt=prt.2642,ol.2649,xjs.2951"); 2259 "rt=prt.2642,ol.2649,xjs.2951");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 // This causes the transaction to retry with a new socket. The second 2314 // This causes the transaction to retry with a new socket. The second
2342 // attempt succeeds. 2315 // attempt succeeds.
2343 request[1].method = "POST"; 2316 request[1].method = "POST";
2344 request[1].url = GURL("http://www.google.com/login.cgi"); 2317 request[1].url = GURL("http://www.google.com/login.cgi");
2345 request[1].upload_data = new UploadData; 2318 request[1].upload_data = new UploadData;
2346 request[1].upload_data->AppendBytes("foo", 3); 2319 request[1].upload_data->AppendBytes("foo", 3);
2347 request[1].load_flags = 0; 2320 request[1].load_flags = 0;
2348 2321
2349 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2322 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2350 scoped_refptr<HttpNetworkSession> session = 2323 scoped_refptr<HttpNetworkSession> session =
2351 CreateSession(proxy_service.get(), &mock_socket_factory); 2324 CreateSession(proxy_service.get());
2352 2325
2353 // The first socket is used for transaction 1 and the first attempt of 2326 // The first socket is used for transaction 1 and the first attempt of
2354 // transaction 2. 2327 // transaction 2.
2355 2328
2356 // The response of transaction 1. 2329 // The response of transaction 1.
2357 MockRead data_reads1[] = { 2330 MockRead data_reads1[] = {
2358 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"), 2331 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"),
2359 MockRead("hello world"), 2332 MockRead("hello world"),
2360 MockRead(false, OK), 2333 MockRead(false, OK),
2361 }; 2334 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 EXPECT_EQ(OK, rv); 2391 EXPECT_EQ(OK, rv);
2419 EXPECT_EQ(kExpectedResponseData[i], response_data); 2392 EXPECT_EQ(kExpectedResponseData[i], response_data);
2420 } 2393 }
2421 } 2394 }
2422 2395
2423 // Test the request-challenge-retry sequence for basic auth when there is 2396 // Test the request-challenge-retry sequence for basic auth when there is
2424 // an identity in the URL. The request should be sent as normal, but when 2397 // an identity in the URL. The request should be sent as normal, but when
2425 // it fails the identity from the URL is used to answer the challenge. 2398 // it fails the identity from the URL is used to answer the challenge.
2426 TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) { 2399 TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) {
2427 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2400 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2428 scoped_ptr<HttpTransaction> trans( 2401 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
2429 new HttpNetworkTransaction( 2402 CreateSession(proxy_service.get()), &mock_socket_factory));
2430 CreateSession(proxy_service.get(), &mock_socket_factory),
2431 &mock_socket_factory));
2432 2403
2433 HttpRequestInfo request; 2404 HttpRequestInfo request;
2434 request.method = "GET"; 2405 request.method = "GET";
2435 // Note: the URL has a username:password in it. 2406 // Note: the URL has a username:password in it.
2436 request.url = GURL("http://foo:bar@www.google.com/"); 2407 request.url = GURL("http://foo:bar@www.google.com/");
2437 request.load_flags = 0; 2408 request.load_flags = 0;
2438 2409
2439 MockWrite data_writes1[] = { 2410 MockWrite data_writes1[] = {
2440 MockWrite("GET / HTTP/1.1\r\n" 2411 MockWrite("GET / HTTP/1.1\r\n"
2441 "Host: www.google.com\r\n" 2412 "Host: www.google.com\r\n"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 EXPECT_EQ(100, response->headers->GetContentLength()); 2470 EXPECT_EQ(100, response->headers->GetContentLength());
2500 2471
2501 // Empty the current queue. 2472 // Empty the current queue.
2502 MessageLoop::current()->RunAllPending(); 2473 MessageLoop::current()->RunAllPending();
2503 } 2474 }
2504 2475
2505 // Test that previously tried username/passwords for a realm get re-used. 2476 // Test that previously tried username/passwords for a realm get re-used.
2506 TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { 2477 TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) {
2507 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2478 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2508 scoped_refptr<HttpNetworkSession> session = 2479 scoped_refptr<HttpNetworkSession> session =
2509 CreateSession(proxy_service.get(), &mock_socket_factory); 2480 CreateSession(proxy_service.get());
2510 2481
2511 // Transaction 1: authenticate (foo, bar) on MyRealm1 2482 // Transaction 1: authenticate (foo, bar) on MyRealm1
2512 { 2483 {
2513 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 2484 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
2514 session, &mock_socket_factory)); 2485 session, &mock_socket_factory));
2515 2486
2516 HttpRequestInfo request; 2487 HttpRequestInfo request;
2517 request.method = "GET"; 2488 request.method = "GET";
2518 request.url = GURL("http://www.google.com/x/y/z"); 2489 request.url = GURL("http://www.google.com/x/y/z");
2519 request.load_flags = 0; 2490 request.load_flags = 0;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 EXPECT_FALSE(response == NULL); 2888 EXPECT_FALSE(response == NULL);
2918 EXPECT_TRUE(response->auth_challenge.get() == NULL); 2889 EXPECT_TRUE(response->auth_challenge.get() == NULL);
2919 EXPECT_EQ(100, response->headers->GetContentLength()); 2890 EXPECT_EQ(100, response->headers->GetContentLength());
2920 } 2891 }
2921 } 2892 }
2922 2893
2923 // Test the ResetStateForRestart() private method. 2894 // Test the ResetStateForRestart() private method.
2924 TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) { 2895 TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) {
2925 // Create a transaction (the dependencies aren't important). 2896 // Create a transaction (the dependencies aren't important).
2926 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2897 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2927 scoped_ptr<HttpNetworkTransaction> trans( 2898 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(
2928 new HttpNetworkTransaction( 2899 CreateSession(proxy_service.get()), &mock_socket_factory));
2929 CreateSession(proxy_service.get(), &mock_socket_factory),
2930 &mock_socket_factory));
2931 2900
2932 // Setup some state (which we expect ResetStateForRestart() will clear). 2901 // Setup some state (which we expect ResetStateForRestart() will clear).
2933 trans->header_buf_->Realloc(10); 2902 trans->header_buf_->Realloc(10);
2934 trans->header_buf_capacity_ = 10; 2903 trans->header_buf_capacity_ = 10;
2935 trans->header_buf_len_ = 3; 2904 trans->header_buf_len_ = 3;
2936 trans->header_buf_body_offset_ = 11; 2905 trans->header_buf_body_offset_ = 11;
2937 trans->header_buf_http_offset_ = 0; 2906 trans->header_buf_http_offset_ = 0;
2938 trans->response_body_length_ = 100; 2907 trans->response_body_length_ = 100;
2939 trans->response_body_read_ = 1; 2908 trans->response_body_read_ = 1;
2940 trans->read_buf_ = new IOBuffer(15); 2909 trans->read_buf_ = new IOBuffer(15);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2977 EXPECT_EQ(false, trans->response_.was_cached); 2946 EXPECT_EQ(false, trans->response_.was_cached);
2978 EXPECT_EQ(base::kInvalidPlatformFileValue, 2947 EXPECT_EQ(base::kInvalidPlatformFileValue,
2979 trans->response_.response_data_file); 2948 trans->response_.response_data_file);
2980 EXPECT_EQ(0, trans->response_.ssl_info.cert_status); 2949 EXPECT_EQ(0, trans->response_.ssl_info.cert_status);
2981 EXPECT_FALSE(trans->response_.vary_data.is_valid()); 2950 EXPECT_FALSE(trans->response_.vary_data.is_valid());
2982 } 2951 }
2983 2952
2984 // Test HTTPS connections to a site with a bad certificate 2953 // Test HTTPS connections to a site with a bad certificate
2985 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) { 2954 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) {
2986 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 2955 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
2987 scoped_ptr<HttpTransaction> trans( 2956 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
2988 new HttpNetworkTransaction( 2957 CreateSession(proxy_service.get()), &mock_socket_factory));
2989 CreateSession(proxy_service.get(), &mock_socket_factory),
2990 &mock_socket_factory));
2991 2958
2992 HttpRequestInfo request; 2959 HttpRequestInfo request;
2993 request.method = "GET"; 2960 request.method = "GET";
2994 request.url = GURL("https://www.google.com/"); 2961 request.url = GURL("https://www.google.com/");
2995 request.load_flags = 0; 2962 request.load_flags = 0;
2996 2963
2997 MockWrite data_writes[] = { 2964 MockWrite data_writes[] = {
2998 MockWrite("GET / HTTP/1.1\r\n" 2965 MockWrite("GET / HTTP/1.1\r\n"
2999 "Host: www.google.com\r\n" 2966 "Host: www.google.com\r\n"
3000 "Connection: keep-alive\r\n\r\n"), 2967 "Connection: keep-alive\r\n\r\n"),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 mock_ssl_sockets[0] = &ssl_bad; 3056 mock_ssl_sockets[0] = &ssl_bad;
3090 mock_ssl_sockets[1] = &ssl; 3057 mock_ssl_sockets[1] = &ssl;
3091 mock_ssl_sockets[2] = NULL; 3058 mock_ssl_sockets[2] = NULL;
3092 3059
3093 TestCompletionCallback callback; 3060 TestCompletionCallback callback;
3094 3061
3095 for (int i = 0; i < 2; i++) { 3062 for (int i = 0; i < 2; i++) {
3096 mock_sockets_index = 0; 3063 mock_sockets_index = 0;
3097 mock_ssl_sockets_index = 0; 3064 mock_ssl_sockets_index = 0;
3098 3065
3099 scoped_ptr<HttpTransaction> trans( 3066 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3100 new HttpNetworkTransaction( 3067 CreateSession(proxy_service.get()), &mock_socket_factory));
3101 CreateSession(proxy_service.get(), &mock_socket_factory),
3102 &mock_socket_factory));
3103 3068
3104 int rv = trans->Start(&request, &callback); 3069 int rv = trans->Start(&request, &callback);
3105 EXPECT_EQ(ERR_IO_PENDING, rv); 3070 EXPECT_EQ(ERR_IO_PENDING, rv);
3106 3071
3107 rv = callback.WaitForResult(); 3072 rv = callback.WaitForResult();
3108 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 3073 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
3109 3074
3110 rv = trans->RestartIgnoringLastError(&callback); 3075 rv = trans->RestartIgnoringLastError(&callback);
3111 EXPECT_EQ(ERR_IO_PENDING, rv); 3076 EXPECT_EQ(ERR_IO_PENDING, rv);
3112 3077
3113 rv = callback.WaitForResult(); 3078 rv = callback.WaitForResult();
3114 EXPECT_EQ(OK, rv); 3079 EXPECT_EQ(OK, rv);
3115 3080
3116 const HttpResponseInfo* response = trans->GetResponseInfo(); 3081 const HttpResponseInfo* response = trans->GetResponseInfo();
3117 3082
3118 EXPECT_FALSE(response == NULL); 3083 EXPECT_FALSE(response == NULL);
3119 EXPECT_EQ(100, response->headers->GetContentLength()); 3084 EXPECT_EQ(100, response->headers->GetContentLength());
3120 } 3085 }
3121 } 3086 }
3122 3087
3123 TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgent) { 3088 TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgent) {
3124 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3089 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3125 scoped_ptr<HttpTransaction> trans( 3090 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3126 new HttpNetworkTransaction( 3091 CreateSession(proxy_service.get()), &mock_socket_factory));
3127 CreateSession(proxy_service.get(), &mock_socket_factory),
3128 &mock_socket_factory));
3129 3092
3130 HttpRequestInfo request; 3093 HttpRequestInfo request;
3131 request.method = "GET"; 3094 request.method = "GET";
3132 request.url = GURL("http://www.google.com/"); 3095 request.url = GURL("http://www.google.com/");
3133 request.user_agent = "Chromium Ultra Awesome X Edition"; 3096 request.user_agent = "Chromium Ultra Awesome X Edition";
3134 3097
3135 MockWrite data_writes[] = { 3098 MockWrite data_writes[] = {
3136 MockWrite("GET / HTTP/1.1\r\n" 3099 MockWrite("GET / HTTP/1.1\r\n"
3137 "Host: www.google.com\r\n" 3100 "Host: www.google.com\r\n"
3138 "Connection: keep-alive\r\n" 3101 "Connection: keep-alive\r\n"
(...skipping 18 matching lines...) Expand all
3157 3120
3158 int rv = trans->Start(&request, &callback); 3121 int rv = trans->Start(&request, &callback);
3159 EXPECT_EQ(ERR_IO_PENDING, rv); 3122 EXPECT_EQ(ERR_IO_PENDING, rv);
3160 3123
3161 rv = callback.WaitForResult(); 3124 rv = callback.WaitForResult();
3162 EXPECT_EQ(OK, rv); 3125 EXPECT_EQ(OK, rv);
3163 } 3126 }
3164 3127
3165 TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) { 3128 TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) {
3166 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3129 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3167 scoped_ptr<HttpTransaction> trans( 3130 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3168 new HttpNetworkTransaction( 3131 CreateSession(proxy_service.get()), &mock_socket_factory));
3169 CreateSession(proxy_service.get(), &mock_socket_factory),
3170 &mock_socket_factory));
3171 3132
3172 HttpRequestInfo request; 3133 HttpRequestInfo request;
3173 request.method = "GET"; 3134 request.method = "GET";
3174 request.url = GURL("http://www.google.com/"); 3135 request.url = GURL("http://www.google.com/");
3175 request.load_flags = 0; 3136 request.load_flags = 0;
3176 request.referrer = GURL("http://the.previous.site.com/"); 3137 request.referrer = GURL("http://the.previous.site.com/");
3177 3138
3178 MockWrite data_writes[] = { 3139 MockWrite data_writes[] = {
3179 MockWrite("GET / HTTP/1.1\r\n" 3140 MockWrite("GET / HTTP/1.1\r\n"
3180 "Host: www.google.com\r\n" 3141 "Host: www.google.com\r\n"
(...skipping 19 matching lines...) Expand all
3200 3161
3201 int rv = trans->Start(&request, &callback); 3162 int rv = trans->Start(&request, &callback);
3202 EXPECT_EQ(ERR_IO_PENDING, rv); 3163 EXPECT_EQ(ERR_IO_PENDING, rv);
3203 3164
3204 rv = callback.WaitForResult(); 3165 rv = callback.WaitForResult();
3205 EXPECT_EQ(OK, rv); 3166 EXPECT_EQ(OK, rv);
3206 } 3167 }
3207 3168
3208 TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) { 3169 TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) {
3209 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3170 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3210 scoped_ptr<HttpTransaction> trans( 3171 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3211 new HttpNetworkTransaction( 3172 CreateSession(proxy_service.get()), &mock_socket_factory));
3212 CreateSession(proxy_service.get(), &mock_socket_factory),
3213 &mock_socket_factory));
3214 3173
3215 HttpRequestInfo request; 3174 HttpRequestInfo request;
3216 request.method = "POST"; 3175 request.method = "POST";
3217 request.url = GURL("http://www.google.com/"); 3176 request.url = GURL("http://www.google.com/");
3218 3177
3219 MockWrite data_writes[] = { 3178 MockWrite data_writes[] = {
3220 MockWrite("POST / HTTP/1.1\r\n" 3179 MockWrite("POST / HTTP/1.1\r\n"
3221 "Host: www.google.com\r\n" 3180 "Host: www.google.com\r\n"
3222 "Connection: keep-alive\r\n" 3181 "Connection: keep-alive\r\n"
3223 "Content-Length: 0\r\n\r\n"), 3182 "Content-Length: 0\r\n\r\n"),
(...skipping 17 matching lines...) Expand all
3241 3200
3242 int rv = trans->Start(&request, &callback); 3201 int rv = trans->Start(&request, &callback);
3243 EXPECT_EQ(ERR_IO_PENDING, rv); 3202 EXPECT_EQ(ERR_IO_PENDING, rv);
3244 3203
3245 rv = callback.WaitForResult(); 3204 rv = callback.WaitForResult();
3246 EXPECT_EQ(OK, rv); 3205 EXPECT_EQ(OK, rv);
3247 } 3206 }
3248 3207
3249 TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) { 3208 TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) {
3250 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3209 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3251 scoped_ptr<HttpTransaction> trans( 3210 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3252 new HttpNetworkTransaction( 3211 CreateSession(proxy_service.get()), &mock_socket_factory));
3253 CreateSession(proxy_service.get(), &mock_socket_factory),
3254 &mock_socket_factory));
3255 3212
3256 HttpRequestInfo request; 3213 HttpRequestInfo request;
3257 request.method = "PUT"; 3214 request.method = "PUT";
3258 request.url = GURL("http://www.google.com/"); 3215 request.url = GURL("http://www.google.com/");
3259 3216
3260 MockWrite data_writes[] = { 3217 MockWrite data_writes[] = {
3261 MockWrite("PUT / HTTP/1.1\r\n" 3218 MockWrite("PUT / HTTP/1.1\r\n"
3262 "Host: www.google.com\r\n" 3219 "Host: www.google.com\r\n"
3263 "Connection: keep-alive\r\n" 3220 "Connection: keep-alive\r\n"
3264 "Content-Length: 0\r\n\r\n"), 3221 "Content-Length: 0\r\n\r\n"),
(...skipping 17 matching lines...) Expand all
3282 3239
3283 int rv = trans->Start(&request, &callback); 3240 int rv = trans->Start(&request, &callback);
3284 EXPECT_EQ(ERR_IO_PENDING, rv); 3241 EXPECT_EQ(ERR_IO_PENDING, rv);
3285 3242
3286 rv = callback.WaitForResult(); 3243 rv = callback.WaitForResult();
3287 EXPECT_EQ(OK, rv); 3244 EXPECT_EQ(OK, rv);
3288 } 3245 }
3289 3246
3290 TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) { 3247 TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) {
3291 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3248 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3292 scoped_ptr<HttpTransaction> trans( 3249 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3293 new HttpNetworkTransaction( 3250 CreateSession(proxy_service.get()), &mock_socket_factory));
3294 CreateSession(proxy_service.get(), &mock_socket_factory),
3295 &mock_socket_factory));
3296 3251
3297 HttpRequestInfo request; 3252 HttpRequestInfo request;
3298 request.method = "HEAD"; 3253 request.method = "HEAD";
3299 request.url = GURL("http://www.google.com/"); 3254 request.url = GURL("http://www.google.com/");
3300 3255
3301 MockWrite data_writes[] = { 3256 MockWrite data_writes[] = {
3302 MockWrite("HEAD / HTTP/1.1\r\n" 3257 MockWrite("HEAD / HTTP/1.1\r\n"
3303 "Host: www.google.com\r\n" 3258 "Host: www.google.com\r\n"
3304 "Connection: keep-alive\r\n" 3259 "Connection: keep-alive\r\n"
3305 "Content-Length: 0\r\n\r\n"), 3260 "Content-Length: 0\r\n\r\n"),
(...skipping 17 matching lines...) Expand all
3323 3278
3324 int rv = trans->Start(&request, &callback); 3279 int rv = trans->Start(&request, &callback);
3325 EXPECT_EQ(ERR_IO_PENDING, rv); 3280 EXPECT_EQ(ERR_IO_PENDING, rv);
3326 3281
3327 rv = callback.WaitForResult(); 3282 rv = callback.WaitForResult();
3328 EXPECT_EQ(OK, rv); 3283 EXPECT_EQ(OK, rv);
3329 } 3284 }
3330 3285
3331 TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) { 3286 TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) {
3332 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3287 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3333 scoped_ptr<HttpTransaction> trans( 3288 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3334 new HttpNetworkTransaction( 3289 CreateSession(proxy_service.get()), &mock_socket_factory));
3335 CreateSession(proxy_service.get(), &mock_socket_factory),
3336 &mock_socket_factory));
3337 3290
3338 HttpRequestInfo request; 3291 HttpRequestInfo request;
3339 request.method = "GET"; 3292 request.method = "GET";
3340 request.url = GURL("http://www.google.com/"); 3293 request.url = GURL("http://www.google.com/");
3341 request.load_flags = LOAD_BYPASS_CACHE; 3294 request.load_flags = LOAD_BYPASS_CACHE;
3342 3295
3343 MockWrite data_writes[] = { 3296 MockWrite data_writes[] = {
3344 MockWrite("GET / HTTP/1.1\r\n" 3297 MockWrite("GET / HTTP/1.1\r\n"
3345 "Host: www.google.com\r\n" 3298 "Host: www.google.com\r\n"
3346 "Connection: keep-alive\r\n" 3299 "Connection: keep-alive\r\n"
(...skipping 20 matching lines...) Expand all
3367 int rv = trans->Start(&request, &callback); 3320 int rv = trans->Start(&request, &callback);
3368 EXPECT_EQ(ERR_IO_PENDING, rv); 3321 EXPECT_EQ(ERR_IO_PENDING, rv);
3369 3322
3370 rv = callback.WaitForResult(); 3323 rv = callback.WaitForResult();
3371 EXPECT_EQ(OK, rv); 3324 EXPECT_EQ(OK, rv);
3372 } 3325 }
3373 3326
3374 TEST_F(HttpNetworkTransactionTest, 3327 TEST_F(HttpNetworkTransactionTest,
3375 BuildRequest_CacheControlValidateCache) { 3328 BuildRequest_CacheControlValidateCache) {
3376 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3329 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3377 scoped_ptr<HttpTransaction> trans( 3330 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3378 new HttpNetworkTransaction( 3331 CreateSession(proxy_service.get()), &mock_socket_factory));
3379 CreateSession(proxy_service.get(), &mock_socket_factory),
3380 &mock_socket_factory));
3381 3332
3382 HttpRequestInfo request; 3333 HttpRequestInfo request;
3383 request.method = "GET"; 3334 request.method = "GET";
3384 request.url = GURL("http://www.google.com/"); 3335 request.url = GURL("http://www.google.com/");
3385 request.load_flags = LOAD_VALIDATE_CACHE; 3336 request.load_flags = LOAD_VALIDATE_CACHE;
3386 3337
3387 MockWrite data_writes[] = { 3338 MockWrite data_writes[] = {
3388 MockWrite("GET / HTTP/1.1\r\n" 3339 MockWrite("GET / HTTP/1.1\r\n"
3389 "Host: www.google.com\r\n" 3340 "Host: www.google.com\r\n"
3390 "Connection: keep-alive\r\n" 3341 "Connection: keep-alive\r\n"
(...skipping 18 matching lines...) Expand all
3409 3360
3410 int rv = trans->Start(&request, &callback); 3361 int rv = trans->Start(&request, &callback);
3411 EXPECT_EQ(ERR_IO_PENDING, rv); 3362 EXPECT_EQ(ERR_IO_PENDING, rv);
3412 3363
3413 rv = callback.WaitForResult(); 3364 rv = callback.WaitForResult();
3414 EXPECT_EQ(OK, rv); 3365 EXPECT_EQ(OK, rv);
3415 } 3366 }
3416 3367
3417 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) { 3368 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) {
3418 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService()); 3369 scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
3419 scoped_ptr<HttpTransaction> trans( 3370 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3420 new HttpNetworkTransaction( 3371 CreateSession(proxy_service.get()), &mock_socket_factory));
3421 CreateSession(proxy_service.get(), &mock_socket_factory),
3422 &mock_socket_factory));
3423 3372
3424 HttpRequestInfo request; 3373 HttpRequestInfo request;
3425 request.method = "GET"; 3374 request.method = "GET";
3426 request.url = GURL("http://www.google.com/"); 3375 request.url = GURL("http://www.google.com/");
3427 request.extra_headers = "FooHeader: Bar\r\n"; 3376 request.extra_headers = "FooHeader: Bar\r\n";
3428 3377
3429 MockWrite data_writes[] = { 3378 MockWrite data_writes[] = {
3430 MockWrite("GET / HTTP/1.1\r\n" 3379 MockWrite("GET / HTTP/1.1\r\n"
3431 "Host: www.google.com\r\n" 3380 "Host: www.google.com\r\n"
3432 "Connection: keep-alive\r\n" 3381 "Connection: keep-alive\r\n"
(...skipping 17 matching lines...) Expand all
3450 TestCompletionCallback callback; 3399 TestCompletionCallback callback;
3451 3400
3452 int rv = trans->Start(&request, &callback); 3401 int rv = trans->Start(&request, &callback);
3453 EXPECT_EQ(ERR_IO_PENDING, rv); 3402 EXPECT_EQ(ERR_IO_PENDING, rv);
3454 3403
3455 rv = callback.WaitForResult(); 3404 rv = callback.WaitForResult();
3456 EXPECT_EQ(OK, rv); 3405 EXPECT_EQ(OK, rv);
3457 } 3406 }
3458 3407
3459 } // namespace net 3408 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698