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

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

Issue 24246016: Make HttpNetworkTransaction no longer own a reference to HttpNetworkSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix test Created 7 years, 2 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 | Annotate | Revision Log
« 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 size_t data_count) { 282 size_t data_count) {
283 SimpleGetHelperResult out; 283 SimpleGetHelperResult out;
284 284
285 HttpRequestInfo request; 285 HttpRequestInfo request;
286 request.method = "GET"; 286 request.method = "GET";
287 request.url = GURL("http://www.google.com/"); 287 request.url = GURL("http://www.google.com/");
288 request.load_flags = 0; 288 request.load_flags = 0;
289 289
290 CapturingBoundNetLog log; 290 CapturingBoundNetLog log;
291 session_deps_.net_log = log.bound().net_log(); 291 session_deps_.net_log = log.bound().net_log();
292 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
292 scoped_ptr<HttpTransaction> trans( 293 scoped_ptr<HttpTransaction> trans(
293 new HttpNetworkTransaction(DEFAULT_PRIORITY, 294 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
294 CreateSession(&session_deps_)));
295 295
296 for (size_t i = 0; i < data_count; ++i) { 296 for (size_t i = 0; i < data_count; ++i) {
297 session_deps_.socket_factory->AddSocketDataProvider(data[i]); 297 session_deps_.socket_factory->AddSocketDataProvider(data[i]);
298 } 298 }
299 299
300 TestCompletionCallback callback; 300 TestCompletionCallback callback;
301 301
302 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); 302 EXPECT_TRUE(log.bound().IsLoggingAllEvents());
303 int rv = trans->Start(&request, callback.callback(), log.bound()); 303 int rv = trans->Start(&request, callback.callback(), log.bound());
304 EXPECT_EQ(ERR_IO_PENDING, rv); 304 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 EXPECT_FALSE(auth_challenge->is_proxy); 559 EXPECT_FALSE(auth_challenge->is_proxy);
560 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); 560 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString());
561 EXPECT_EQ(std::string(), auth_challenge->realm); 561 EXPECT_EQ(std::string(), auth_challenge->realm);
562 EXPECT_EQ("ntlm", auth_challenge->scheme); 562 EXPECT_EQ("ntlm", auth_challenge->scheme);
563 return true; 563 return true;
564 } 564 }
565 565
566 } // namespace 566 } // namespace
567 567
568 TEST_P(HttpNetworkTransactionTest, Basic) { 568 TEST_P(HttpNetworkTransactionTest, Basic) {
569 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
569 scoped_ptr<HttpTransaction> trans( 570 scoped_ptr<HttpTransaction> trans(
570 new HttpNetworkTransaction(DEFAULT_PRIORITY, 571 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
571 CreateSession(&session_deps_)));
572 } 572 }
573 573
574 TEST_P(HttpNetworkTransactionTest, SimpleGET) { 574 TEST_P(HttpNetworkTransactionTest, SimpleGET) {
575 MockRead data_reads[] = { 575 MockRead data_reads[] = {
576 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 576 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
577 MockRead("hello world"), 577 MockRead("hello world"),
578 MockRead(SYNCHRONOUS, OK), 578 MockRead(SYNCHRONOUS, OK),
579 }; 579 };
580 SimpleGetHelperResult out = SimpleGetHelper(data_reads, 580 SimpleGetHelperResult out = SimpleGetHelper(data_reads,
581 arraysize(data_reads)); 581 arraysize(data_reads));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 MockRead("Location: http://good.com/\r\n"), 854 MockRead("Location: http://good.com/\r\n"),
855 MockRead("Content-Length: 0\r\n\r\n"), 855 MockRead("Content-Length: 0\r\n\r\n"),
856 MockRead(SYNCHRONOUS, OK), 856 MockRead(SYNCHRONOUS, OK),
857 }; 857 };
858 858
859 HttpRequestInfo request; 859 HttpRequestInfo request;
860 request.method = "GET"; 860 request.method = "GET";
861 request.url = GURL("http://redirect.com/"); 861 request.url = GURL("http://redirect.com/");
862 request.load_flags = 0; 862 request.load_flags = 0;
863 863
864 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
864 scoped_ptr<HttpTransaction> trans( 865 scoped_ptr<HttpTransaction> trans(
865 new HttpNetworkTransaction(DEFAULT_PRIORITY, 866 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
866 CreateSession(&session_deps_)));
867 867
868 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 868 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
869 session_deps_.socket_factory->AddSocketDataProvider(&data); 869 session_deps_.socket_factory->AddSocketDataProvider(&data);
870 870
871 TestCompletionCallback callback; 871 TestCompletionCallback callback;
872 872
873 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 873 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
874 EXPECT_EQ(ERR_IO_PENDING, rv); 874 EXPECT_EQ(ERR_IO_PENDING, rv);
875 875
876 EXPECT_EQ(OK, callback.WaitForResult()); 876 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 21 matching lines...) Expand all
898 } 898 }
899 899
900 // Do a request using the HEAD method. Verify that we don't try to read the 900 // Do a request using the HEAD method. Verify that we don't try to read the
901 // message body (since HEAD has none). 901 // message body (since HEAD has none).
902 TEST_P(HttpNetworkTransactionTest, Head) { 902 TEST_P(HttpNetworkTransactionTest, Head) {
903 HttpRequestInfo request; 903 HttpRequestInfo request;
904 request.method = "HEAD"; 904 request.method = "HEAD";
905 request.url = GURL("http://www.google.com/"); 905 request.url = GURL("http://www.google.com/");
906 request.load_flags = 0; 906 request.load_flags = 0;
907 907
908 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
908 scoped_ptr<HttpTransaction> trans( 909 scoped_ptr<HttpTransaction> trans(
909 new HttpNetworkTransaction(DEFAULT_PRIORITY, 910 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
910 CreateSession(&session_deps_)));
911 911
912 MockWrite data_writes1[] = { 912 MockWrite data_writes1[] = {
913 MockWrite("HEAD / HTTP/1.1\r\n" 913 MockWrite("HEAD / HTTP/1.1\r\n"
914 "Host: www.google.com\r\n" 914 "Host: www.google.com\r\n"
915 "Connection: keep-alive\r\n" 915 "Connection: keep-alive\r\n"
916 "Content-Length: 0\r\n\r\n"), 916 "Content-Length: 0\r\n\r\n"),
917 }; 917 };
918 MockRead data_reads1[] = { 918 MockRead data_reads1[] = {
919 MockRead("HTTP/1.1 404 Not Found\r\n"), 919 MockRead("HTTP/1.1 404 Not Found\r\n"),
920 MockRead("Server: Blah\r\n"), 920 MockRead("Server: Blah\r\n"),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 ScopedVector<UploadElementReader> element_readers; 1010 ScopedVector<UploadElementReader> element_readers;
1011 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 1011 element_readers.push_back(new UploadBytesElementReader("foo", 3));
1012 UploadDataStream upload_data_stream(element_readers.Pass(), 0); 1012 UploadDataStream upload_data_stream(element_readers.Pass(), 0);
1013 1013
1014 HttpRequestInfo request; 1014 HttpRequestInfo request;
1015 request.method = "POST"; 1015 request.method = "POST";
1016 request.url = GURL("http://www.foo.com/"); 1016 request.url = GURL("http://www.foo.com/");
1017 request.upload_data_stream = &upload_data_stream; 1017 request.upload_data_stream = &upload_data_stream;
1018 request.load_flags = 0; 1018 request.load_flags = 0;
1019 1019
1020 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1020 scoped_ptr<HttpTransaction> trans( 1021 scoped_ptr<HttpTransaction> trans(
1021 new HttpNetworkTransaction(DEFAULT_PRIORITY, 1022 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
1022 CreateSession(&session_deps_)));
1023 1023
1024 MockRead data_reads[] = { 1024 MockRead data_reads[] = {
1025 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), 1025 MockRead("HTTP/1.0 100 Continue\r\n\r\n"),
1026 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 1026 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
1027 MockRead("hello world"), 1027 MockRead("hello world"),
1028 MockRead(SYNCHRONOUS, OK), 1028 MockRead(SYNCHRONOUS, OK),
1029 }; 1029 };
1030 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1030 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1031 session_deps_.socket_factory->AddSocketDataProvider(&data); 1031 session_deps_.socket_factory->AddSocketDataProvider(&data);
1032 1032
(...skipping 19 matching lines...) Expand all
1052 1052
1053 // This test is almost the same as Ignores100 above, but the response contains 1053 // This test is almost the same as Ignores100 above, but the response contains
1054 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is 1054 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is
1055 // HTTP/1.1 and the two status headers are read in one read. 1055 // HTTP/1.1 and the two status headers are read in one read.
1056 TEST_P(HttpNetworkTransactionTest, Ignores1xx) { 1056 TEST_P(HttpNetworkTransactionTest, Ignores1xx) {
1057 HttpRequestInfo request; 1057 HttpRequestInfo request;
1058 request.method = "GET"; 1058 request.method = "GET";
1059 request.url = GURL("http://www.foo.com/"); 1059 request.url = GURL("http://www.foo.com/");
1060 request.load_flags = 0; 1060 request.load_flags = 0;
1061 1061
1062 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1062 scoped_ptr<HttpTransaction> trans( 1063 scoped_ptr<HttpTransaction> trans(
1063 new HttpNetworkTransaction(DEFAULT_PRIORITY, 1064 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
1064 CreateSession(&session_deps_)));
1065 1065
1066 MockRead data_reads[] = { 1066 MockRead data_reads[] = {
1067 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n" 1067 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"
1068 "HTTP/1.1 200 OK\r\n\r\n"), 1068 "HTTP/1.1 200 OK\r\n\r\n"),
1069 MockRead("hello world"), 1069 MockRead("hello world"),
1070 MockRead(SYNCHRONOUS, OK), 1070 MockRead(SYNCHRONOUS, OK),
1071 }; 1071 };
1072 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1072 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1073 session_deps_.socket_factory->AddSocketDataProvider(&data); 1073 session_deps_.socket_factory->AddSocketDataProvider(&data);
1074 1074
(...skipping 16 matching lines...) Expand all
1091 EXPECT_EQ(OK, rv); 1091 EXPECT_EQ(OK, rv);
1092 EXPECT_EQ("hello world", response_data); 1092 EXPECT_EQ("hello world", response_data);
1093 } 1093 }
1094 1094
1095 TEST_P(HttpNetworkTransactionTest, Incomplete100ThenEOF) { 1095 TEST_P(HttpNetworkTransactionTest, Incomplete100ThenEOF) {
1096 HttpRequestInfo request; 1096 HttpRequestInfo request;
1097 request.method = "POST"; 1097 request.method = "POST";
1098 request.url = GURL("http://www.foo.com/"); 1098 request.url = GURL("http://www.foo.com/");
1099 request.load_flags = 0; 1099 request.load_flags = 0;
1100 1100
1101 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1101 scoped_ptr<HttpTransaction> trans( 1102 scoped_ptr<HttpTransaction> trans(
1102 new HttpNetworkTransaction(DEFAULT_PRIORITY, 1103 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
1103 CreateSession(&session_deps_)));
1104 1104
1105 MockRead data_reads[] = { 1105 MockRead data_reads[] = {
1106 MockRead(SYNCHRONOUS, "HTTP/1.0 100 Continue\r\n"), 1106 MockRead(SYNCHRONOUS, "HTTP/1.0 100 Continue\r\n"),
1107 MockRead(ASYNC, 0), 1107 MockRead(ASYNC, 0),
1108 }; 1108 };
1109 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1109 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1110 session_deps_.socket_factory->AddSocketDataProvider(&data); 1110 session_deps_.socket_factory->AddSocketDataProvider(&data);
1111 1111
1112 TestCompletionCallback callback; 1112 TestCompletionCallback callback;
1113 1113
1114 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 1114 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
1115 EXPECT_EQ(ERR_IO_PENDING, rv); 1115 EXPECT_EQ(ERR_IO_PENDING, rv);
1116 1116
1117 rv = callback.WaitForResult(); 1117 rv = callback.WaitForResult();
1118 EXPECT_EQ(OK, rv); 1118 EXPECT_EQ(OK, rv);
1119 1119
1120 std::string response_data; 1120 std::string response_data;
1121 rv = ReadTransaction(trans.get(), &response_data); 1121 rv = ReadTransaction(trans.get(), &response_data);
1122 EXPECT_EQ(OK, rv); 1122 EXPECT_EQ(OK, rv);
1123 EXPECT_EQ("", response_data); 1123 EXPECT_EQ("", response_data);
1124 } 1124 }
1125 1125
1126 TEST_P(HttpNetworkTransactionTest, EmptyResponse) { 1126 TEST_P(HttpNetworkTransactionTest, EmptyResponse) {
1127 HttpRequestInfo request; 1127 HttpRequestInfo request;
1128 request.method = "POST"; 1128 request.method = "POST";
1129 request.url = GURL("http://www.foo.com/"); 1129 request.url = GURL("http://www.foo.com/");
1130 request.load_flags = 0; 1130 request.load_flags = 0;
1131 1131
1132 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1132 scoped_ptr<HttpTransaction> trans( 1133 scoped_ptr<HttpTransaction> trans(
1133 new HttpNetworkTransaction(DEFAULT_PRIORITY, 1134 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
1134 CreateSession(&session_deps_))); 1135
1135 1136
1136 MockRead data_reads[] = { 1137 MockRead data_reads[] = {
1137 MockRead(ASYNC, 0), 1138 MockRead(ASYNC, 0),
1138 }; 1139 };
1139 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1140 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1140 session_deps_.socket_factory->AddSocketDataProvider(&data); 1141 session_deps_.socket_factory->AddSocketDataProvider(&data);
1141 1142
1142 TestCompletionCallback callback; 1143 TestCompletionCallback callback;
1143 1144
1144 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 1145 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 MockRead read_failure(SYNCHRONOUS, OK); // EOF 1253 MockRead read_failure(SYNCHRONOUS, OK); // EOF
1253 KeepAliveConnectionResendRequestTest(NULL, &read_failure); 1254 KeepAliveConnectionResendRequestTest(NULL, &read_failure);
1254 } 1255 }
1255 1256
1256 TEST_P(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) { 1257 TEST_P(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) {
1257 HttpRequestInfo request; 1258 HttpRequestInfo request;
1258 request.method = "GET"; 1259 request.method = "GET";
1259 request.url = GURL("http://www.google.com/"); 1260 request.url = GURL("http://www.google.com/");
1260 request.load_flags = 0; 1261 request.load_flags = 0;
1261 1262
1263 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1262 scoped_ptr<HttpTransaction> trans( 1264 scoped_ptr<HttpTransaction> trans(
1263 new HttpNetworkTransaction(DEFAULT_PRIORITY, 1265 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
1264 CreateSession(&session_deps_)));
1265 1266
1266 MockRead data_reads[] = { 1267 MockRead data_reads[] = {
1267 MockRead(ASYNC, ERR_CONNECTION_RESET), 1268 MockRead(ASYNC, ERR_CONNECTION_RESET),
1268 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used 1269 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used
1269 MockRead("hello world"), 1270 MockRead("hello world"),
1270 MockRead(SYNCHRONOUS, OK), 1271 MockRead(SYNCHRONOUS, OK),
1271 }; 1272 };
1272 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1273 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1273 session_deps_.socket_factory->AddSocketDataProvider(&data); 1274 session_deps_.socket_factory->AddSocketDataProvider(&data);
1274 1275
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 // Test the request-challenge-retry sequence for basic auth. 1501 // Test the request-challenge-retry sequence for basic auth.
1501 // (basic auth is the easiest to mock, because it has no randomness). 1502 // (basic auth is the easiest to mock, because it has no randomness).
1502 TEST_P(HttpNetworkTransactionTest, BasicAuth) { 1503 TEST_P(HttpNetworkTransactionTest, BasicAuth) {
1503 HttpRequestInfo request; 1504 HttpRequestInfo request;
1504 request.method = "GET"; 1505 request.method = "GET";
1505 request.url = GURL("http://www.google.com/"); 1506 request.url = GURL("http://www.google.com/");
1506 request.load_flags = 0; 1507 request.load_flags = 0;
1507 1508
1508 CapturingNetLog log; 1509 CapturingNetLog log;
1509 session_deps_.net_log = &log; 1510 session_deps_.net_log = &log;
1511 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1510 scoped_ptr<HttpTransaction> trans( 1512 scoped_ptr<HttpTransaction> trans(
1511 new HttpNetworkTransaction(DEFAULT_PRIORITY, 1513 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
1512 CreateSession(&session_deps_)));
1513 1514
1514 MockWrite data_writes1[] = { 1515 MockWrite data_writes1[] = {
1515 MockWrite("GET / HTTP/1.1\r\n" 1516 MockWrite("GET / HTTP/1.1\r\n"
1516 "Host: www.google.com\r\n" 1517 "Host: www.google.com\r\n"
1517 "Connection: keep-alive\r\n\r\n"), 1518 "Connection: keep-alive\r\n\r\n"),
1518 }; 1519 };
1519 1520
1520 MockRead data_reads1[] = { 1521 MockRead data_reads1[] = {
1521 MockRead("HTTP/1.0 401 Unauthorized\r\n"), 1522 MockRead("HTTP/1.0 401 Unauthorized\r\n"),
1522 // Give a couple authenticate options (only the middle one is actually 1523 // Give a couple authenticate options (only the middle one is actually
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 EXPECT_TRUE(response->auth_challenge.get() == NULL); 1594 EXPECT_TRUE(response->auth_challenge.get() == NULL);
1594 EXPECT_EQ(100, response->headers->GetContentLength()); 1595 EXPECT_EQ(100, response->headers->GetContentLength());
1595 } 1596 }
1596 1597
1597 TEST_P(HttpNetworkTransactionTest, DoNotSendAuth) { 1598 TEST_P(HttpNetworkTransactionTest, DoNotSendAuth) {
1598 HttpRequestInfo request; 1599 HttpRequestInfo request;
1599 request.method = "GET"; 1600 request.method = "GET";
1600 request.url = GURL("http://www.google.com/"); 1601 request.url = GURL("http://www.google.com/");
1601 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; 1602 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA;
1602 1603
1604 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1603 scoped_ptr<HttpTransaction> trans( 1605 scoped_ptr<HttpTransaction> trans(
1604 new HttpNetworkTransaction(DEFAULT_PRIORITY, 1606 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
1605 CreateSession(&session_deps_)));
1606 1607
1607 MockWrite data_writes[] = { 1608 MockWrite data_writes[] = {
1608 MockWrite("GET / HTTP/1.1\r\n" 1609 MockWrite("GET / HTTP/1.1\r\n"
1609 "Host: www.google.com\r\n" 1610 "Host: www.google.com\r\n"
1610 "Connection: keep-alive\r\n\r\n"), 1611 "Connection: keep-alive\r\n\r\n"),
1611 }; 1612 };
1612 1613
1613 MockRead data_reads[] = { 1614 MockRead data_reads[] = {
1614 MockRead("HTTP/1.0 401 Unauthorized\r\n"), 1615 MockRead("HTTP/1.0 401 Unauthorized\r\n"),
1615 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 1616 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2256 2257
2257 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). 2258 // Test when a server (non-proxy) returns a 407 (proxy-authenticate).
2258 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. 2259 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH.
2259 TEST_P(HttpNetworkTransactionTest, UnexpectedProxyAuth) { 2260 TEST_P(HttpNetworkTransactionTest, UnexpectedProxyAuth) {
2260 HttpRequestInfo request; 2261 HttpRequestInfo request;
2261 request.method = "GET"; 2262 request.method = "GET";
2262 request.url = GURL("http://www.google.com/"); 2263 request.url = GURL("http://www.google.com/");
2263 request.load_flags = 0; 2264 request.load_flags = 0;
2264 2265
2265 // We are using a DIRECT connection (i.e. no proxy) for this session. 2266 // We are using a DIRECT connection (i.e. no proxy) for this session.
2267 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2266 scoped_ptr<HttpTransaction> trans( 2268 scoped_ptr<HttpTransaction> trans(
2267 new HttpNetworkTransaction(DEFAULT_PRIORITY, 2269 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
2268 CreateSession(&session_deps_)));
2269 2270
2270 MockWrite data_writes1[] = { 2271 MockWrite data_writes1[] = {
2271 MockWrite("GET / HTTP/1.1\r\n" 2272 MockWrite("GET / HTTP/1.1\r\n"
2272 "Host: www.google.com\r\n" 2273 "Host: www.google.com\r\n"
2273 "Connection: keep-alive\r\n\r\n"), 2274 "Connection: keep-alive\r\n\r\n"),
2274 }; 2275 };
2275 2276
2276 MockRead data_reads1[] = { 2277 MockRead data_reads1[] = {
2277 MockRead("HTTP/1.0 407 Proxy Auth required\r\n"), 2278 MockRead("HTTP/1.0 407 Proxy Auth required\r\n"),
2278 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 2279 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
3735 // Test the flow when both the proxy server AND origin server require 3736 // Test the flow when both the proxy server AND origin server require
3736 // authentication. Again, this uses basic auth for both since that is 3737 // authentication. Again, this uses basic auth for both since that is
3737 // the simplest to mock. 3738 // the simplest to mock.
3738 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { 3739 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyThenServer) {
3739 HttpRequestInfo request; 3740 HttpRequestInfo request;
3740 request.method = "GET"; 3741 request.method = "GET";
3741 request.url = GURL("http://www.google.com/"); 3742 request.url = GURL("http://www.google.com/");
3742 request.load_flags = 0; 3743 request.load_flags = 0;
3743 3744
3744 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 3745 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
3746 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3745 3747
3746 // Configure against proxy server "myproxy:70". 3748 // Configure against proxy server "myproxy:70".
wtc 2013/10/15 23:08:21 Nit: this comment could be describing |session| be
mmenke 2013/10/16 15:58:44 Done.
3747 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(DEFAULT_PRIORITY, 3749 scoped_ptr<HttpTransaction> trans(
3748 CreateSession(&session_deps_))); 3750 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
3749 3751
3750 MockWrite data_writes1[] = { 3752 MockWrite data_writes1[] = {
3751 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" 3753 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n"
3752 "Host: www.google.com\r\n" 3754 "Host: www.google.com\r\n"
3753 "Proxy-Connection: keep-alive\r\n\r\n"), 3755 "Proxy-Connection: keep-alive\r\n\r\n"),
3754 }; 3756 };
3755 3757
3756 MockRead data_reads1[] = { 3758 MockRead data_reads1[] = {
3757 MockRead("HTTP/1.0 407 Unauthorized\r\n"), 3759 MockRead("HTTP/1.0 407 Unauthorized\r\n"),
3758 // Give a couple authenticate options (only the middle one is actually 3760 // Give a couple authenticate options (only the middle one is actually
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
4194 4196
4195 // Test reading a server response which has only headers, and no body. 4197 // Test reading a server response which has only headers, and no body.
4196 // After some maximum number of bytes is consumed, the transaction should 4198 // After some maximum number of bytes is consumed, the transaction should
4197 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. 4199 // fail with ERR_RESPONSE_HEADERS_TOO_BIG.
4198 TEST_P(HttpNetworkTransactionTest, LargeHeadersNoBody) { 4200 TEST_P(HttpNetworkTransactionTest, LargeHeadersNoBody) {
4199 HttpRequestInfo request; 4201 HttpRequestInfo request;
4200 request.method = "GET"; 4202 request.method = "GET";
4201 request.url = GURL("http://www.google.com/"); 4203 request.url = GURL("http://www.google.com/");
4202 request.load_flags = 0; 4204 request.load_flags = 0;
4203 4205
4206 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4204 scoped_ptr<HttpTransaction> trans( 4207 scoped_ptr<HttpTransaction> trans(
4205 new HttpNetworkTransaction(DEFAULT_PRIORITY, 4208 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
4206 CreateSession(&session_deps_)));
4207 4209
4208 // Respond with 300 kb of headers (we should fail after 256 kb). 4210 // Respond with 300 kb of headers (we should fail after 256 kb).
4209 std::string large_headers_string; 4211 std::string large_headers_string;
4210 FillLargeHeadersString(&large_headers_string, 300 * 1024); 4212 FillLargeHeadersString(&large_headers_string, 300 * 1024);
4211 4213
4212 MockRead data_reads[] = { 4214 MockRead data_reads[] = {
4213 MockRead("HTTP/1.0 200 OK\r\n"), 4215 MockRead("HTTP/1.0 200 OK\r\n"),
4214 MockRead(ASYNC, large_headers_string.data(), large_headers_string.size()), 4216 MockRead(ASYNC, large_headers_string.data(), large_headers_string.size()),
4215 MockRead("\r\nBODY"), 4217 MockRead("\r\nBODY"),
4216 MockRead(SYNCHRONOUS, OK), 4218 MockRead(SYNCHRONOUS, OK),
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
4649 4651
4650 // Test the request-challenge-retry sequence for basic auth when there is 4652 // Test the request-challenge-retry sequence for basic auth when there is
4651 // an identity in the URL. The request should be sent as normal, but when 4653 // an identity in the URL. The request should be sent as normal, but when
4652 // it fails the identity from the URL is used to answer the challenge. 4654 // it fails the identity from the URL is used to answer the challenge.
4653 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURL) { 4655 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURL) {
4654 HttpRequestInfo request; 4656 HttpRequestInfo request;
4655 request.method = "GET"; 4657 request.method = "GET";
4656 request.url = GURL("http://foo:b@r@www.google.com/"); 4658 request.url = GURL("http://foo:b@r@www.google.com/");
4657 request.load_flags = LOAD_NORMAL; 4659 request.load_flags = LOAD_NORMAL;
4658 4660
4661 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4659 scoped_ptr<HttpTransaction> trans( 4662 scoped_ptr<HttpTransaction> trans(
4660 new HttpNetworkTransaction(DEFAULT_PRIORITY, 4663 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
4661 CreateSession(&session_deps_)));
4662 4664
4663 // The password contains an escaped character -- for this test to pass it 4665 // The password contains an escaped character -- for this test to pass it
4664 // will need to be unescaped by HttpNetworkTransaction. 4666 // will need to be unescaped by HttpNetworkTransaction.
4665 EXPECT_EQ("b%40r", request.url.password()); 4667 EXPECT_EQ("b%40r", request.url.password());
4666 4668
4667 MockWrite data_writes1[] = { 4669 MockWrite data_writes1[] = {
4668 MockWrite("GET / HTTP/1.1\r\n" 4670 MockWrite("GET / HTTP/1.1\r\n"
4669 "Host: www.google.com\r\n" 4671 "Host: www.google.com\r\n"
4670 "Connection: keep-alive\r\n\r\n"), 4672 "Connection: keep-alive\r\n\r\n"),
4671 }; 4673 };
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4730 // once. 4732 // once.
4731 TEST_P(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { 4733 TEST_P(HttpNetworkTransactionTest, WrongAuthIdentityInURL) {
4732 HttpRequestInfo request; 4734 HttpRequestInfo request;
4733 request.method = "GET"; 4735 request.method = "GET";
4734 // Note: the URL has a username:password in it. The password "baz" is 4736 // Note: the URL has a username:password in it. The password "baz" is
4735 // wrong (should be "bar"). 4737 // wrong (should be "bar").
4736 request.url = GURL("http://foo:baz@www.google.com/"); 4738 request.url = GURL("http://foo:baz@www.google.com/");
4737 4739
4738 request.load_flags = LOAD_NORMAL; 4740 request.load_flags = LOAD_NORMAL;
4739 4741
4742 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4740 scoped_ptr<HttpTransaction> trans( 4743 scoped_ptr<HttpTransaction> trans(
4741 new HttpNetworkTransaction(DEFAULT_PRIORITY, 4744 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
4742 CreateSession(&session_deps_)));
4743 4745
4744 MockWrite data_writes1[] = { 4746 MockWrite data_writes1[] = {
4745 MockWrite("GET / HTTP/1.1\r\n" 4747 MockWrite("GET / HTTP/1.1\r\n"
4746 "Host: www.google.com\r\n" 4748 "Host: www.google.com\r\n"
4747 "Connection: keep-alive\r\n\r\n"), 4749 "Connection: keep-alive\r\n\r\n"),
4748 }; 4750 };
4749 4751
4750 MockRead data_reads1[] = { 4752 MockRead data_reads1[] = {
4751 MockRead("HTTP/1.0 401 Unauthorized\r\n"), 4753 MockRead("HTTP/1.0 401 Unauthorized\r\n"),
4752 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 4754 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
5349 5351
5350 const HttpResponseInfo* response = trans->GetResponseInfo(); 5352 const HttpResponseInfo* response = trans->GetResponseInfo();
5351 ASSERT_TRUE(response != NULL); 5353 ASSERT_TRUE(response != NULL);
5352 EXPECT_TRUE(response->auth_challenge.get() == NULL); 5354 EXPECT_TRUE(response->auth_challenge.get() == NULL);
5353 } 5355 }
5354 } 5356 }
5355 5357
5356 // Test the ResetStateForRestart() private method. 5358 // Test the ResetStateForRestart() private method.
5357 TEST_P(HttpNetworkTransactionTest, ResetStateForRestart) { 5359 TEST_P(HttpNetworkTransactionTest, ResetStateForRestart) {
5358 // Create a transaction (the dependencies aren't important). 5360 // Create a transaction (the dependencies aren't important).
5361 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5359 scoped_ptr<HttpNetworkTransaction> trans( 5362 scoped_ptr<HttpNetworkTransaction> trans(
5360 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5363 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5361 CreateSession(&session_deps_)));
5362 5364
5363 // Setup some state (which we expect ResetStateForRestart() will clear). 5365 // Setup some state (which we expect ResetStateForRestart() will clear).
5364 trans->read_buf_ = new IOBuffer(15); 5366 trans->read_buf_ = new IOBuffer(15);
5365 trans->read_buf_len_ = 15; 5367 trans->read_buf_len_ = 15;
5366 trans->request_headers_.SetHeader("Authorization", "NTLM"); 5368 trans->request_headers_.SetHeader("Authorization", "NTLM");
5367 5369
5368 // Setup state in response_ 5370 // Setup state in response_
5369 HttpResponseInfo* response = &trans->response_; 5371 HttpResponseInfo* response = &trans->response_;
5370 response->auth_challenge = new AuthChallengeInfo(); 5372 response->auth_challenge = new AuthChallengeInfo();
5371 response->ssl_info.cert_status = static_cast<CertStatus>(-1); // Nonsensical. 5373 response->ssl_info.cert_status = static_cast<CertStatus>(-1); // Nonsensical.
(...skipping 24 matching lines...) Expand all
5396 EXPECT_FALSE(response->vary_data.is_valid()); 5398 EXPECT_FALSE(response->vary_data.is_valid());
5397 } 5399 }
5398 5400
5399 // Test HTTPS connections to a site with a bad certificate 5401 // Test HTTPS connections to a site with a bad certificate
5400 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificate) { 5402 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificate) {
5401 HttpRequestInfo request; 5403 HttpRequestInfo request;
5402 request.method = "GET"; 5404 request.method = "GET";
5403 request.url = GURL("https://www.google.com/"); 5405 request.url = GURL("https://www.google.com/");
5404 request.load_flags = 0; 5406 request.load_flags = 0;
5405 5407
5408 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5406 scoped_ptr<HttpTransaction> trans( 5409 scoped_ptr<HttpTransaction> trans(
5407 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5410 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5408 CreateSession(&session_deps_)));
5409 5411
5410 MockWrite data_writes[] = { 5412 MockWrite data_writes[] = {
5411 MockWrite("GET / HTTP/1.1\r\n" 5413 MockWrite("GET / HTTP/1.1\r\n"
5412 "Host: www.google.com\r\n" 5414 "Host: www.google.com\r\n"
5413 "Connection: keep-alive\r\n\r\n"), 5415 "Connection: keep-alive\r\n\r\n"),
5414 }; 5416 };
5415 5417
5416 MockRead data_reads[] = { 5418 MockRead data_reads[] = {
5417 MockRead("HTTP/1.0 200 OK\r\n"), 5419 MockRead("HTTP/1.0 200 OK\r\n"),
5418 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 5420 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5497 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID); 5499 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID);
5498 SSLSocketDataProvider ssl(ASYNC, OK); 5500 SSLSocketDataProvider ssl(ASYNC, OK);
5499 5501
5500 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate); 5502 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate);
5501 session_deps_.socket_factory->AddSocketDataProvider(&data); 5503 session_deps_.socket_factory->AddSocketDataProvider(&data);
5502 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad); 5504 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad);
5503 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 5505 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
5504 5506
5505 TestCompletionCallback callback; 5507 TestCompletionCallback callback;
5506 5508
5507 for (int i = 0; i < 2; i++) { 5509 for (int i = 0; i < 2; i++) {
wtc 2013/10/16 15:04:32 I wonder why this test needs to repeat this twice.
mmenke 2013/10/16 15:58:44 https://codereview.chromium.org/43115 - sounds lik
5508 session_deps_.socket_factory->ResetNextMockIndexes(); 5510 session_deps_.socket_factory->ResetNextMockIndexes();
5509 5511
5512 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5510 scoped_ptr<HttpTransaction> trans( 5513 scoped_ptr<HttpTransaction> trans(
5511 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5514 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5512 CreateSession(&session_deps_)));
5513 5515
5514 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5516 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5515 EXPECT_EQ(ERR_IO_PENDING, rv); 5517 EXPECT_EQ(ERR_IO_PENDING, rv);
5516 5518
5517 rv = callback.WaitForResult(); 5519 rv = callback.WaitForResult();
5518 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 5520 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
5519 5521
5520 rv = trans->RestartIgnoringLastError(callback.callback()); 5522 rv = trans->RestartIgnoringLastError(callback.callback());
5521 EXPECT_EQ(ERR_IO_PENDING, rv); 5523 EXPECT_EQ(ERR_IO_PENDING, rv);
5522 5524
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5564 data_writes, arraysize(data_writes)); 5566 data_writes, arraysize(data_writes));
5565 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 5567 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
5566 SSLSocketDataProvider tunnel_ssl(ASYNC, OK); // SSL through the tunnel 5568 SSLSocketDataProvider tunnel_ssl(ASYNC, OK); // SSL through the tunnel
5567 5569
5568 session_deps_.socket_factory->AddSocketDataProvider(&data); 5570 session_deps_.socket_factory->AddSocketDataProvider(&data);
5569 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 5571 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
5570 session_deps_.socket_factory->AddSSLSocketDataProvider(&tunnel_ssl); 5572 session_deps_.socket_factory->AddSSLSocketDataProvider(&tunnel_ssl);
5571 5573
5572 TestCompletionCallback callback; 5574 TestCompletionCallback callback;
5573 5575
5576 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5574 scoped_ptr<HttpTransaction> trans( 5577 scoped_ptr<HttpTransaction> trans(
5575 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5578 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5576 CreateSession(&session_deps_)));
5577 5579
5578 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5580 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5579 EXPECT_EQ(ERR_IO_PENDING, rv); 5581 EXPECT_EQ(ERR_IO_PENDING, rv);
5580 5582
5581 rv = callback.WaitForResult(); 5583 rv = callback.WaitForResult();
5582 EXPECT_EQ(OK, rv); 5584 EXPECT_EQ(OK, rv);
5583 const HttpResponseInfo* response = trans->GetResponseInfo(); 5585 const HttpResponseInfo* response = trans->GetResponseInfo();
5584 5586
5585 ASSERT_TRUE(response != NULL); 5587 ASSERT_TRUE(response != NULL);
5586 5588
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5622 5624
5623 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 5625 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
5624 data_writes, arraysize(data_writes)); 5626 data_writes, arraysize(data_writes));
5625 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 5627 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
5626 5628
5627 session_deps_.socket_factory->AddSocketDataProvider(&data); 5629 session_deps_.socket_factory->AddSocketDataProvider(&data);
5628 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 5630 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
5629 5631
5630 TestCompletionCallback callback; 5632 TestCompletionCallback callback;
5631 5633
5634 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5632 scoped_ptr<HttpTransaction> trans( 5635 scoped_ptr<HttpTransaction> trans(
5633 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5636 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5634 CreateSession(&session_deps_)));
5635 5637
5636 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5638 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5637 EXPECT_EQ(ERR_IO_PENDING, rv); 5639 EXPECT_EQ(ERR_IO_PENDING, rv);
5638 5640
5639 rv = callback.WaitForResult(); 5641 rv = callback.WaitForResult();
5640 EXPECT_EQ(OK, rv); 5642 EXPECT_EQ(OK, rv);
5641 const HttpResponseInfo* response = trans->GetResponseInfo(); 5643 const HttpResponseInfo* response = trans->GetResponseInfo();
5642 5644
5643 ASSERT_TRUE(response != NULL); 5645 ASSERT_TRUE(response != NULL);
5644 5646
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5707 data_reads, arraysize(data_reads), 5709 data_reads, arraysize(data_reads),
5708 data_writes, arraysize(data_writes)); 5710 data_writes, arraysize(data_writes));
5709 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 5711 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
5710 proxy_ssl.SetNextProto(GetParam()); 5712 proxy_ssl.SetNextProto(GetParam());
5711 5713
5712 session_deps_.socket_factory->AddSocketDataProvider(&data); 5714 session_deps_.socket_factory->AddSocketDataProvider(&data);
5713 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 5715 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
5714 5716
5715 TestCompletionCallback callback; 5717 TestCompletionCallback callback;
5716 5718
5719 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5717 scoped_ptr<HttpTransaction> trans( 5720 scoped_ptr<HttpTransaction> trans(
5718 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5721 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5719 CreateSession(&session_deps_)));
5720 5722
5721 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5723 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5722 EXPECT_EQ(ERR_IO_PENDING, rv); 5724 EXPECT_EQ(ERR_IO_PENDING, rv);
5723 5725
5724 rv = callback.WaitForResult(); 5726 rv = callback.WaitForResult();
5725 EXPECT_EQ(OK, rv); 5727 EXPECT_EQ(OK, rv);
5726 const HttpResponseInfo* response = trans->GetResponseInfo(); 5728 const HttpResponseInfo* response = trans->GetResponseInfo();
5727 5729
5728 ASSERT_TRUE(response != NULL); 5730 ASSERT_TRUE(response != NULL);
5729 5731
(...skipping 29 matching lines...) Expand all
5759 5761
5760 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 5762 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
5761 data_writes, arraysize(data_writes)); 5763 data_writes, arraysize(data_writes));
5762 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 5764 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
5763 5765
5764 session_deps_.socket_factory->AddSocketDataProvider(&data); 5766 session_deps_.socket_factory->AddSocketDataProvider(&data);
5765 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 5767 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
5766 5768
5767 TestCompletionCallback callback; 5769 TestCompletionCallback callback;
5768 5770
5771 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5769 scoped_ptr<HttpTransaction> trans( 5772 scoped_ptr<HttpTransaction> trans(
5770 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5773 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5771 CreateSession(&session_deps_)));
5772 5774
5773 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5775 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5774 EXPECT_EQ(ERR_IO_PENDING, rv); 5776 EXPECT_EQ(ERR_IO_PENDING, rv);
5775 5777
5776 rv = callback.WaitForResult(); 5778 rv = callback.WaitForResult();
5777 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 5779 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
5778 5780
5779 // TODO(ttuttle): Anything else to check here? 5781 // TODO(ttuttle): Anything else to check here?
5780 } 5782 }
5781 5783
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5820 data_reads, arraysize(data_reads), 5822 data_reads, arraysize(data_reads),
5821 data_writes, arraysize(data_writes)); 5823 data_writes, arraysize(data_writes));
5822 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 5824 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
5823 proxy_ssl.SetNextProto(GetParam()); 5825 proxy_ssl.SetNextProto(GetParam());
5824 5826
5825 session_deps_.socket_factory->AddSocketDataProvider(&data); 5827 session_deps_.socket_factory->AddSocketDataProvider(&data);
5826 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 5828 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
5827 5829
5828 TestCompletionCallback callback; 5830 TestCompletionCallback callback;
5829 5831
5832 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5830 scoped_ptr<HttpTransaction> trans( 5833 scoped_ptr<HttpTransaction> trans(
5831 new HttpNetworkTransaction(DEFAULT_PRIORITY, 5834 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
5832 CreateSession(&session_deps_)));
5833 5835
5834 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5836 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5835 EXPECT_EQ(ERR_IO_PENDING, rv); 5837 EXPECT_EQ(ERR_IO_PENDING, rv);
5836 5838
5837 rv = callback.WaitForResult(); 5839 rv = callback.WaitForResult();
5838 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 5840 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
5839 5841
5840 // TODO(ttuttle): Anything else to check here? 5842 // TODO(ttuttle): Anything else to check here?
5841 } 5843 }
5842 5844
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
6245 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate); 6247 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate);
6246 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad); 6248 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad);
6247 6249
6248 // SSL to the proxy, then CONNECT request, then valid SSL certificate 6250 // SSL to the proxy, then CONNECT request, then valid SSL certificate
6249 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 6251 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
6250 session_deps_.socket_factory->AddSocketDataProvider(&data); 6252 session_deps_.socket_factory->AddSocketDataProvider(&data);
6251 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 6253 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
6252 6254
6253 TestCompletionCallback callback; 6255 TestCompletionCallback callback;
6254 6256
6257 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6255 scoped_ptr<HttpTransaction> trans( 6258 scoped_ptr<HttpTransaction> trans(
6256 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6259 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6257 CreateSession(&session_deps_)));
6258 6260
6259 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 6261 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
6260 EXPECT_EQ(ERR_IO_PENDING, rv); 6262 EXPECT_EQ(ERR_IO_PENDING, rv);
6261 6263
6262 rv = callback.WaitForResult(); 6264 rv = callback.WaitForResult();
6263 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 6265 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
6264 6266
6265 rv = trans->RestartIgnoringLastError(callback.callback()); 6267 rv = trans->RestartIgnoringLastError(callback.callback());
6266 EXPECT_EQ(ERR_IO_PENDING, rv); 6268 EXPECT_EQ(ERR_IO_PENDING, rv);
6267 6269
6268 rv = callback.WaitForResult(); 6270 rv = callback.WaitForResult();
6269 EXPECT_EQ(OK, rv); 6271 EXPECT_EQ(OK, rv);
6270 6272
6271 const HttpResponseInfo* response = trans->GetResponseInfo(); 6273 const HttpResponseInfo* response = trans->GetResponseInfo();
6272 6274
6273 ASSERT_TRUE(response != NULL); 6275 ASSERT_TRUE(response != NULL);
6274 EXPECT_EQ(100, response->headers->GetContentLength()); 6276 EXPECT_EQ(100, response->headers->GetContentLength());
6275 } 6277 }
6276 6278
6277 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgent) { 6279 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgent) {
6278 HttpRequestInfo request; 6280 HttpRequestInfo request;
6279 request.method = "GET"; 6281 request.method = "GET";
6280 request.url = GURL("http://www.google.com/"); 6282 request.url = GURL("http://www.google.com/");
6281 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 6283 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
6282 "Chromium Ultra Awesome X Edition"); 6284 "Chromium Ultra Awesome X Edition");
6283 6285
6286 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6284 scoped_ptr<HttpTransaction> trans( 6287 scoped_ptr<HttpTransaction> trans(
6285 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6288 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6286 CreateSession(&session_deps_)));
6287 6289
6288 MockWrite data_writes[] = { 6290 MockWrite data_writes[] = {
6289 MockWrite("GET / HTTP/1.1\r\n" 6291 MockWrite("GET / HTTP/1.1\r\n"
6290 "Host: www.google.com\r\n" 6292 "Host: www.google.com\r\n"
6291 "Connection: keep-alive\r\n" 6293 "Connection: keep-alive\r\n"
6292 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), 6294 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"),
6293 }; 6295 };
6294 6296
6295 // Lastly, the server responds with the actual content. 6297 // Lastly, the server responds with the actual content.
6296 MockRead data_reads[] = { 6298 MockRead data_reads[] = {
(...skipping 17 matching lines...) Expand all
6314 } 6316 }
6315 6317
6316 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) { 6318 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) {
6317 HttpRequestInfo request; 6319 HttpRequestInfo request;
6318 request.method = "GET"; 6320 request.method = "GET";
6319 request.url = GURL("https://www.google.com/"); 6321 request.url = GURL("https://www.google.com/");
6320 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 6322 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
6321 "Chromium Ultra Awesome X Edition"); 6323 "Chromium Ultra Awesome X Edition");
6322 6324
6323 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 6325 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
6326 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6324 scoped_ptr<HttpTransaction> trans( 6327 scoped_ptr<HttpTransaction> trans(
6325 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6328 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6326 CreateSession(&session_deps_)));
6327 6329
6328 MockWrite data_writes[] = { 6330 MockWrite data_writes[] = {
6329 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" 6331 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n"
6330 "Host: www.google.com\r\n" 6332 "Host: www.google.com\r\n"
6331 "Proxy-Connection: keep-alive\r\n" 6333 "Proxy-Connection: keep-alive\r\n"
6332 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), 6334 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"),
6333 }; 6335 };
6334 MockRead data_reads[] = { 6336 MockRead data_reads[] = {
6335 // Return an error, so the transaction stops here (this test isn't 6337 // Return an error, so the transaction stops here (this test isn't
6336 // interested in the rest). 6338 // interested in the rest).
(...skipping 16 matching lines...) Expand all
6353 } 6355 }
6354 6356
6355 TEST_P(HttpNetworkTransactionTest, BuildRequest_Referer) { 6357 TEST_P(HttpNetworkTransactionTest, BuildRequest_Referer) {
6356 HttpRequestInfo request; 6358 HttpRequestInfo request;
6357 request.method = "GET"; 6359 request.method = "GET";
6358 request.url = GURL("http://www.google.com/"); 6360 request.url = GURL("http://www.google.com/");
6359 request.load_flags = 0; 6361 request.load_flags = 0;
6360 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer, 6362 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer,
6361 "http://the.previous.site.com/"); 6363 "http://the.previous.site.com/");
6362 6364
6365 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6363 scoped_ptr<HttpTransaction> trans( 6366 scoped_ptr<HttpTransaction> trans(
6364 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6367 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6365 CreateSession(&session_deps_)));
6366 6368
6367 MockWrite data_writes[] = { 6369 MockWrite data_writes[] = {
6368 MockWrite("GET / HTTP/1.1\r\n" 6370 MockWrite("GET / HTTP/1.1\r\n"
6369 "Host: www.google.com\r\n" 6371 "Host: www.google.com\r\n"
6370 "Connection: keep-alive\r\n" 6372 "Connection: keep-alive\r\n"
6371 "Referer: http://the.previous.site.com/\r\n\r\n"), 6373 "Referer: http://the.previous.site.com/\r\n\r\n"),
6372 }; 6374 };
6373 6375
6374 // Lastly, the server responds with the actual content. 6376 // Lastly, the server responds with the actual content.
6375 MockRead data_reads[] = { 6377 MockRead data_reads[] = {
(...skipping 14 matching lines...) Expand all
6390 6392
6391 rv = callback.WaitForResult(); 6393 rv = callback.WaitForResult();
6392 EXPECT_EQ(OK, rv); 6394 EXPECT_EQ(OK, rv);
6393 } 6395 }
6394 6396
6395 TEST_P(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) { 6397 TEST_P(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) {
6396 HttpRequestInfo request; 6398 HttpRequestInfo request;
6397 request.method = "POST"; 6399 request.method = "POST";
6398 request.url = GURL("http://www.google.com/"); 6400 request.url = GURL("http://www.google.com/");
6399 6401
6402 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6400 scoped_ptr<HttpTransaction> trans( 6403 scoped_ptr<HttpTransaction> trans(
6401 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6404 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6402 CreateSession(&session_deps_)));
6403 6405
6404 MockWrite data_writes[] = { 6406 MockWrite data_writes[] = {
6405 MockWrite("POST / HTTP/1.1\r\n" 6407 MockWrite("POST / HTTP/1.1\r\n"
6406 "Host: www.google.com\r\n" 6408 "Host: www.google.com\r\n"
6407 "Connection: keep-alive\r\n" 6409 "Connection: keep-alive\r\n"
6408 "Content-Length: 0\r\n\r\n"), 6410 "Content-Length: 0\r\n\r\n"),
6409 }; 6411 };
6410 6412
6411 // Lastly, the server responds with the actual content. 6413 // Lastly, the server responds with the actual content.
6412 MockRead data_reads[] = { 6414 MockRead data_reads[] = {
(...skipping 14 matching lines...) Expand all
6427 6429
6428 rv = callback.WaitForResult(); 6430 rv = callback.WaitForResult();
6429 EXPECT_EQ(OK, rv); 6431 EXPECT_EQ(OK, rv);
6430 } 6432 }
6431 6433
6432 TEST_P(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) { 6434 TEST_P(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) {
6433 HttpRequestInfo request; 6435 HttpRequestInfo request;
6434 request.method = "PUT"; 6436 request.method = "PUT";
6435 request.url = GURL("http://www.google.com/"); 6437 request.url = GURL("http://www.google.com/");
6436 6438
6439 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6437 scoped_ptr<HttpTransaction> trans( 6440 scoped_ptr<HttpTransaction> trans(
6438 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6441 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6439 CreateSession(&session_deps_)));
6440 6442
6441 MockWrite data_writes[] = { 6443 MockWrite data_writes[] = {
6442 MockWrite("PUT / HTTP/1.1\r\n" 6444 MockWrite("PUT / HTTP/1.1\r\n"
6443 "Host: www.google.com\r\n" 6445 "Host: www.google.com\r\n"
6444 "Connection: keep-alive\r\n" 6446 "Connection: keep-alive\r\n"
6445 "Content-Length: 0\r\n\r\n"), 6447 "Content-Length: 0\r\n\r\n"),
6446 }; 6448 };
6447 6449
6448 // Lastly, the server responds with the actual content. 6450 // Lastly, the server responds with the actual content.
6449 MockRead data_reads[] = { 6451 MockRead data_reads[] = {
(...skipping 14 matching lines...) Expand all
6464 6466
6465 rv = callback.WaitForResult(); 6467 rv = callback.WaitForResult();
6466 EXPECT_EQ(OK, rv); 6468 EXPECT_EQ(OK, rv);
6467 } 6469 }
6468 6470
6469 TEST_P(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) { 6471 TEST_P(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) {
6470 HttpRequestInfo request; 6472 HttpRequestInfo request;
6471 request.method = "HEAD"; 6473 request.method = "HEAD";
6472 request.url = GURL("http://www.google.com/"); 6474 request.url = GURL("http://www.google.com/");
6473 6475
6476 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6474 scoped_ptr<HttpTransaction> trans( 6477 scoped_ptr<HttpTransaction> trans(
6475 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6478 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6476 CreateSession(&session_deps_)));
6477 6479
6478 MockWrite data_writes[] = { 6480 MockWrite data_writes[] = {
6479 MockWrite("HEAD / HTTP/1.1\r\n" 6481 MockWrite("HEAD / HTTP/1.1\r\n"
6480 "Host: www.google.com\r\n" 6482 "Host: www.google.com\r\n"
6481 "Connection: keep-alive\r\n" 6483 "Connection: keep-alive\r\n"
6482 "Content-Length: 0\r\n\r\n"), 6484 "Content-Length: 0\r\n\r\n"),
6483 }; 6485 };
6484 6486
6485 // Lastly, the server responds with the actual content. 6487 // Lastly, the server responds with the actual content.
6486 MockRead data_reads[] = { 6488 MockRead data_reads[] = {
(...skipping 15 matching lines...) Expand all
6502 rv = callback.WaitForResult(); 6504 rv = callback.WaitForResult();
6503 EXPECT_EQ(OK, rv); 6505 EXPECT_EQ(OK, rv);
6504 } 6506 }
6505 6507
6506 TEST_P(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) { 6508 TEST_P(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) {
6507 HttpRequestInfo request; 6509 HttpRequestInfo request;
6508 request.method = "GET"; 6510 request.method = "GET";
6509 request.url = GURL("http://www.google.com/"); 6511 request.url = GURL("http://www.google.com/");
6510 request.load_flags = LOAD_BYPASS_CACHE; 6512 request.load_flags = LOAD_BYPASS_CACHE;
6511 6513
6514 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6512 scoped_ptr<HttpTransaction> trans( 6515 scoped_ptr<HttpTransaction> trans(
6513 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6516 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6514 CreateSession(&session_deps_)));
6515 6517
6516 MockWrite data_writes[] = { 6518 MockWrite data_writes[] = {
6517 MockWrite("GET / HTTP/1.1\r\n" 6519 MockWrite("GET / HTTP/1.1\r\n"
6518 "Host: www.google.com\r\n" 6520 "Host: www.google.com\r\n"
6519 "Connection: keep-alive\r\n" 6521 "Connection: keep-alive\r\n"
6520 "Pragma: no-cache\r\n" 6522 "Pragma: no-cache\r\n"
6521 "Cache-Control: no-cache\r\n\r\n"), 6523 "Cache-Control: no-cache\r\n\r\n"),
6522 }; 6524 };
6523 6525
6524 // Lastly, the server responds with the actual content. 6526 // Lastly, the server responds with the actual content.
(...skipping 17 matching lines...) Expand all
6542 EXPECT_EQ(OK, rv); 6544 EXPECT_EQ(OK, rv);
6543 } 6545 }
6544 6546
6545 TEST_P(HttpNetworkTransactionTest, 6547 TEST_P(HttpNetworkTransactionTest,
6546 BuildRequest_CacheControlValidateCache) { 6548 BuildRequest_CacheControlValidateCache) {
6547 HttpRequestInfo request; 6549 HttpRequestInfo request;
6548 request.method = "GET"; 6550 request.method = "GET";
6549 request.url = GURL("http://www.google.com/"); 6551 request.url = GURL("http://www.google.com/");
6550 request.load_flags = LOAD_VALIDATE_CACHE; 6552 request.load_flags = LOAD_VALIDATE_CACHE;
6551 6553
6554 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6552 scoped_ptr<HttpTransaction> trans( 6555 scoped_ptr<HttpTransaction> trans(
6553 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6556 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6554 CreateSession(&session_deps_)));
6555 6557
6556 MockWrite data_writes[] = { 6558 MockWrite data_writes[] = {
6557 MockWrite("GET / HTTP/1.1\r\n" 6559 MockWrite("GET / HTTP/1.1\r\n"
6558 "Host: www.google.com\r\n" 6560 "Host: www.google.com\r\n"
6559 "Connection: keep-alive\r\n" 6561 "Connection: keep-alive\r\n"
6560 "Cache-Control: max-age=0\r\n\r\n"), 6562 "Cache-Control: max-age=0\r\n\r\n"),
6561 }; 6563 };
6562 6564
6563 // Lastly, the server responds with the actual content. 6565 // Lastly, the server responds with the actual content.
6564 MockRead data_reads[] = { 6566 MockRead data_reads[] = {
(...skipping 15 matching lines...) Expand all
6580 rv = callback.WaitForResult(); 6582 rv = callback.WaitForResult();
6581 EXPECT_EQ(OK, rv); 6583 EXPECT_EQ(OK, rv);
6582 } 6584 }
6583 6585
6584 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) { 6586 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) {
6585 HttpRequestInfo request; 6587 HttpRequestInfo request;
6586 request.method = "GET"; 6588 request.method = "GET";
6587 request.url = GURL("http://www.google.com/"); 6589 request.url = GURL("http://www.google.com/");
6588 request.extra_headers.SetHeader("FooHeader", "Bar"); 6590 request.extra_headers.SetHeader("FooHeader", "Bar");
6589 6591
6592 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6590 scoped_ptr<HttpTransaction> trans( 6593 scoped_ptr<HttpTransaction> trans(
6591 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6594 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6592 CreateSession(&session_deps_)));
6593 6595
6594 MockWrite data_writes[] = { 6596 MockWrite data_writes[] = {
6595 MockWrite("GET / HTTP/1.1\r\n" 6597 MockWrite("GET / HTTP/1.1\r\n"
6596 "Host: www.google.com\r\n" 6598 "Host: www.google.com\r\n"
6597 "Connection: keep-alive\r\n" 6599 "Connection: keep-alive\r\n"
6598 "FooHeader: Bar\r\n\r\n"), 6600 "FooHeader: Bar\r\n\r\n"),
6599 }; 6601 };
6600 6602
6601 // Lastly, the server responds with the actual content. 6603 // Lastly, the server responds with the actual content.
6602 MockRead data_reads[] = { 6604 MockRead data_reads[] = {
(...skipping 17 matching lines...) Expand all
6620 } 6622 }
6621 6623
6622 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) { 6624 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) {
6623 HttpRequestInfo request; 6625 HttpRequestInfo request;
6624 request.method = "GET"; 6626 request.method = "GET";
6625 request.url = GURL("http://www.google.com/"); 6627 request.url = GURL("http://www.google.com/");
6626 request.extra_headers.SetHeader("referer", "www.foo.com"); 6628 request.extra_headers.SetHeader("referer", "www.foo.com");
6627 request.extra_headers.SetHeader("hEllo", "Kitty"); 6629 request.extra_headers.SetHeader("hEllo", "Kitty");
6628 request.extra_headers.SetHeader("FoO", "bar"); 6630 request.extra_headers.SetHeader("FoO", "bar");
6629 6631
6632 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6630 scoped_ptr<HttpTransaction> trans( 6633 scoped_ptr<HttpTransaction> trans(
6631 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6634 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6632 CreateSession(&session_deps_)));
6633 6635
6634 MockWrite data_writes[] = { 6636 MockWrite data_writes[] = {
6635 MockWrite("GET / HTTP/1.1\r\n" 6637 MockWrite("GET / HTTP/1.1\r\n"
6636 "Host: www.google.com\r\n" 6638 "Host: www.google.com\r\n"
6637 "Connection: keep-alive\r\n" 6639 "Connection: keep-alive\r\n"
6638 "referer: www.foo.com\r\n" 6640 "referer: www.foo.com\r\n"
6639 "hEllo: Kitty\r\n" 6641 "hEllo: Kitty\r\n"
6640 "FoO: bar\r\n\r\n"), 6642 "FoO: bar\r\n\r\n"),
6641 }; 6643 };
6642 6644
(...skipping 22 matching lines...) Expand all
6665 HttpRequestInfo request; 6667 HttpRequestInfo request;
6666 request.method = "GET"; 6668 request.method = "GET";
6667 request.url = GURL("http://www.google.com/"); 6669 request.url = GURL("http://www.google.com/");
6668 request.load_flags = 0; 6670 request.load_flags = 0;
6669 6671
6670 session_deps_.proxy_service.reset( 6672 session_deps_.proxy_service.reset(
6671 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080")); 6673 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080"));
6672 CapturingNetLog net_log; 6674 CapturingNetLog net_log;
6673 session_deps_.net_log = &net_log; 6675 session_deps_.net_log = &net_log;
6674 6676
6677 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6675 scoped_ptr<HttpTransaction> trans( 6678 scoped_ptr<HttpTransaction> trans(
6676 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6679 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6677 CreateSession(&session_deps_)));
6678 6680
6679 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; 6681 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
6680 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 6682 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
6681 6683
6682 MockWrite data_writes[] = { 6684 MockWrite data_writes[] = {
6683 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)), 6685 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)),
6684 MockWrite("GET / HTTP/1.1\r\n" 6686 MockWrite("GET / HTTP/1.1\r\n"
6685 "Host: www.google.com\r\n" 6687 "Host: www.google.com\r\n"
6686 "Connection: keep-alive\r\n\r\n") 6688 "Connection: keep-alive\r\n\r\n")
6687 }; 6689 };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6724 HttpRequestInfo request; 6726 HttpRequestInfo request;
6725 request.method = "GET"; 6727 request.method = "GET";
6726 request.url = GURL("https://www.google.com/"); 6728 request.url = GURL("https://www.google.com/");
6727 request.load_flags = 0; 6729 request.load_flags = 0;
6728 6730
6729 session_deps_.proxy_service.reset( 6731 session_deps_.proxy_service.reset(
6730 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080")); 6732 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080"));
6731 CapturingNetLog net_log; 6733 CapturingNetLog net_log;
6732 session_deps_.net_log = &net_log; 6734 session_deps_.net_log = &net_log;
6733 6735
6736 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6734 scoped_ptr<HttpTransaction> trans( 6737 scoped_ptr<HttpTransaction> trans(
6735 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6738 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6736 CreateSession(&session_deps_)));
6737 6739
6738 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 }; 6740 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 };
6739 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 6741 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
6740 6742
6741 MockWrite data_writes[] = { 6743 MockWrite data_writes[] = {
6742 MockWrite(ASYNC, reinterpret_cast<char*>(write_buffer), 6744 MockWrite(ASYNC, reinterpret_cast<char*>(write_buffer),
6743 arraysize(write_buffer)), 6745 arraysize(write_buffer)),
6744 MockWrite("GET / HTTP/1.1\r\n" 6746 MockWrite("GET / HTTP/1.1\r\n"
6745 "Host: www.google.com\r\n" 6747 "Host: www.google.com\r\n"
6746 "Connection: keep-alive\r\n\r\n") 6748 "Connection: keep-alive\r\n\r\n")
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6788 HttpRequestInfo request; 6790 HttpRequestInfo request;
6789 request.method = "GET"; 6791 request.method = "GET";
6790 request.url = GURL("http://www.google.com/"); 6792 request.url = GURL("http://www.google.com/");
6791 request.load_flags = 0; 6793 request.load_flags = 0;
6792 6794
6793 session_deps_.proxy_service.reset( 6795 session_deps_.proxy_service.reset(
6794 ProxyService::CreateFixed("socks4://myproxy:1080")); 6796 ProxyService::CreateFixed("socks4://myproxy:1080"));
6795 CapturingNetLog net_log; 6797 CapturingNetLog net_log;
6796 session_deps_.net_log = &net_log; 6798 session_deps_.net_log = &net_log;
6797 6799
6800 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6798 scoped_ptr<HttpTransaction> trans( 6801 scoped_ptr<HttpTransaction> trans(
6799 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6802 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6800 CreateSession(&session_deps_)));
6801 6803
6802 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; 6804 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
6803 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 6805 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
6804 6806
6805 MockWrite data_writes[] = { 6807 MockWrite data_writes[] = {
6806 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)), 6808 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)),
6807 MockWrite("GET / HTTP/1.1\r\n" 6809 MockWrite("GET / HTTP/1.1\r\n"
6808 "Host: www.google.com\r\n" 6810 "Host: www.google.com\r\n"
6809 "Connection: keep-alive\r\n\r\n") 6811 "Connection: keep-alive\r\n\r\n")
6810 }; 6812 };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6847 HttpRequestInfo request; 6849 HttpRequestInfo request;
6848 request.method = "GET"; 6850 request.method = "GET";
6849 request.url = GURL("http://www.google.com/"); 6851 request.url = GURL("http://www.google.com/");
6850 request.load_flags = 0; 6852 request.load_flags = 0;
6851 6853
6852 session_deps_.proxy_service.reset( 6854 session_deps_.proxy_service.reset(
6853 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080")); 6855 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080"));
6854 CapturingNetLog net_log; 6856 CapturingNetLog net_log;
6855 session_deps_.net_log = &net_log; 6857 session_deps_.net_log = &net_log;
6856 6858
6859 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6857 scoped_ptr<HttpTransaction> trans( 6860 scoped_ptr<HttpTransaction> trans(
6858 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6861 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6859 CreateSession(&session_deps_)));
6860 6862
6861 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 6863 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
6862 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 6864 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
6863 const char kSOCKS5OkRequest[] = { 6865 const char kSOCKS5OkRequest[] = {
6864 0x05, // Version 6866 0x05, // Version
6865 0x01, // Command (CONNECT) 6867 0x01, // Command (CONNECT)
6866 0x00, // Reserved. 6868 0x00, // Reserved.
6867 0x03, // Address type (DOMAINNAME). 6869 0x03, // Address type (DOMAINNAME).
6868 0x0E, // Length of domain (14) 6870 0x0E, // Length of domain (14)
6869 // Domain string: 6871 // Domain string:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6920 HttpRequestInfo request; 6922 HttpRequestInfo request;
6921 request.method = "GET"; 6923 request.method = "GET";
6922 request.url = GURL("https://www.google.com/"); 6924 request.url = GURL("https://www.google.com/");
6923 request.load_flags = 0; 6925 request.load_flags = 0;
6924 6926
6925 session_deps_.proxy_service.reset( 6927 session_deps_.proxy_service.reset(
6926 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080")); 6928 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080"));
6927 CapturingNetLog net_log; 6929 CapturingNetLog net_log;
6928 session_deps_.net_log = &net_log; 6930 session_deps_.net_log = &net_log;
6929 6931
6932 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6930 scoped_ptr<HttpTransaction> trans( 6933 scoped_ptr<HttpTransaction> trans(
6931 new HttpNetworkTransaction(DEFAULT_PRIORITY, 6934 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
6932 CreateSession(&session_deps_)));
6933 6935
6934 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 6936 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
6935 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 6937 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
6936 const unsigned char kSOCKS5OkRequest[] = { 6938 const unsigned char kSOCKS5OkRequest[] = {
6937 0x05, // Version 6939 0x05, // Version
6938 0x01, // Command (CONNECT) 6940 0x01, // Command (CONNECT)
6939 0x00, // Reserved. 6941 0x00, // Reserved.
6940 0x03, // Address type (DOMAINNAME). 6942 0x03, // Address type (DOMAINNAME).
6941 0x0E, // Length of domain (14) 6943 0x0E, // Length of domain (14)
6942 // Domain string: 6944 // Domain string:
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
7248 request.method = "GET"; 7250 request.method = "GET";
7249 request.url = GURL("http://www.google.com/"); 7251 request.url = GURL("http://www.google.com/");
7250 7252
7251 session_deps_.proxy_service.reset( 7253 session_deps_.proxy_service.reset(
7252 ProxyService::CreateFixed("myproxy:70;foobar:80")); 7254 ProxyService::CreateFixed("myproxy:70;foobar:80"));
7253 7255
7254 // This simulates failure resolving all hostnames; that means we will fail 7256 // This simulates failure resolving all hostnames; that means we will fail
7255 // connecting to both proxies (myproxy:70 and foobar:80). 7257 // connecting to both proxies (myproxy:70 and foobar:80).
7256 session_deps_.host_resolver->rules()->AddSimulatedFailure("*"); 7258 session_deps_.host_resolver->rules()->AddSimulatedFailure("*");
7257 7259
7260 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7258 scoped_ptr<HttpTransaction> trans( 7261 scoped_ptr<HttpTransaction> trans(
7259 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7262 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7260 CreateSession(&session_deps_)));
7261 7263
7262 TestCompletionCallback callback; 7264 TestCompletionCallback callback;
7263 7265
7264 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 7266 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
7265 EXPECT_EQ(ERR_IO_PENDING, rv); 7267 EXPECT_EQ(ERR_IO_PENDING, rv);
7266 7268
7267 rv = callback.WaitForResult(); 7269 rv = callback.WaitForResult();
7268 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); 7270 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv);
7269 } 7271 }
7270 7272
7271 // Base test to make sure that when the load flags for a request specify to 7273 // Base test to make sure that when the load flags for a request specify to
7272 // bypass the cache, the DNS cache is not used. 7274 // bypass the cache, the DNS cache is not used.
7273 void HttpNetworkTransactionTest::BypassHostCacheOnRefreshHelper( 7275 void HttpNetworkTransactionTest::BypassHostCacheOnRefreshHelper(
7274 int load_flags) { 7276 int load_flags) {
7275 // Issue a request, asking to bypass the cache(s). 7277 // Issue a request, asking to bypass the cache(s).
7276 HttpRequestInfo request; 7278 HttpRequestInfo request;
7277 request.method = "GET"; 7279 request.method = "GET";
7278 request.load_flags = load_flags; 7280 request.load_flags = load_flags;
7279 request.url = GURL("http://www.google.com/"); 7281 request.url = GURL("http://www.google.com/");
7280 7282
7281 // Select a host resolver that does caching. 7283 // Select a host resolver that does caching.
7282 session_deps_.host_resolver.reset(new MockCachingHostResolver); 7284 session_deps_.host_resolver.reset(new MockCachingHostResolver);
7283 7285
7284 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(DEFAULT_PRIORITY, 7286 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7285 CreateSession(&session_deps_))); 7287 scoped_ptr<HttpTransaction> trans(
7288 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7286 7289
7287 // Warm up the host cache so it has an entry for "www.google.com". 7290 // Warm up the host cache so it has an entry for "www.google.com".
7288 AddressList addrlist; 7291 AddressList addrlist;
7289 TestCompletionCallback callback; 7292 TestCompletionCallback callback;
7290 int rv = session_deps_.host_resolver->Resolve( 7293 int rv = session_deps_.host_resolver->Resolve(
7291 HostResolver::RequestInfo(HostPortPair("www.google.com", 80)), 7294 HostResolver::RequestInfo(HostPortPair("www.google.com", 80)),
7292 DEFAULT_PRIORITY, 7295 DEFAULT_PRIORITY,
7293 &addrlist, 7296 &addrlist,
7294 callback.callback(), 7297 callback.callback(),
7295 NULL, 7298 NULL,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7351 HttpRequestInfo request; 7354 HttpRequestInfo request;
7352 request.method = "GET"; 7355 request.method = "GET";
7353 request.url = GURL("http://www.foo.com/"); 7356 request.url = GURL("http://www.foo.com/");
7354 request.load_flags = 0; 7357 request.load_flags = 0;
7355 7358
7356 MockWrite write_failure[] = { 7359 MockWrite write_failure[] = {
7357 MockWrite(ASYNC, ERR_CONNECTION_RESET), 7360 MockWrite(ASYNC, ERR_CONNECTION_RESET),
7358 }; 7361 };
7359 StaticSocketDataProvider data(NULL, 0, 7362 StaticSocketDataProvider data(NULL, 0,
7360 write_failure, arraysize(write_failure)); 7363 write_failure, arraysize(write_failure));
7361 session_deps_.socket_factory->AddSocketDataProvider(&data); 7364 session_deps_.socket_factory->AddSocketDataProvider(&data);
wtc 2013/10/15 23:08:21 Nit: it may be safer to move line 7352 after this
wtc 2013/10/16 15:04:32 I took another look at this. I think your change i
mmenke 2013/10/16 15:58:44 Order changed. I agree with you that the ordering
7362 7365
7363 TestCompletionCallback callback; 7366 TestCompletionCallback callback;
7364 7367
7365 scoped_ptr<HttpTransaction> trans( 7368 scoped_ptr<HttpTransaction> trans(
7366 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7369 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7367 CreateSession(&session_deps_)));
7368 7370
7369 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 7371 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
7370 EXPECT_EQ(ERR_IO_PENDING, rv); 7372 EXPECT_EQ(ERR_IO_PENDING, rv);
7371 7373
7372 rv = callback.WaitForResult(); 7374 rv = callback.WaitForResult();
7373 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 7375 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
7374 } 7376 }
7375 7377
7376 // Check that a connection closed after the start of the headers finishes ok. 7378 // Check that a connection closed after the start of the headers finishes ok.
7377 TEST_P(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { 7379 TEST_P(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) {
7378 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7380 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7379 7381
7380 HttpRequestInfo request; 7382 HttpRequestInfo request;
7381 request.method = "GET"; 7383 request.method = "GET";
7382 request.url = GURL("http://www.foo.com/"); 7384 request.url = GURL("http://www.foo.com/");
7383 request.load_flags = 0; 7385 request.load_flags = 0;
7384 7386
7385 MockRead data_reads[] = { 7387 MockRead data_reads[] = {
7386 MockRead("HTTP/1."), 7388 MockRead("HTTP/1."),
7387 MockRead(SYNCHRONOUS, OK), 7389 MockRead(SYNCHRONOUS, OK),
7388 }; 7390 };
7389 7391
7390 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 7392 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
7391 session_deps_.socket_factory->AddSocketDataProvider(&data); 7393 session_deps_.socket_factory->AddSocketDataProvider(&data);
wtc 2013/10/15 23:08:21 Nit: same here. Consider creating |session| after
mmenke 2013/10/16 15:58:44 Done.
7392 7394
7393 TestCompletionCallback callback; 7395 TestCompletionCallback callback;
7394 7396
7395 scoped_ptr<HttpTransaction> trans( 7397 scoped_ptr<HttpTransaction> trans(
7396 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7398 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7397 CreateSession(&session_deps_)));
7398 7399
7399 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 7400 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
7400 EXPECT_EQ(ERR_IO_PENDING, rv); 7401 EXPECT_EQ(ERR_IO_PENDING, rv);
7401 7402
7402 rv = callback.WaitForResult(); 7403 rv = callback.WaitForResult();
7403 EXPECT_EQ(OK, rv); 7404 EXPECT_EQ(OK, rv);
7404 7405
7405 const HttpResponseInfo* response = trans->GetResponseInfo(); 7406 const HttpResponseInfo* response = trans->GetResponseInfo();
7406 ASSERT_TRUE(response != NULL); 7407 ASSERT_TRUE(response != NULL);
7407 7408
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
7511 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0); 7512 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0);
7512 SSLSocketDataProvider ssl(ASYNC, OK); 7513 SSLSocketDataProvider ssl(ASYNC, OK);
7513 7514
7514 session_deps_.socket_factory->AddSocketDataProvider(&data); 7515 session_deps_.socket_factory->AddSocketDataProvider(&data);
7515 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 7516 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
7516 7517
7517 TestCompletionCallback callback; 7518 TestCompletionCallback callback;
7518 7519
7519 session_deps_.socket_factory->ResetNextMockIndexes(); 7520 session_deps_.socket_factory->ResetNextMockIndexes();
7520 7521
7522 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7521 scoped_ptr<HttpTransaction> trans( 7523 scoped_ptr<HttpTransaction> trans(
7522 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7524 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7523 CreateSession(&session_deps_)));
7524 7525
7525 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 7526 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
7526 EXPECT_EQ(ERR_IO_PENDING, rv); 7527 EXPECT_EQ(ERR_IO_PENDING, rv);
7527 7528
7528 rv = callback.WaitForResult(); 7529 rv = callback.WaitForResult();
7529 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 7530 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
7530 } 7531 }
7531 7532
7532 TEST_P(HttpNetworkTransactionTest, LargeContentLengthThenClose) { 7533 TEST_P(HttpNetworkTransactionTest, LargeContentLengthThenClose) {
7533 HttpRequestInfo request; 7534 HttpRequestInfo request;
7534 request.method = "GET"; 7535 request.method = "GET";
7535 request.url = GURL("http://www.google.com/"); 7536 request.url = GURL("http://www.google.com/");
7536 request.load_flags = 0; 7537 request.load_flags = 0;
7537 7538
7539 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7538 scoped_ptr<HttpTransaction> trans( 7540 scoped_ptr<HttpTransaction> trans(
7539 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7541 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7540 CreateSession(&session_deps_)));
7541 7542
7542 MockRead data_reads[] = { 7543 MockRead data_reads[] = {
7543 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), 7544 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"),
7544 MockRead(SYNCHRONOUS, OK), 7545 MockRead(SYNCHRONOUS, OK),
7545 }; 7546 };
7546 7547
7547 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 7548 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
7548 session_deps_.socket_factory->AddSocketDataProvider(&data); 7549 session_deps_.socket_factory->AddSocketDataProvider(&data);
7549 7550
7550 TestCompletionCallback callback; 7551 TestCompletionCallback callback;
(...skipping 29 matching lines...) Expand all
7580 kuint64max, 7581 kuint64max,
7581 base::Time())); 7582 base::Time()));
7582 UploadDataStream upload_data_stream(element_readers.Pass(), 0); 7583 UploadDataStream upload_data_stream(element_readers.Pass(), 0);
7583 7584
7584 HttpRequestInfo request; 7585 HttpRequestInfo request;
7585 request.method = "POST"; 7586 request.method = "POST";
7586 request.url = GURL("http://www.google.com/upload"); 7587 request.url = GURL("http://www.google.com/upload");
7587 request.upload_data_stream = &upload_data_stream; 7588 request.upload_data_stream = &upload_data_stream;
7588 request.load_flags = 0; 7589 request.load_flags = 0;
7589 7590
7591 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7590 scoped_ptr<HttpTransaction> trans( 7592 scoped_ptr<HttpTransaction> trans(
7591 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7593 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7592 CreateSession(&session_deps_)));
7593 7594
7594 MockRead data_reads[] = { 7595 MockRead data_reads[] = {
7595 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 7596 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
7596 MockRead("hello world"), 7597 MockRead("hello world"),
7597 MockRead(SYNCHRONOUS, OK), 7598 MockRead(SYNCHRONOUS, OK),
7598 }; 7599 };
7599 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 7600 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
7600 session_deps_.socket_factory->AddSocketDataProvider(&data); 7601 session_deps_.socket_factory->AddSocketDataProvider(&data);
7601 7602
7602 TestCompletionCallback callback; 7603 TestCompletionCallback callback;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
7639 UploadDataStream upload_data_stream(element_readers.Pass(), 0); 7640 UploadDataStream upload_data_stream(element_readers.Pass(), 0);
7640 7641
7641 HttpRequestInfo request; 7642 HttpRequestInfo request;
7642 request.method = "POST"; 7643 request.method = "POST";
7643 request.url = GURL("http://www.google.com/upload"); 7644 request.url = GURL("http://www.google.com/upload");
7644 request.upload_data_stream = &upload_data_stream; 7645 request.upload_data_stream = &upload_data_stream;
7645 request.load_flags = 0; 7646 request.load_flags = 0;
7646 7647
7647 // If we try to upload an unreadable file, the network stack should report 7648 // If we try to upload an unreadable file, the network stack should report
7648 // the file size as zero and upload zero bytes for that file. 7649 // the file size as zero and upload zero bytes for that file.
7650 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7649 scoped_ptr<HttpTransaction> trans( 7651 scoped_ptr<HttpTransaction> trans(
7650 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7652 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7651 CreateSession(&session_deps_)));
7652 7653
7653 MockRead data_reads[] = { 7654 MockRead data_reads[] = {
7654 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 7655 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
7655 MockRead(SYNCHRONOUS, OK), 7656 MockRead(SYNCHRONOUS, OK),
7656 }; 7657 };
7657 MockWrite data_writes[] = { 7658 MockWrite data_writes[] = {
7658 MockWrite("POST /upload HTTP/1.1\r\n" 7659 MockWrite("POST /upload HTTP/1.1\r\n"
7659 "Host: www.google.com\r\n" 7660 "Host: www.google.com\r\n"
7660 "Connection: keep-alive\r\n" 7661 "Connection: keep-alive\r\n"
7661 "Content-Length: 0\r\n\r\n"), 7662 "Content-Length: 0\r\n\r\n"),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7697 kuint64max, 7698 kuint64max,
7698 base::Time())); 7699 base::Time()));
7699 UploadDataStream upload_data_stream(element_readers.Pass(), 0); 7700 UploadDataStream upload_data_stream(element_readers.Pass(), 0);
7700 7701
7701 HttpRequestInfo request; 7702 HttpRequestInfo request;
7702 request.method = "POST"; 7703 request.method = "POST";
7703 request.url = GURL("http://www.google.com/upload"); 7704 request.url = GURL("http://www.google.com/upload");
7704 request.upload_data_stream = &upload_data_stream; 7705 request.upload_data_stream = &upload_data_stream;
7705 request.load_flags = 0; 7706 request.load_flags = 0;
7706 7707
7708 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7707 scoped_ptr<HttpTransaction> trans( 7709 scoped_ptr<HttpTransaction> trans(
7708 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7710 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7709 CreateSession(&session_deps_)));
7710 7711
7711 MockRead data_reads[] = { 7712 MockRead data_reads[] = {
7712 MockRead("HTTP/1.1 401 Unauthorized\r\n"), 7713 MockRead("HTTP/1.1 401 Unauthorized\r\n"),
7713 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 7714 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
7714 MockRead("Content-Length: 0\r\n\r\n"), // No response body. 7715 MockRead("Content-Length: 0\r\n\r\n"), // No response body.
7715 7716
7716 MockRead("HTTP/1.1 200 OK\r\n"), 7717 MockRead("HTTP/1.1 200 OK\r\n"),
7717 MockRead("Content-Length: 0\r\n\r\n"), 7718 MockRead("Content-Length: 0\r\n\r\n"),
7718 MockRead(SYNCHRONOUS, OK), 7719 MockRead(SYNCHRONOUS, OK),
7719 }; 7720 };
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
7801 ScopedVector<UploadElementReader> element_readers; 7802 ScopedVector<UploadElementReader> element_readers;
7802 element_readers.push_back(fake_reader); 7803 element_readers.push_back(fake_reader);
7803 UploadDataStream upload_data_stream(element_readers.Pass(), 0); 7804 UploadDataStream upload_data_stream(element_readers.Pass(), 0);
7804 7805
7805 HttpRequestInfo request; 7806 HttpRequestInfo request;
7806 request.method = "POST"; 7807 request.method = "POST";
7807 request.url = GURL("http://www.google.com/upload"); 7808 request.url = GURL("http://www.google.com/upload");
7808 request.upload_data_stream = &upload_data_stream; 7809 request.upload_data_stream = &upload_data_stream;
7809 request.load_flags = 0; 7810 request.load_flags = 0;
7810 7811
7812 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7811 scoped_ptr<HttpTransaction> trans( 7813 scoped_ptr<HttpTransaction> trans(
7812 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7814 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7813 CreateSession(&session_deps_)));
7814 7815
7815 StaticSocketDataProvider data; 7816 StaticSocketDataProvider data;
7816 session_deps_.socket_factory->AddSocketDataProvider(&data); 7817 session_deps_.socket_factory->AddSocketDataProvider(&data);
7817 7818
7818 TestCompletionCallback callback; 7819 TestCompletionCallback callback;
7819 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 7820 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
7820 EXPECT_EQ(ERR_IO_PENDING, rv); 7821 EXPECT_EQ(ERR_IO_PENDING, rv);
7821 base::MessageLoop::current()->RunUntilIdle(); 7822 base::MessageLoop::current()->RunUntilIdle();
7822 7823
7823 // Transaction is pending on request body initialization. 7824 // Transaction is pending on request body initialization.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
7905 data_writes3, arraysize(data_writes3)); 7906 data_writes3, arraysize(data_writes3));
7906 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4), 7907 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4),
7907 data_writes4, arraysize(data_writes4)); 7908 data_writes4, arraysize(data_writes4));
7908 session_deps_.socket_factory->AddSocketDataProvider(&data1); 7909 session_deps_.socket_factory->AddSocketDataProvider(&data1);
7909 session_deps_.socket_factory->AddSocketDataProvider(&data2); 7910 session_deps_.socket_factory->AddSocketDataProvider(&data2);
7910 session_deps_.socket_factory->AddSocketDataProvider(&data3); 7911 session_deps_.socket_factory->AddSocketDataProvider(&data3);
7911 session_deps_.socket_factory->AddSocketDataProvider(&data4); 7912 session_deps_.socket_factory->AddSocketDataProvider(&data4);
7912 7913
7913 TestCompletionCallback callback1; 7914 TestCompletionCallback callback1;
7914 7915
7916 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7915 scoped_ptr<HttpTransaction> trans( 7917 scoped_ptr<HttpTransaction> trans(
7916 new HttpNetworkTransaction(DEFAULT_PRIORITY, 7918 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
7917 CreateSession(&session_deps_)));
7918 7919
7919 // Issue the first request with Authorize headers. There should be a 7920 // Issue the first request with Authorize headers. There should be a
7920 // password prompt for first_realm waiting to be filled in after the 7921 // password prompt for first_realm waiting to be filled in after the
7921 // transaction completes. 7922 // transaction completes.
7922 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); 7923 int rv = trans->Start(&request, callback1.callback(), BoundNetLog());
7923 EXPECT_EQ(ERR_IO_PENDING, rv); 7924 EXPECT_EQ(ERR_IO_PENDING, rv);
7924 rv = callback1.WaitForResult(); 7925 rv = callback1.WaitForResult();
7925 EXPECT_EQ(OK, rv); 7926 EXPECT_EQ(OK, rv);
7926 const HttpResponseInfo* response = trans->GetResponseInfo(); 7927 const HttpResponseInfo* response = trans->GetResponseInfo();
7927 ASSERT_TRUE(response != NULL); 7928 ASSERT_TRUE(response != NULL);
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
9280 } else { 9281 } else {
9281 session_deps_.proxy_service.reset(ProxyService::CreateDirect()); 9282 session_deps_.proxy_service.reset(ProxyService::CreateDirect());
9282 } 9283 }
9283 9284
9284 HttpRequestInfo request; 9285 HttpRequestInfo request;
9285 request.method = "GET"; 9286 request.method = "GET";
9286 request.url = GURL(test_config.server_url); 9287 request.url = GURL(test_config.server_url);
9287 request.load_flags = 0; 9288 request.load_flags = 0;
9288 9289
9289 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9290 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9290 HttpNetworkTransaction trans( 9291 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session);
9291 DEFAULT_PRIORITY, CreateSession(&session_deps_));
9292 9292
9293 for (int round = 0; round < test_config.num_auth_rounds; ++round) { 9293 for (int round = 0; round < test_config.num_auth_rounds; ++round) {
9294 const TestRound& read_write_round = test_config.rounds[round]; 9294 const TestRound& read_write_round = test_config.rounds[round];
9295 9295
9296 // Set up expected reads and writes. 9296 // Set up expected reads and writes.
9297 MockRead reads[2]; 9297 MockRead reads[2];
9298 reads[0] = read_write_round.read; 9298 reads[0] = read_write_round.read;
9299 size_t length_reads = 1; 9299 size_t length_reads = 1;
9300 if (read_write_round.extra_read) { 9300 if (read_write_round.extra_read) {
9301 reads[1] = *read_write_round.extra_read; 9301 reads[1] = *read_write_round.extra_read;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
9836 MockRead(SYNCHRONOUS, "hello world"), 9836 MockRead(SYNCHRONOUS, "hello world"),
9837 MockRead(SYNCHRONOUS, OK), 9837 MockRead(SYNCHRONOUS, OK),
9838 }; 9838 };
9839 9839
9840 HttpRequestInfo request; 9840 HttpRequestInfo request;
9841 request.method = "GET"; 9841 request.method = "GET";
9842 request.url = GURL("http://www.google.com/"); 9842 request.url = GURL("http://www.google.com/");
9843 request.load_flags = 0; 9843 request.load_flags = 0;
9844 9844
9845 session_deps_.host_resolver->set_synchronous_mode(true); 9845 session_deps_.host_resolver->set_synchronous_mode(true);
9846 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9846 scoped_ptr<HttpTransaction> trans( 9847 scoped_ptr<HttpTransaction> trans(
9847 new HttpNetworkTransaction(DEFAULT_PRIORITY, 9848 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
9848 CreateSession(&session_deps_)));
9849 9849
9850 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 9850 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
9851 data.set_connect_data(mock_connect); 9851 data.set_connect_data(mock_connect);
9852 session_deps_.socket_factory->AddSocketDataProvider(&data); 9852 session_deps_.socket_factory->AddSocketDataProvider(&data);
9853 9853
9854 TestCompletionCallback callback; 9854 TestCompletionCallback callback;
9855 9855
9856 CapturingBoundNetLog log; 9856 CapturingBoundNetLog log;
9857 int rv = trans->Start(&request, callback.callback(), log.bound()); 9857 int rv = trans->Start(&request, callback.callback(), log.bound());
9858 EXPECT_EQ(ERR_IO_PENDING, rv); 9858 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
11518 EXPECT_FALSE( 11518 EXPECT_FALSE(
11519 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); 11519 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b));
11520 } 11520 }
11521 11521
11522 TEST_P(HttpNetworkTransactionTest, HttpSyncConnectError) { 11522 TEST_P(HttpNetworkTransactionTest, HttpSyncConnectError) {
11523 HttpRequestInfo request; 11523 HttpRequestInfo request;
11524 request.method = "GET"; 11524 request.method = "GET";
11525 request.url = GURL("http://www.google.com/"); 11525 request.url = GURL("http://www.google.com/");
11526 request.load_flags = 0; 11526 request.load_flags = 0;
11527 11527
11528 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11528 scoped_ptr<HttpTransaction> trans( 11529 scoped_ptr<HttpTransaction> trans(
11529 new HttpNetworkTransaction(DEFAULT_PRIORITY, 11530 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
11530 CreateSession(&session_deps_)));
11531 11531
11532 MockConnect mock_connect(SYNCHRONOUS, ERR_CONNECTION_REFUSED); 11532 MockConnect mock_connect(SYNCHRONOUS, ERR_CONNECTION_REFUSED);
11533 StaticSocketDataProvider data; 11533 StaticSocketDataProvider data;
11534 data.set_connect_data(mock_connect); 11534 data.set_connect_data(mock_connect);
11535 session_deps_.socket_factory->AddSocketDataProvider(&data); 11535 session_deps_.socket_factory->AddSocketDataProvider(&data);
11536 11536
11537 TestCompletionCallback callback; 11537 TestCompletionCallback callback;
11538 11538
11539 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 11539 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
11540 EXPECT_EQ(ERR_IO_PENDING, rv); 11540 EXPECT_EQ(ERR_IO_PENDING, rv);
11541 11541
11542 rv = callback.WaitForResult(); 11542 rv = callback.WaitForResult();
11543 EXPECT_EQ(ERR_CONNECTION_REFUSED, rv); 11543 EXPECT_EQ(ERR_CONNECTION_REFUSED, rv);
11544 11544
11545 EXPECT_EQ(NULL, trans->GetResponseInfo()); 11545 EXPECT_EQ(NULL, trans->GetResponseInfo());
11546 11546
11547 // We don't care whether this succeeds or fails, but it shouldn't crash. 11547 // We don't care whether this succeeds or fails, but it shouldn't crash.
11548 HttpRequestHeaders request_headers; 11548 HttpRequestHeaders request_headers;
11549 trans->GetFullRequestHeaders(&request_headers); 11549 trans->GetFullRequestHeaders(&request_headers);
11550 } 11550 }
11551 11551
11552 TEST_P(HttpNetworkTransactionTest, HttpAsyncConnectError) { 11552 TEST_P(HttpNetworkTransactionTest, HttpAsyncConnectError) {
11553 HttpRequestInfo request; 11553 HttpRequestInfo request;
11554 request.method = "GET"; 11554 request.method = "GET";
11555 request.url = GURL("http://www.google.com/"); 11555 request.url = GURL("http://www.google.com/");
11556 request.load_flags = 0; 11556 request.load_flags = 0;
11557 11557
11558 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11558 scoped_ptr<HttpTransaction> trans( 11559 scoped_ptr<HttpTransaction> trans(
11559 new HttpNetworkTransaction(DEFAULT_PRIORITY, 11560 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
11560 CreateSession(&session_deps_)));
11561 11561
11562 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 11562 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
11563 StaticSocketDataProvider data; 11563 StaticSocketDataProvider data;
11564 data.set_connect_data(mock_connect); 11564 data.set_connect_data(mock_connect);
11565 session_deps_.socket_factory->AddSocketDataProvider(&data); 11565 session_deps_.socket_factory->AddSocketDataProvider(&data);
11566 11566
11567 TestCompletionCallback callback; 11567 TestCompletionCallback callback;
11568 11568
11569 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 11569 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
11570 EXPECT_EQ(ERR_IO_PENDING, rv); 11570 EXPECT_EQ(ERR_IO_PENDING, rv);
11571 11571
11572 rv = callback.WaitForResult(); 11572 rv = callback.WaitForResult();
11573 EXPECT_EQ(ERR_CONNECTION_REFUSED, rv); 11573 EXPECT_EQ(ERR_CONNECTION_REFUSED, rv);
11574 11574
11575 EXPECT_EQ(NULL, trans->GetResponseInfo()); 11575 EXPECT_EQ(NULL, trans->GetResponseInfo());
11576 11576
11577 // We don't care whether this succeeds or fails, but it shouldn't crash. 11577 // We don't care whether this succeeds or fails, but it shouldn't crash.
11578 HttpRequestHeaders request_headers; 11578 HttpRequestHeaders request_headers;
11579 trans->GetFullRequestHeaders(&request_headers); 11579 trans->GetFullRequestHeaders(&request_headers);
11580 } 11580 }
11581 11581
11582 TEST_P(HttpNetworkTransactionTest, HttpSyncWriteError) { 11582 TEST_P(HttpNetworkTransactionTest, HttpSyncWriteError) {
11583 HttpRequestInfo request; 11583 HttpRequestInfo request;
11584 request.method = "GET"; 11584 request.method = "GET";
11585 request.url = GURL("http://www.google.com/"); 11585 request.url = GURL("http://www.google.com/");
11586 request.load_flags = 0; 11586 request.load_flags = 0;
11587 11587
11588 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11588 scoped_ptr<HttpTransaction> trans( 11589 scoped_ptr<HttpTransaction> trans(
11589 new HttpNetworkTransaction(DEFAULT_PRIORITY, 11590 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
11590 CreateSession(&session_deps_)));
11591 11591
11592 MockWrite data_writes[] = { 11592 MockWrite data_writes[] = {
11593 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 11593 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
11594 }; 11594 };
11595 MockRead data_reads[] = { 11595 MockRead data_reads[] = {
11596 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. 11596 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached.
11597 }; 11597 };
11598 11598
11599 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 11599 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
11600 data_writes, arraysize(data_writes)); 11600 data_writes, arraysize(data_writes));
(...skipping 13 matching lines...) Expand all
11614 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); 11614 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
11615 EXPECT_TRUE(request_headers.HasHeader("Host")); 11615 EXPECT_TRUE(request_headers.HasHeader("Host"));
11616 } 11616 }
11617 11617
11618 TEST_P(HttpNetworkTransactionTest, HttpAsyncWriteError) { 11618 TEST_P(HttpNetworkTransactionTest, HttpAsyncWriteError) {
11619 HttpRequestInfo request; 11619 HttpRequestInfo request;
11620 request.method = "GET"; 11620 request.method = "GET";
11621 request.url = GURL("http://www.google.com/"); 11621 request.url = GURL("http://www.google.com/");
11622 request.load_flags = 0; 11622 request.load_flags = 0;
11623 11623
11624 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11624 scoped_ptr<HttpTransaction> trans( 11625 scoped_ptr<HttpTransaction> trans(
11625 new HttpNetworkTransaction(DEFAULT_PRIORITY, 11626 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
11626 CreateSession(&session_deps_)));
11627 11627
11628 MockWrite data_writes[] = { 11628 MockWrite data_writes[] = {
11629 MockWrite(ASYNC, ERR_CONNECTION_RESET), 11629 MockWrite(ASYNC, ERR_CONNECTION_RESET),
11630 }; 11630 };
11631 MockRead data_reads[] = { 11631 MockRead data_reads[] = {
11632 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. 11632 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached.
11633 }; 11633 };
11634 11634
11635 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 11635 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
11636 data_writes, arraysize(data_writes)); 11636 data_writes, arraysize(data_writes));
(...skipping 13 matching lines...) Expand all
11650 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); 11650 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
11651 EXPECT_TRUE(request_headers.HasHeader("Host")); 11651 EXPECT_TRUE(request_headers.HasHeader("Host"));
11652 } 11652 }
11653 11653
11654 TEST_P(HttpNetworkTransactionTest, HttpSyncReadError) { 11654 TEST_P(HttpNetworkTransactionTest, HttpSyncReadError) {
11655 HttpRequestInfo request; 11655 HttpRequestInfo request;
11656 request.method = "GET"; 11656 request.method = "GET";
11657 request.url = GURL("http://www.google.com/"); 11657 request.url = GURL("http://www.google.com/");
11658 request.load_flags = 0; 11658 request.load_flags = 0;
11659 11659
11660 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11660 scoped_ptr<HttpTransaction> trans( 11661 scoped_ptr<HttpTransaction> trans(
11661 new HttpNetworkTransaction(DEFAULT_PRIORITY, 11662 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
11662 CreateSession(&session_deps_)));
11663 11663
11664 MockWrite data_writes[] = { 11664 MockWrite data_writes[] = {
11665 MockWrite("GET / HTTP/1.1\r\n" 11665 MockWrite("GET / HTTP/1.1\r\n"
11666 "Host: www.google.com\r\n" 11666 "Host: www.google.com\r\n"
11667 "Connection: keep-alive\r\n\r\n"), 11667 "Connection: keep-alive\r\n\r\n"),
11668 }; 11668 };
11669 MockRead data_reads[] = { 11669 MockRead data_reads[] = {
11670 MockRead(SYNCHRONOUS, ERR_CONNECTION_RESET), 11670 MockRead(SYNCHRONOUS, ERR_CONNECTION_RESET),
11671 }; 11671 };
11672 11672
(...skipping 15 matching lines...) Expand all
11688 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); 11688 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
11689 EXPECT_TRUE(request_headers.HasHeader("Host")); 11689 EXPECT_TRUE(request_headers.HasHeader("Host"));
11690 } 11690 }
11691 11691
11692 TEST_P(HttpNetworkTransactionTest, HttpAsyncReadError) { 11692 TEST_P(HttpNetworkTransactionTest, HttpAsyncReadError) {
11693 HttpRequestInfo request; 11693 HttpRequestInfo request;
11694 request.method = "GET"; 11694 request.method = "GET";
11695 request.url = GURL("http://www.google.com/"); 11695 request.url = GURL("http://www.google.com/");
11696 request.load_flags = 0; 11696 request.load_flags = 0;
11697 11697
11698 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11698 scoped_ptr<HttpTransaction> trans( 11699 scoped_ptr<HttpTransaction> trans(
11699 new HttpNetworkTransaction(DEFAULT_PRIORITY, 11700 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
11700 CreateSession(&session_deps_)));
11701 11701
11702 MockWrite data_writes[] = { 11702 MockWrite data_writes[] = {
11703 MockWrite("GET / HTTP/1.1\r\n" 11703 MockWrite("GET / HTTP/1.1\r\n"
11704 "Host: www.google.com\r\n" 11704 "Host: www.google.com\r\n"
11705 "Connection: keep-alive\r\n\r\n"), 11705 "Connection: keep-alive\r\n\r\n"),
11706 }; 11706 };
11707 MockRead data_reads[] = { 11707 MockRead data_reads[] = {
11708 MockRead(ASYNC, ERR_CONNECTION_RESET), 11708 MockRead(ASYNC, ERR_CONNECTION_RESET),
11709 }; 11709 };
11710 11710
(...skipping 16 matching lines...) Expand all
11727 EXPECT_TRUE(request_headers.HasHeader("Host")); 11727 EXPECT_TRUE(request_headers.HasHeader("Host"));
11728 } 11728 }
11729 11729
11730 TEST_P(HttpNetworkTransactionTest, GetFullRequestHeadersIncludesExtraHeader) { 11730 TEST_P(HttpNetworkTransactionTest, GetFullRequestHeadersIncludesExtraHeader) {
11731 HttpRequestInfo request; 11731 HttpRequestInfo request;
11732 request.method = "GET"; 11732 request.method = "GET";
11733 request.url = GURL("http://www.google.com/"); 11733 request.url = GURL("http://www.google.com/");
11734 request.load_flags = 0; 11734 request.load_flags = 0;
11735 request.extra_headers.SetHeader("X-Foo", "bar"); 11735 request.extra_headers.SetHeader("X-Foo", "bar");
11736 11736
11737 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11737 scoped_ptr<HttpTransaction> trans( 11738 scoped_ptr<HttpTransaction> trans(
11738 new HttpNetworkTransaction(DEFAULT_PRIORITY, 11739 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
11739 CreateSession(&session_deps_)));
11740 11740
11741 MockWrite data_writes[] = { 11741 MockWrite data_writes[] = {
11742 MockWrite("GET / HTTP/1.1\r\n" 11742 MockWrite("GET / HTTP/1.1\r\n"
11743 "Host: www.google.com\r\n" 11743 "Host: www.google.com\r\n"
11744 "Connection: keep-alive\r\n" 11744 "Connection: keep-alive\r\n"
11745 "X-Foo: bar\r\n\r\n"), 11745 "X-Foo: bar\r\n\r\n"),
11746 }; 11746 };
11747 MockRead data_reads[] = { 11747 MockRead data_reads[] = {
11748 MockRead("HTTP/1.1 200 OK\r\n" 11748 MockRead("HTTP/1.1 200 OK\r\n"
11749 "Content-Length: 5\r\n\r\n" 11749 "Content-Length: 5\r\n\r\n"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
12223 // established, to let the HTTP request start. 12223 // established, to let the HTTP request start.
12224 ASSERT_EQ(OK, http_callback.WaitForResult()); 12224 ASSERT_EQ(OK, http_callback.WaitForResult());
12225 std::string response_data; 12225 std::string response_data;
12226 ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data)); 12226 ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data));
12227 EXPECT_EQ("falafel", response_data); 12227 EXPECT_EQ("falafel", response_data);
12228 12228
12229 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); 12229 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session));
12230 } 12230 }
12231 12231
12232 } // namespace net 12232 } // 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