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

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

Issue 1342613002: Revert of Remove reference counting from HttpNetworkSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 226
227 void AddWebSocketHeaders(HttpRequestHeaders* headers) { 227 void AddWebSocketHeaders(HttpRequestHeaders* headers) {
228 headers->SetHeader("Connection", "Upgrade"); 228 headers->SetHeader("Connection", "Upgrade");
229 headers->SetHeader("Upgrade", "websocket"); 229 headers->SetHeader("Upgrade", "websocket");
230 headers->SetHeader("Origin", "http://www.example.org"); 230 headers->SetHeader("Origin", "http://www.example.org");
231 headers->SetHeader("Sec-WebSocket-Version", "13"); 231 headers->SetHeader("Sec-WebSocket-Version", "13");
232 headers->SetHeader("Sec-WebSocket-Key", "dGhlIHNhbXBsZSBub25jZQ=="); 232 headers->SetHeader("Sec-WebSocket-Key", "dGhlIHNhbXBsZSBub25jZQ==");
233 } 233 }
234 234
235 scoped_ptr<HttpNetworkSession> CreateSession( 235 HttpNetworkSession* CreateSession(SpdySessionDependencies* session_deps) {
236 SpdySessionDependencies* session_deps) {
237 return SpdySessionDependencies::SpdyCreateSession(session_deps); 236 return SpdySessionDependencies::SpdyCreateSession(session_deps);
238 } 237 }
239 238
240 } // namespace 239 } // namespace
241 240
242 class HttpNetworkTransactionTest 241 class HttpNetworkTransactionTest
243 : public PlatformTest, 242 : public PlatformTest,
244 public ::testing::WithParamInterface<NextProto> { 243 public ::testing::WithParamInterface<NextProto> {
245 public: 244 public:
246 virtual ~HttpNetworkTransactionTest() { 245 virtual ~HttpNetworkTransactionTest() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 size_t data_count) { 320 size_t data_count) {
322 SimpleGetHelperResult out; 321 SimpleGetHelperResult out;
323 322
324 HttpRequestInfo request; 323 HttpRequestInfo request;
325 request.method = "GET"; 324 request.method = "GET";
326 request.url = GURL("http://www.example.org/"); 325 request.url = GURL("http://www.example.org/");
327 request.load_flags = 0; 326 request.load_flags = 0;
328 327
329 BoundTestNetLog log; 328 BoundTestNetLog log;
330 session_deps_.net_log = log.bound().net_log(); 329 session_deps_.net_log = log.bound().net_log();
331 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 330 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
332 scoped_ptr<HttpTransaction> trans( 331 scoped_ptr<HttpTransaction> trans(
333 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 332 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
334 333
335 for (size_t i = 0; i < data_count; ++i) { 334 for (size_t i = 0; i < data_count; ++i) {
336 session_deps_.socket_factory->AddSocketDataProvider(data[i]); 335 session_deps_.socket_factory->AddSocketDataProvider(data[i]);
337 } 336 }
338 337
339 TestCompletionCallback callback; 338 TestCompletionCallback callback;
340 339
341 EXPECT_TRUE(log.bound().IsCapturing()); 340 EXPECT_TRUE(log.bound().IsCapturing());
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); 666 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString());
668 EXPECT_EQ(std::string(), auth_challenge->realm); 667 EXPECT_EQ(std::string(), auth_challenge->realm);
669 EXPECT_EQ("ntlm", auth_challenge->scheme); 668 EXPECT_EQ("ntlm", auth_challenge->scheme);
670 return true; 669 return true;
671 } 670 }
672 #endif // defined(NTLM_PORTABLE) 671 #endif // defined(NTLM_PORTABLE)
673 672
674 } // namespace 673 } // namespace
675 674
676 TEST_P(HttpNetworkTransactionTest, Basic) { 675 TEST_P(HttpNetworkTransactionTest, Basic) {
677 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 676 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
678 scoped_ptr<HttpTransaction> trans( 677 scoped_ptr<HttpTransaction> trans(
679 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 678 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
680 } 679 }
681 680
682 TEST_P(HttpNetworkTransactionTest, SimpleGET) { 681 TEST_P(HttpNetworkTransactionTest, SimpleGET) {
683 MockRead data_reads[] = { 682 MockRead data_reads[] = {
684 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 683 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
685 MockRead("hello world"), 684 MockRead("hello world"),
686 MockRead(SYNCHRONOUS, OK), 685 MockRead(SYNCHRONOUS, OK),
687 }; 686 };
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 MockRead("Location: http://good.com/\r\n"), 985 MockRead("Location: http://good.com/\r\n"),
987 MockRead("Content-Length: 0\r\n\r\n"), 986 MockRead("Content-Length: 0\r\n\r\n"),
988 MockRead(SYNCHRONOUS, OK), 987 MockRead(SYNCHRONOUS, OK),
989 }; 988 };
990 989
991 HttpRequestInfo request; 990 HttpRequestInfo request;
992 request.method = "GET"; 991 request.method = "GET";
993 request.url = GURL("http://redirect.com/"); 992 request.url = GURL("http://redirect.com/");
994 request.load_flags = 0; 993 request.load_flags = 0;
995 994
996 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 995 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
997 scoped_ptr<HttpTransaction> trans( 996 scoped_ptr<HttpTransaction> trans(
998 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 997 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
999 998
1000 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 999 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1001 session_deps_.socket_factory->AddSocketDataProvider(&data); 1000 session_deps_.socket_factory->AddSocketDataProvider(&data);
1002 1001
1003 TestCompletionCallback callback; 1002 TestCompletionCallback callback;
1004 1003
1005 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 1004 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
1006 EXPECT_EQ(ERR_IO_PENDING, rv); 1005 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 24 matching lines...) Expand all
1031 } 1030 }
1032 1031
1033 // Do a request using the HEAD method. Verify that we don't try to read the 1032 // Do a request using the HEAD method. Verify that we don't try to read the
1034 // message body (since HEAD has none). 1033 // message body (since HEAD has none).
1035 TEST_P(HttpNetworkTransactionTest, Head) { 1034 TEST_P(HttpNetworkTransactionTest, Head) {
1036 HttpRequestInfo request; 1035 HttpRequestInfo request;
1037 request.method = "HEAD"; 1036 request.method = "HEAD";
1038 request.url = GURL("http://www.example.org/"); 1037 request.url = GURL("http://www.example.org/");
1039 request.load_flags = 0; 1038 request.load_flags = 0;
1040 1039
1041 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1040 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1042 scoped_ptr<HttpTransaction> trans( 1041 scoped_ptr<HttpTransaction> trans(
1043 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1042 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1044 BeforeProxyHeadersSentHandler proxy_headers_handler; 1043 BeforeProxyHeadersSentHandler proxy_headers_handler;
1045 trans->SetBeforeProxyHeadersSentCallback( 1044 trans->SetBeforeProxyHeadersSentCallback(
1046 base::Bind(&BeforeProxyHeadersSentHandler::OnBeforeProxyHeadersSent, 1045 base::Bind(&BeforeProxyHeadersSentHandler::OnBeforeProxyHeadersSent,
1047 base::Unretained(&proxy_headers_handler))); 1046 base::Unretained(&proxy_headers_handler)));
1048 1047
1049 MockWrite data_writes1[] = { 1048 MockWrite data_writes1[] = {
1050 MockWrite("HEAD / HTTP/1.1\r\n" 1049 MockWrite("HEAD / HTTP/1.1\r\n"
1051 "Host: www.example.org\r\n" 1050 "Host: www.example.org\r\n"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1090
1092 // Reading should give EOF right away, since there is no message body 1091 // Reading should give EOF right away, since there is no message body
1093 // (despite non-zero content-length). 1092 // (despite non-zero content-length).
1094 std::string response_data; 1093 std::string response_data;
1095 rv = ReadTransaction(trans.get(), &response_data); 1094 rv = ReadTransaction(trans.get(), &response_data);
1096 EXPECT_EQ(OK, rv); 1095 EXPECT_EQ(OK, rv);
1097 EXPECT_EQ("", response_data); 1096 EXPECT_EQ("", response_data);
1098 } 1097 }
1099 1098
1100 TEST_P(HttpNetworkTransactionTest, ReuseConnection) { 1099 TEST_P(HttpNetworkTransactionTest, ReuseConnection) {
1101 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1100 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1102 1101
1103 MockRead data_reads[] = { 1102 MockRead data_reads[] = {
1104 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 1103 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
1105 MockRead("hello"), 1104 MockRead("hello"),
1106 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 1105 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
1107 MockRead("world"), 1106 MockRead("world"),
1108 MockRead(SYNCHRONOUS, OK), 1107 MockRead(SYNCHRONOUS, OK),
1109 }; 1108 };
1110 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1109 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1111 session_deps_.socket_factory->AddSocketDataProvider(&data); 1110 session_deps_.socket_factory->AddSocketDataProvider(&data);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 ScopedVector<UploadElementReader> element_readers; 1148 ScopedVector<UploadElementReader> element_readers;
1150 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 1149 element_readers.push_back(new UploadBytesElementReader("foo", 3));
1151 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 1150 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
1152 1151
1153 HttpRequestInfo request; 1152 HttpRequestInfo request;
1154 request.method = "POST"; 1153 request.method = "POST";
1155 request.url = GURL("http://www.foo.com/"); 1154 request.url = GURL("http://www.foo.com/");
1156 request.upload_data_stream = &upload_data_stream; 1155 request.upload_data_stream = &upload_data_stream;
1157 request.load_flags = 0; 1156 request.load_flags = 0;
1158 1157
1159 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1158 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1160 scoped_ptr<HttpTransaction> trans( 1159 scoped_ptr<HttpTransaction> trans(
1161 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1160 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1162 1161
1163 MockRead data_reads[] = { 1162 MockRead data_reads[] = {
1164 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), 1163 MockRead("HTTP/1.0 100 Continue\r\n\r\n"),
1165 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 1164 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
1166 MockRead("hello world"), 1165 MockRead("hello world"),
1167 MockRead(SYNCHRONOUS, OK), 1166 MockRead(SYNCHRONOUS, OK),
1168 }; 1167 };
1169 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1168 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
(...skipping 21 matching lines...) Expand all
1191 1190
1192 // This test is almost the same as Ignores100 above, but the response contains 1191 // This test is almost the same as Ignores100 above, but the response contains
1193 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is 1192 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is
1194 // HTTP/1.1 and the two status headers are read in one read. 1193 // HTTP/1.1 and the two status headers are read in one read.
1195 TEST_P(HttpNetworkTransactionTest, Ignores1xx) { 1194 TEST_P(HttpNetworkTransactionTest, Ignores1xx) {
1196 HttpRequestInfo request; 1195 HttpRequestInfo request;
1197 request.method = "GET"; 1196 request.method = "GET";
1198 request.url = GURL("http://www.foo.com/"); 1197 request.url = GURL("http://www.foo.com/");
1199 request.load_flags = 0; 1198 request.load_flags = 0;
1200 1199
1201 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1200 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1202 scoped_ptr<HttpTransaction> trans( 1201 scoped_ptr<HttpTransaction> trans(
1203 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1202 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1204 1203
1205 MockRead data_reads[] = { 1204 MockRead data_reads[] = {
1206 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n" 1205 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"
1207 "HTTP/1.1 200 OK\r\n\r\n"), 1206 "HTTP/1.1 200 OK\r\n\r\n"),
1208 MockRead("hello world"), 1207 MockRead("hello world"),
1209 MockRead(SYNCHRONOUS, OK), 1208 MockRead(SYNCHRONOUS, OK),
1210 }; 1209 };
1211 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1210 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
(...skipping 18 matching lines...) Expand all
1230 EXPECT_EQ(OK, rv); 1229 EXPECT_EQ(OK, rv);
1231 EXPECT_EQ("hello world", response_data); 1230 EXPECT_EQ("hello world", response_data);
1232 } 1231 }
1233 1232
1234 TEST_P(HttpNetworkTransactionTest, Incomplete100ThenEOF) { 1233 TEST_P(HttpNetworkTransactionTest, Incomplete100ThenEOF) {
1235 HttpRequestInfo request; 1234 HttpRequestInfo request;
1236 request.method = "POST"; 1235 request.method = "POST";
1237 request.url = GURL("http://www.foo.com/"); 1236 request.url = GURL("http://www.foo.com/");
1238 request.load_flags = 0; 1237 request.load_flags = 0;
1239 1238
1240 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1239 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1241 scoped_ptr<HttpTransaction> trans( 1240 scoped_ptr<HttpTransaction> trans(
1242 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1241 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1243 1242
1244 MockRead data_reads[] = { 1243 MockRead data_reads[] = {
1245 MockRead(SYNCHRONOUS, "HTTP/1.0 100 Continue\r\n"), 1244 MockRead(SYNCHRONOUS, "HTTP/1.0 100 Continue\r\n"),
1246 MockRead(ASYNC, 0), 1245 MockRead(ASYNC, 0),
1247 }; 1246 };
1248 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1247 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1249 session_deps_.socket_factory->AddSocketDataProvider(&data); 1248 session_deps_.socket_factory->AddSocketDataProvider(&data);
1250 1249
(...skipping 10 matching lines...) Expand all
1261 EXPECT_EQ(OK, rv); 1260 EXPECT_EQ(OK, rv);
1262 EXPECT_EQ("", response_data); 1261 EXPECT_EQ("", response_data);
1263 } 1262 }
1264 1263
1265 TEST_P(HttpNetworkTransactionTest, EmptyResponse) { 1264 TEST_P(HttpNetworkTransactionTest, EmptyResponse) {
1266 HttpRequestInfo request; 1265 HttpRequestInfo request;
1267 request.method = "POST"; 1266 request.method = "POST";
1268 request.url = GURL("http://www.foo.com/"); 1267 request.url = GURL("http://www.foo.com/");
1269 request.load_flags = 0; 1268 request.load_flags = 0;
1270 1269
1271 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1270 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1272 scoped_ptr<HttpTransaction> trans( 1271 scoped_ptr<HttpTransaction> trans(
1273 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1272 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1274 1273
1275 MockRead data_reads[] = { 1274 MockRead data_reads[] = {
1276 MockRead(ASYNC, 0), 1275 MockRead(ASYNC, 0),
1277 }; 1276 };
1278 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1277 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
1279 session_deps_.socket_factory->AddSocketDataProvider(&data); 1278 session_deps_.socket_factory->AddSocketDataProvider(&data);
1280 1279
1281 TestCompletionCallback callback; 1280 TestCompletionCallback callback;
1282 1281
1283 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 1282 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
1284 EXPECT_EQ(ERR_IO_PENDING, rv); 1283 EXPECT_EQ(ERR_IO_PENDING, rv);
1285 1284
1286 rv = callback.WaitForResult(); 1285 rv = callback.WaitForResult();
1287 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); 1286 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv);
1288 } 1287 }
1289 1288
1290 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( 1289 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest(
1291 const MockWrite* write_failure, 1290 const MockWrite* write_failure,
1292 const MockRead* read_failure) { 1291 const MockRead* read_failure) {
1293 HttpRequestInfo request; 1292 HttpRequestInfo request;
1294 request.method = "GET"; 1293 request.method = "GET";
1295 request.url = GURL("http://www.foo.com/"); 1294 request.url = GURL("http://www.foo.com/");
1296 request.load_flags = 0; 1295 request.load_flags = 0;
1297 1296
1298 TestNetLog net_log; 1297 TestNetLog net_log;
1299 session_deps_.net_log = &net_log; 1298 session_deps_.net_log = &net_log;
1300 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1299 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1301 1300
1302 // Written data for successfully sending both requests. 1301 // Written data for successfully sending both requests.
1303 MockWrite data1_writes[] = { 1302 MockWrite data1_writes[] = {
1304 MockWrite("GET / HTTP/1.1\r\n" 1303 MockWrite("GET / HTTP/1.1\r\n"
1305 "Host: www.foo.com\r\n" 1304 "Host: www.foo.com\r\n"
1306 "Connection: keep-alive\r\n\r\n"), 1305 "Connection: keep-alive\r\n\r\n"),
1307 MockWrite("GET / HTTP/1.1\r\n" 1306 MockWrite("GET / HTTP/1.1\r\n"
1308 "Host: www.foo.com\r\n" 1307 "Host: www.foo.com\r\n"
1309 "Connection: keep-alive\r\n\r\n") 1308 "Connection: keep-alive\r\n\r\n")
1310 }; 1309 };
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 const MockWrite* write_failure, 1379 const MockWrite* write_failure,
1381 const MockRead* read_failure, 1380 const MockRead* read_failure,
1382 bool use_spdy) { 1381 bool use_spdy) {
1383 HttpRequestInfo request; 1382 HttpRequestInfo request;
1384 request.method = "GET"; 1383 request.method = "GET";
1385 request.url = GURL("https://www.foo.com/"); 1384 request.url = GURL("https://www.foo.com/");
1386 request.load_flags = 0; 1385 request.load_flags = 0;
1387 1386
1388 TestNetLog net_log; 1387 TestNetLog net_log;
1389 session_deps_.net_log = &net_log; 1388 session_deps_.net_log = &net_log;
1390 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1389 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1391 1390
1392 SSLSocketDataProvider ssl1(ASYNC, OK); 1391 SSLSocketDataProvider ssl1(ASYNC, OK);
1393 SSLSocketDataProvider ssl2(ASYNC, OK); 1392 SSLSocketDataProvider ssl2(ASYNC, OK);
1394 if (use_spdy) { 1393 if (use_spdy) {
1395 ssl1.SetNextProto(GetParam()); 1394 ssl1.SetNextProto(GetParam());
1396 ssl2.SetNextProto(GetParam()); 1395 ssl2.SetNextProto(GetParam());
1397 } 1396 }
1398 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1); 1397 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1);
1399 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); 1398 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2);
1400 1399
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 MockRead read_failure(ASYNC, OK); // EOF 1575 MockRead read_failure(ASYNC, OK); // EOF
1577 PreconnectErrorResendRequestTest(NULL, &read_failure, true); 1576 PreconnectErrorResendRequestTest(NULL, &read_failure, true);
1578 } 1577 }
1579 1578
1580 TEST_P(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) { 1579 TEST_P(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) {
1581 HttpRequestInfo request; 1580 HttpRequestInfo request;
1582 request.method = "GET"; 1581 request.method = "GET";
1583 request.url = GURL("http://www.example.org/"); 1582 request.url = GURL("http://www.example.org/");
1584 request.load_flags = 0; 1583 request.load_flags = 0;
1585 1584
1586 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1585 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1587 scoped_ptr<HttpTransaction> trans( 1586 scoped_ptr<HttpTransaction> trans(
1588 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1587 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1589 1588
1590 MockRead data_reads[] = { 1589 MockRead data_reads[] = {
1591 MockRead(ASYNC, ERR_CONNECTION_RESET), 1590 MockRead(ASYNC, ERR_CONNECTION_RESET),
1592 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used 1591 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used
1593 MockRead("hello world"), 1592 MockRead("hello world"),
1594 MockRead(SYNCHRONOUS, OK), 1593 MockRead(SYNCHRONOUS, OK),
1595 }; 1594 };
1596 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1595 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
(...skipping 29 matching lines...) Expand all
1626 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv); 1625 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv);
1627 } 1626 }
1628 1627
1629 // Test that network access can be deferred and resumed. 1628 // Test that network access can be deferred and resumed.
1630 TEST_P(HttpNetworkTransactionTest, ThrottleBeforeNetworkStart) { 1629 TEST_P(HttpNetworkTransactionTest, ThrottleBeforeNetworkStart) {
1631 HttpRequestInfo request; 1630 HttpRequestInfo request;
1632 request.method = "GET"; 1631 request.method = "GET";
1633 request.url = GURL("http://www.example.org/"); 1632 request.url = GURL("http://www.example.org/");
1634 request.load_flags = 0; 1633 request.load_flags = 0;
1635 1634
1636 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1635 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1637 scoped_ptr<HttpTransaction> trans( 1636 scoped_ptr<HttpTransaction> trans(
1638 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1637 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1639 1638
1640 // Defer on OnBeforeNetworkStart. 1639 // Defer on OnBeforeNetworkStart.
1641 BeforeNetworkStartHandler net_start_handler(true); // defer 1640 BeforeNetworkStartHandler net_start_handler(true); // defer
1642 trans->SetBeforeNetworkStartCallback( 1641 trans->SetBeforeNetworkStartCallback(
1643 base::Bind(&BeforeNetworkStartHandler::OnBeforeNetworkStart, 1642 base::Bind(&BeforeNetworkStartHandler::OnBeforeNetworkStart,
1644 base::Unretained(&net_start_handler))); 1643 base::Unretained(&net_start_handler)));
1645 1644
1646 MockRead data_reads[] = { 1645 MockRead data_reads[] = {
(...skipping 28 matching lines...) Expand all
1675 trans.reset(); 1674 trans.reset();
1676 } 1675 }
1677 1676
1678 // Test that network use can be deferred and canceled. 1677 // Test that network use can be deferred and canceled.
1679 TEST_P(HttpNetworkTransactionTest, ThrottleAndCancelBeforeNetworkStart) { 1678 TEST_P(HttpNetworkTransactionTest, ThrottleAndCancelBeforeNetworkStart) {
1680 HttpRequestInfo request; 1679 HttpRequestInfo request;
1681 request.method = "GET"; 1680 request.method = "GET";
1682 request.url = GURL("http://www.example.org/"); 1681 request.url = GURL("http://www.example.org/");
1683 request.load_flags = 0; 1682 request.load_flags = 0;
1684 1683
1685 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1684 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1686 scoped_ptr<HttpTransaction> trans( 1685 scoped_ptr<HttpTransaction> trans(
1687 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1686 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1688 1687
1689 // Defer on OnBeforeNetworkStart. 1688 // Defer on OnBeforeNetworkStart.
1690 BeforeNetworkStartHandler net_start_handler(true); // defer 1689 BeforeNetworkStartHandler net_start_handler(true); // defer
1691 trans->SetBeforeNetworkStartCallback( 1690 trans->SetBeforeNetworkStartCallback(
1692 base::Bind(&BeforeNetworkStartHandler::OnBeforeNetworkStart, 1691 base::Bind(&BeforeNetworkStartHandler::OnBeforeNetworkStart,
1693 base::Unretained(&net_start_handler))); 1692 base::Unretained(&net_start_handler)));
1694 1693
1695 TestCompletionCallback callback; 1694 TestCompletionCallback callback;
(...skipping 10 matching lines...) Expand all
1706 // Next 2 cases (KeepAliveEarlyClose and KeepAliveEarlyClose2) are regression 1705 // Next 2 cases (KeepAliveEarlyClose and KeepAliveEarlyClose2) are regression
1707 // tests. There was a bug causing HttpNetworkTransaction to hang in the 1706 // tests. There was a bug causing HttpNetworkTransaction to hang in the
1708 // destructor in such situations. 1707 // destructor in such situations.
1709 // See http://crbug.com/154712 and http://crbug.com/156609. 1708 // See http://crbug.com/154712 and http://crbug.com/156609.
1710 TEST_P(HttpNetworkTransactionTest, KeepAliveEarlyClose) { 1709 TEST_P(HttpNetworkTransactionTest, KeepAliveEarlyClose) {
1711 HttpRequestInfo request; 1710 HttpRequestInfo request;
1712 request.method = "GET"; 1711 request.method = "GET";
1713 request.url = GURL("http://www.example.org/"); 1712 request.url = GURL("http://www.example.org/");
1714 request.load_flags = 0; 1713 request.load_flags = 0;
1715 1714
1716 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1715 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1717 scoped_ptr<HttpTransaction> trans( 1716 scoped_ptr<HttpTransaction> trans(
1718 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1717 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1719 1718
1720 MockRead data_reads[] = { 1719 MockRead data_reads[] = {
1721 MockRead("HTTP/1.0 200 OK\r\n"), 1720 MockRead("HTTP/1.0 200 OK\r\n"),
1722 MockRead("Connection: keep-alive\r\n"), 1721 MockRead("Connection: keep-alive\r\n"),
1723 MockRead("Content-Length: 100\r\n\r\n"), 1722 MockRead("Content-Length: 100\r\n\r\n"),
1724 MockRead("hello"), 1723 MockRead("hello"),
1725 MockRead(SYNCHRONOUS, 0), 1724 MockRead(SYNCHRONOUS, 0),
1726 }; 1725 };
(...skipping 20 matching lines...) Expand all
1747 base::MessageLoop::current()->RunUntilIdle(); 1746 base::MessageLoop::current()->RunUntilIdle();
1748 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); 1747 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get()));
1749 } 1748 }
1750 1749
1751 TEST_P(HttpNetworkTransactionTest, KeepAliveEarlyClose2) { 1750 TEST_P(HttpNetworkTransactionTest, KeepAliveEarlyClose2) {
1752 HttpRequestInfo request; 1751 HttpRequestInfo request;
1753 request.method = "GET"; 1752 request.method = "GET";
1754 request.url = GURL("http://www.example.org/"); 1753 request.url = GURL("http://www.example.org/");
1755 request.load_flags = 0; 1754 request.load_flags = 0;
1756 1755
1757 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1756 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1758 scoped_ptr<HttpTransaction> trans( 1757 scoped_ptr<HttpTransaction> trans(
1759 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1758 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1760 1759
1761 MockRead data_reads[] = { 1760 MockRead data_reads[] = {
1762 MockRead("HTTP/1.0 200 OK\r\n"), 1761 MockRead("HTTP/1.0 200 OK\r\n"),
1763 MockRead("Connection: keep-alive\r\n"), 1762 MockRead("Connection: keep-alive\r\n"),
1764 MockRead("Content-Length: 100\r\n\r\n"), 1763 MockRead("Content-Length: 100\r\n\r\n"),
1765 MockRead(SYNCHRONOUS, 0), 1764 MockRead(SYNCHRONOUS, 0),
1766 }; 1765 };
1767 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 1766 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
(...skipping 21 matching lines...) Expand all
1789 // Test that we correctly reuse a keep-alive connection after not explicitly 1788 // Test that we correctly reuse a keep-alive connection after not explicitly
1790 // reading the body. 1789 // reading the body.
1791 TEST_P(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) { 1790 TEST_P(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) {
1792 HttpRequestInfo request; 1791 HttpRequestInfo request;
1793 request.method = "GET"; 1792 request.method = "GET";
1794 request.url = GURL("http://www.foo.com/"); 1793 request.url = GURL("http://www.foo.com/");
1795 request.load_flags = 0; 1794 request.load_flags = 0;
1796 1795
1797 TestNetLog net_log; 1796 TestNetLog net_log;
1798 session_deps_.net_log = &net_log; 1797 session_deps_.net_log = &net_log;
1799 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1798 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1800 1799
1801 // Note that because all these reads happen in the same 1800 // Note that because all these reads happen in the same
1802 // StaticSocketDataProvider, it shows that the same socket is being reused for 1801 // StaticSocketDataProvider, it shows that the same socket is being reused for
1803 // all transactions. 1802 // all transactions.
1804 MockRead data1_reads[] = { 1803 MockRead data1_reads[] = {
1805 MockRead("HTTP/1.1 204 No Content\r\n\r\n"), 1804 MockRead("HTTP/1.1 204 No Content\r\n\r\n"),
1806 MockRead("HTTP/1.1 205 Reset Content\r\n\r\n"), 1805 MockRead("HTTP/1.1 205 Reset Content\r\n\r\n"),
1807 MockRead("HTTP/1.1 304 Not Modified\r\n\r\n"), 1806 MockRead("HTTP/1.1 304 Not Modified\r\n\r\n"),
1808 MockRead("HTTP/1.1 302 Found\r\n" 1807 MockRead("HTTP/1.1 302 Found\r\n"
1809 "Content-Length: 0\r\n\r\n"), 1808 "Content-Length: 0\r\n\r\n"),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 // Test the request-challenge-retry sequence for basic auth. 1897 // Test the request-challenge-retry sequence for basic auth.
1899 // (basic auth is the easiest to mock, because it has no randomness). 1898 // (basic auth is the easiest to mock, because it has no randomness).
1900 TEST_P(HttpNetworkTransactionTest, BasicAuth) { 1899 TEST_P(HttpNetworkTransactionTest, BasicAuth) {
1901 HttpRequestInfo request; 1900 HttpRequestInfo request;
1902 request.method = "GET"; 1901 request.method = "GET";
1903 request.url = GURL("http://www.example.org/"); 1902 request.url = GURL("http://www.example.org/");
1904 request.load_flags = 0; 1903 request.load_flags = 0;
1905 1904
1906 TestNetLog log; 1905 TestNetLog log;
1907 session_deps_.net_log = &log; 1906 session_deps_.net_log = &log;
1908 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 1907 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
1909 scoped_ptr<HttpTransaction> trans( 1908 scoped_ptr<HttpTransaction> trans(
1910 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 1909 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
1911 1910
1912 MockWrite data_writes1[] = { 1911 MockWrite data_writes1[] = {
1913 MockWrite( 1912 MockWrite(
1914 "GET / HTTP/1.1\r\n" 1913 "GET / HTTP/1.1\r\n"
1915 "Host: www.example.org\r\n" 1914 "Host: www.example.org\r\n"
1916 "Connection: keep-alive\r\n\r\n"), 1915 "Connection: keep-alive\r\n\r\n"),
1917 }; 1916 };
1918 1917
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 EXPECT_TRUE(response->auth_challenge.get() == NULL); 2002 EXPECT_TRUE(response->auth_challenge.get() == NULL);
2004 EXPECT_EQ(100, response->headers->GetContentLength()); 2003 EXPECT_EQ(100, response->headers->GetContentLength());
2005 } 2004 }
2006 2005
2007 TEST_P(HttpNetworkTransactionTest, DoNotSendAuth) { 2006 TEST_P(HttpNetworkTransactionTest, DoNotSendAuth) {
2008 HttpRequestInfo request; 2007 HttpRequestInfo request;
2009 request.method = "GET"; 2008 request.method = "GET";
2010 request.url = GURL("http://www.example.org/"); 2009 request.url = GURL("http://www.example.org/");
2011 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2010 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2012 2011
2013 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2012 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2014 scoped_ptr<HttpTransaction> trans( 2013 scoped_ptr<HttpTransaction> trans(
2015 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2014 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2016 2015
2017 MockWrite data_writes[] = { 2016 MockWrite data_writes[] = {
2018 MockWrite( 2017 MockWrite(
2019 "GET / HTTP/1.1\r\n" 2018 "GET / HTTP/1.1\r\n"
2020 "Host: www.example.org\r\n" 2019 "Host: www.example.org\r\n"
2021 "Connection: keep-alive\r\n\r\n"), 2020 "Connection: keep-alive\r\n\r\n"),
2022 }; 2021 };
2023 2022
(...skipping 30 matching lines...) Expand all
2054 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 2053 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
2055 // connection. 2054 // connection.
2056 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAlive) { 2055 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAlive) {
2057 HttpRequestInfo request; 2056 HttpRequestInfo request;
2058 request.method = "GET"; 2057 request.method = "GET";
2059 request.url = GURL("http://www.example.org/"); 2058 request.url = GURL("http://www.example.org/");
2060 request.load_flags = 0; 2059 request.load_flags = 0;
2061 2060
2062 TestNetLog log; 2061 TestNetLog log;
2063 session_deps_.net_log = &log; 2062 session_deps_.net_log = &log;
2064 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2063 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2065 2064
2066 MockWrite data_writes1[] = { 2065 MockWrite data_writes1[] = {
2067 MockWrite( 2066 MockWrite(
2068 "GET / HTTP/1.1\r\n" 2067 "GET / HTTP/1.1\r\n"
2069 "Host: www.example.org\r\n" 2068 "Host: www.example.org\r\n"
2070 "Connection: keep-alive\r\n\r\n"), 2069 "Connection: keep-alive\r\n\r\n"),
2071 2070
2072 // After calling trans->RestartWithAuth(), this is the request we should 2071 // After calling trans->RestartWithAuth(), this is the request we should
2073 // be issuing -- the final header line contains the credentials. 2072 // be issuing -- the final header line contains the credentials.
2074 MockWrite( 2073 MockWrite(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 } 2156 }
2158 2157
2159 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 2158 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
2160 // connection and with no response body to drain. 2159 // connection and with no response body to drain.
2161 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { 2160 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) {
2162 HttpRequestInfo request; 2161 HttpRequestInfo request;
2163 request.method = "GET"; 2162 request.method = "GET";
2164 request.url = GURL("http://www.example.org/"); 2163 request.url = GURL("http://www.example.org/");
2165 request.load_flags = 0; 2164 request.load_flags = 0;
2166 2165
2167 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2166 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2168 2167
2169 MockWrite data_writes1[] = { 2168 MockWrite data_writes1[] = {
2170 MockWrite( 2169 MockWrite(
2171 "GET / HTTP/1.1\r\n" 2170 "GET / HTTP/1.1\r\n"
2172 "Host: www.example.org\r\n" 2171 "Host: www.example.org\r\n"
2173 "Connection: keep-alive\r\n\r\n"), 2172 "Connection: keep-alive\r\n\r\n"),
2174 2173
2175 // After calling trans->RestartWithAuth(), this is the request we should 2174 // After calling trans->RestartWithAuth(), this is the request we should
2176 // be issuing -- the final header line contains the credentials. 2175 // be issuing -- the final header line contains the credentials.
2177 MockWrite( 2176 MockWrite(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 } 2234 }
2236 2235
2237 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 2236 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
2238 // connection and with a large response body to drain. 2237 // connection and with a large response body to drain.
2239 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { 2238 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) {
2240 HttpRequestInfo request; 2239 HttpRequestInfo request;
2241 request.method = "GET"; 2240 request.method = "GET";
2242 request.url = GURL("http://www.example.org/"); 2241 request.url = GURL("http://www.example.org/");
2243 request.load_flags = 0; 2242 request.load_flags = 0;
2244 2243
2245 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2244 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2246 2245
2247 MockWrite data_writes1[] = { 2246 MockWrite data_writes1[] = {
2248 MockWrite( 2247 MockWrite(
2249 "GET / HTTP/1.1\r\n" 2248 "GET / HTTP/1.1\r\n"
2250 "Host: www.example.org\r\n" 2249 "Host: www.example.org\r\n"
2251 "Connection: keep-alive\r\n\r\n"), 2250 "Connection: keep-alive\r\n\r\n"),
2252 2251
2253 // After calling trans->RestartWithAuth(), this is the request we should 2252 // After calling trans->RestartWithAuth(), this is the request we should
2254 // be issuing -- the final header line contains the credentials. 2253 // be issuing -- the final header line contains the credentials.
2255 MockWrite( 2254 MockWrite(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 } 2320 }
2322 2321
2323 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 2322 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
2324 // connection, but the server gets impatient and closes the connection. 2323 // connection, but the server gets impatient and closes the connection.
2325 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { 2324 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) {
2326 HttpRequestInfo request; 2325 HttpRequestInfo request;
2327 request.method = "GET"; 2326 request.method = "GET";
2328 request.url = GURL("http://www.example.org/"); 2327 request.url = GURL("http://www.example.org/");
2329 request.load_flags = 0; 2328 request.load_flags = 0;
2330 2329
2331 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2330 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2332 2331
2333 MockWrite data_writes1[] = { 2332 MockWrite data_writes1[] = {
2334 MockWrite( 2333 MockWrite(
2335 "GET / HTTP/1.1\r\n" 2334 "GET / HTTP/1.1\r\n"
2336 "Host: www.example.org\r\n" 2335 "Host: www.example.org\r\n"
2337 "Connection: keep-alive\r\n\r\n"), 2336 "Connection: keep-alive\r\n\r\n"),
2338 // This simulates the seemingly successful write to a closed connection 2337 // This simulates the seemingly successful write to a closed connection
2339 // if the bug is not fixed. 2338 // if the bug is not fixed.
2340 MockWrite( 2339 MockWrite(
2341 "GET / HTTP/1.1\r\n" 2340 "GET / HTTP/1.1\r\n"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 request.method = "GET"; 2415 request.method = "GET";
2417 request.url = GURL("https://www.example.org/"); 2416 request.url = GURL("https://www.example.org/");
2418 // when the no authentication data flag is set. 2417 // when the no authentication data flag is set.
2419 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2418 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2420 2419
2421 // Configure against proxy server "myproxy:70". 2420 // Configure against proxy server "myproxy:70".
2422 session_deps_.proxy_service.reset( 2421 session_deps_.proxy_service.reset(
2423 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 2422 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
2424 BoundTestNetLog log; 2423 BoundTestNetLog log;
2425 session_deps_.net_log = log.bound().net_log(); 2424 session_deps_.net_log = log.bound().net_log();
2426 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2425 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2427 2426
2428 // Since we have proxy, should try to establish tunnel. 2427 // Since we have proxy, should try to establish tunnel.
2429 MockWrite data_writes1[] = { 2428 MockWrite data_writes1[] = {
2430 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n" 2429 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n"
2431 "Host: www.example.org\r\n" 2430 "Host: www.example.org\r\n"
2432 "Proxy-Connection: keep-alive\r\n\r\n"), 2431 "Proxy-Connection: keep-alive\r\n\r\n"),
2433 }; 2432 };
2434 2433
2435 // The proxy responds to the connect with a 407, using a non-persistent 2434 // The proxy responds to the connect with a 407, using a non-persistent
2436 // connection. 2435 // connection.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 request.method = "GET"; 2539 request.method = "GET";
2541 request.url = GURL("https://www.example.org/"); 2540 request.url = GURL("https://www.example.org/");
2542 // when the no authentication data flag is set. 2541 // when the no authentication data flag is set.
2543 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2542 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2544 2543
2545 // Configure against proxy server "myproxy:70". 2544 // Configure against proxy server "myproxy:70".
2546 session_deps_.proxy_service.reset( 2545 session_deps_.proxy_service.reset(
2547 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 2546 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
2548 BoundTestNetLog log; 2547 BoundTestNetLog log;
2549 session_deps_.net_log = log.bound().net_log(); 2548 session_deps_.net_log = log.bound().net_log();
2550 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2549 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2551 2550
2552 // Since we have proxy, should try to establish tunnel. 2551 // Since we have proxy, should try to establish tunnel.
2553 MockWrite data_writes1[] = { 2552 MockWrite data_writes1[] = {
2554 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n" 2553 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n"
2555 "Host: www.example.org\r\n" 2554 "Host: www.example.org\r\n"
2556 "Proxy-Connection: keep-alive\r\n\r\n"), 2555 "Proxy-Connection: keep-alive\r\n\r\n"),
2557 }; 2556 };
2558 2557
2559 // The proxy responds to the connect with a 407, using a non-persistent 2558 // The proxy responds to the connect with a 407, using a non-persistent
2560 // connection. 2559 // connection.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 request.method = "GET"; 2663 request.method = "GET";
2665 request.url = GURL("https://www.example.org/"); 2664 request.url = GURL("https://www.example.org/");
2666 // Ensure that proxy authentication is attempted even 2665 // Ensure that proxy authentication is attempted even
2667 // when the no authentication data flag is set. 2666 // when the no authentication data flag is set.
2668 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2667 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2669 2668
2670 // Configure against proxy server "myproxy:70". 2669 // Configure against proxy server "myproxy:70".
2671 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2670 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
2672 BoundTestNetLog log; 2671 BoundTestNetLog log;
2673 session_deps_.net_log = log.bound().net_log(); 2672 session_deps_.net_log = log.bound().net_log();
2674 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2673 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2675 2674
2676 scoped_ptr<HttpTransaction> trans( 2675 scoped_ptr<HttpTransaction> trans(
2677 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2676 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2678 2677
2679 // Since we have proxy, should try to establish tunnel. 2678 // Since we have proxy, should try to establish tunnel.
2680 MockWrite data_writes1[] = { 2679 MockWrite data_writes1[] = {
2681 MockWrite( 2680 MockWrite(
2682 "CONNECT www.example.org:443 HTTP/1.1\r\n" 2681 "CONNECT www.example.org:443 HTTP/1.1\r\n"
2683 "Host: www.example.org\r\n" 2682 "Host: www.example.org\r\n"
2684 "Proxy-Connection: keep-alive\r\n\r\n"), 2683 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 request.method = "GET"; 2770 request.method = "GET";
2772 request.url = GURL("https://www.example.org/"); 2771 request.url = GURL("https://www.example.org/");
2773 // Ensure that proxy authentication is attempted even 2772 // Ensure that proxy authentication is attempted even
2774 // when the no authentication data flag is set. 2773 // when the no authentication data flag is set.
2775 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2774 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2776 2775
2777 // Configure against proxy server "myproxy:70". 2776 // Configure against proxy server "myproxy:70".
2778 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2777 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
2779 BoundTestNetLog log; 2778 BoundTestNetLog log;
2780 session_deps_.net_log = log.bound().net_log(); 2779 session_deps_.net_log = log.bound().net_log();
2781 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2780 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2782 2781
2783 scoped_ptr<HttpTransaction> trans( 2782 scoped_ptr<HttpTransaction> trans(
2784 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2783 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2785 2784
2786 // Since we have proxy, should try to establish tunnel. 2785 // Since we have proxy, should try to establish tunnel.
2787 MockWrite data_writes1[] = { 2786 MockWrite data_writes1[] = {
2788 MockWrite( 2787 MockWrite(
2789 "CONNECT www.example.org:443 HTTP/1.1\r\n" 2788 "CONNECT www.example.org:443 HTTP/1.1\r\n"
2790 "Host: www.example.org\r\n" 2789 "Host: www.example.org\r\n"
2791 "Proxy-Connection: keep-alive\r\n\r\n"), 2790 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHangupDuringBody) { 2874 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHangupDuringBody) {
2876 HttpRequestInfo request; 2875 HttpRequestInfo request;
2877 request.method = "GET"; 2876 request.method = "GET";
2878 request.url = GURL("https://www.example.org/"); 2877 request.url = GURL("https://www.example.org/");
2879 // Ensure that proxy authentication is attempted even 2878 // Ensure that proxy authentication is attempted even
2880 // when the no authentication data flag is set. 2879 // when the no authentication data flag is set.
2881 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2880 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2882 2881
2883 // Configure against proxy server "myproxy:70". 2882 // Configure against proxy server "myproxy:70".
2884 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2883 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
2885 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); 2884 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2886 2885
2887 scoped_ptr<HttpTransaction> trans( 2886 scoped_ptr<HttpTransaction> trans(
2888 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2887 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2889 2888
2890 // Since we have proxy, should try to establish tunnel. 2889 // Since we have proxy, should try to establish tunnel.
2891 MockWrite data_writes1[] = { 2890 MockWrite data_writes1[] = {
2892 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n" 2891 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n"
2893 "Host: www.example.org\r\n" 2892 "Host: www.example.org\r\n"
2894 "Proxy-Connection: keep-alive\r\n\r\n"), 2893 "Proxy-Connection: keep-alive\r\n\r\n"),
2895 }; 2894 };
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 // even if the user cancels the proxy's auth attempt. 2964 // even if the user cancels the proxy's auth attempt.
2966 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { 2965 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) {
2967 HttpRequestInfo request; 2966 HttpRequestInfo request;
2968 request.method = "GET"; 2967 request.method = "GET";
2969 request.url = GURL("https://www.example.org/"); 2968 request.url = GURL("https://www.example.org/");
2970 request.load_flags = 0; 2969 request.load_flags = 0;
2971 2970
2972 // Configure against proxy server "myproxy:70". 2971 // Configure against proxy server "myproxy:70".
2973 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2972 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
2974 2973
2975 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2974 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2976 2975
2977 scoped_ptr<HttpTransaction> trans( 2976 scoped_ptr<HttpTransaction> trans(
2978 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2977 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2979 2978
2980 // Since we have proxy, should try to establish tunnel. 2979 // Since we have proxy, should try to establish tunnel.
2981 MockWrite data_writes[] = { 2980 MockWrite data_writes[] = {
2982 MockWrite( 2981 MockWrite(
2983 "CONNECT www.example.org:443 HTTP/1.1\r\n" 2982 "CONNECT www.example.org:443 HTTP/1.1\r\n"
2984 "Host: www.example.org\r\n" 2983 "Host: www.example.org\r\n"
2985 "Proxy-Connection: keep-alive\r\n\r\n"), 2984 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 // caller when the proxy responds to CONNECT with 407. 3024 // caller when the proxy responds to CONNECT with 407.
3026 TEST_P(HttpNetworkTransactionTest, SanitizeProxyAuthHeaders) { 3025 TEST_P(HttpNetworkTransactionTest, SanitizeProxyAuthHeaders) {
3027 HttpRequestInfo request; 3026 HttpRequestInfo request;
3028 request.method = "GET"; 3027 request.method = "GET";
3029 request.url = GURL("https://www.example.org/"); 3028 request.url = GURL("https://www.example.org/");
3030 request.load_flags = 0; 3029 request.load_flags = 0;
3031 3030
3032 // Configure against proxy server "myproxy:70". 3031 // Configure against proxy server "myproxy:70".
3033 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 3032 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
3034 3033
3035 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3034 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3036 3035
3037 scoped_ptr<HttpTransaction> trans( 3036 scoped_ptr<HttpTransaction> trans(
3038 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3037 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3039 3038
3040 // Since we have proxy, should try to establish tunnel. 3039 // Since we have proxy, should try to establish tunnel.
3041 MockWrite data_writes[] = { 3040 MockWrite data_writes[] = {
3042 MockWrite( 3041 MockWrite(
3043 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3042 "CONNECT www.example.org:443 HTTP/1.1\r\n"
3044 "Host: www.example.org\r\n" 3043 "Host: www.example.org\r\n"
3045 "Proxy-Connection: keep-alive\r\n\r\n"), 3044 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 3085
3087 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). 3086 // Test when a server (non-proxy) returns a 407 (proxy-authenticate).
3088 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. 3087 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH.
3089 TEST_P(HttpNetworkTransactionTest, UnexpectedProxyAuth) { 3088 TEST_P(HttpNetworkTransactionTest, UnexpectedProxyAuth) {
3090 HttpRequestInfo request; 3089 HttpRequestInfo request;
3091 request.method = "GET"; 3090 request.method = "GET";
3092 request.url = GURL("http://www.example.org/"); 3091 request.url = GURL("http://www.example.org/");
3093 request.load_flags = 0; 3092 request.load_flags = 0;
3094 3093
3095 // We are using a DIRECT connection (i.e. no proxy) for this session. 3094 // We are using a DIRECT connection (i.e. no proxy) for this session.
3096 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3095 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3097 scoped_ptr<HttpTransaction> trans( 3096 scoped_ptr<HttpTransaction> trans(
3098 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3097 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3099 3098
3100 MockWrite data_writes1[] = { 3099 MockWrite data_writes1[] = {
3101 MockWrite( 3100 MockWrite(
3102 "GET / HTTP/1.1\r\n" 3101 "GET / HTTP/1.1\r\n"
3103 "Host: www.example.org\r\n" 3102 "Host: www.example.org\r\n"
3104 "Connection: keep-alive\r\n\r\n"), 3103 "Connection: keep-alive\r\n\r\n"),
3105 }; 3104 };
3106 3105
(...skipping 27 matching lines...) Expand all
3134 // issued the challenge. 3133 // issued the challenge.
3135 TEST_P(HttpNetworkTransactionTest, 3134 TEST_P(HttpNetworkTransactionTest,
3136 HttpsServerRequestsProxyAuthThroughProxy) { 3135 HttpsServerRequestsProxyAuthThroughProxy) {
3137 HttpRequestInfo request; 3136 HttpRequestInfo request;
3138 request.method = "GET"; 3137 request.method = "GET";
3139 request.url = GURL("https://www.example.org/"); 3138 request.url = GURL("https://www.example.org/");
3140 3139
3141 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 3140 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
3142 BoundTestNetLog log; 3141 BoundTestNetLog log;
3143 session_deps_.net_log = log.bound().net_log(); 3142 session_deps_.net_log = log.bound().net_log();
3144 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3143 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3145 3144
3146 // Since we have proxy, should try to establish tunnel. 3145 // Since we have proxy, should try to establish tunnel.
3147 MockWrite data_writes1[] = { 3146 MockWrite data_writes1[] = {
3148 MockWrite( 3147 MockWrite(
3149 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3148 "CONNECT www.example.org:443 HTTP/1.1\r\n"
3150 "Host: www.example.org\r\n" 3149 "Host: www.example.org\r\n"
3151 "Proxy-Connection: keep-alive\r\n\r\n"), 3150 "Proxy-Connection: keep-alive\r\n\r\n"),
3152 3151
3153 MockWrite( 3152 MockWrite(
3154 "GET / HTTP/1.1\r\n" 3153 "GET / HTTP/1.1\r\n"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 3199
3201 HttpRequestInfo request2; 3200 HttpRequestInfo request2;
3202 request2.method = "GET"; 3201 request2.method = "GET";
3203 request2.url = GURL("https://www.example.org/2"); 3202 request2.url = GURL("https://www.example.org/2");
3204 3203
3205 // Configure against proxy server "myproxy:70". 3204 // Configure against proxy server "myproxy:70".
3206 session_deps_.proxy_service.reset( 3205 session_deps_.proxy_service.reset(
3207 ProxyService::CreateFixed("PROXY myproxy:70")); 3206 ProxyService::CreateFixed("PROXY myproxy:70"));
3208 BoundTestNetLog log; 3207 BoundTestNetLog log;
3209 session_deps_.net_log = log.bound().net_log(); 3208 session_deps_.net_log = log.bound().net_log();
3210 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3209 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3211 3210
3212 // Since we have proxy, should try to establish tunnel. 3211 // Since we have proxy, should try to establish tunnel.
3213 MockWrite data_writes1[] = { 3212 MockWrite data_writes1[] = {
3214 MockWrite( 3213 MockWrite(
3215 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3214 "CONNECT www.example.org:443 HTTP/1.1\r\n"
3216 "Host: www.example.org\r\n" 3215 "Host: www.example.org\r\n"
3217 "Proxy-Connection: keep-alive\r\n\r\n"), 3216 "Proxy-Connection: keep-alive\r\n\r\n"),
3218 3217
3219 MockWrite( 3218 MockWrite(
3220 "GET /1 HTTP/1.1\r\n" 3219 "GET /1 HTTP/1.1\r\n"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3301 3300
3302 HttpRequestInfo request2; 3301 HttpRequestInfo request2;
3303 request2.method = "GET"; 3302 request2.method = "GET";
3304 request2.url = GURL("https://www.example.org/2"); 3303 request2.url = GURL("https://www.example.org/2");
3305 3304
3306 // Configure against proxy server "myproxy:70". 3305 // Configure against proxy server "myproxy:70".
3307 session_deps_.proxy_service.reset( 3306 session_deps_.proxy_service.reset(
3308 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 3307 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
3309 BoundTestNetLog log; 3308 BoundTestNetLog log;
3310 session_deps_.net_log = log.bound().net_log(); 3309 session_deps_.net_log = log.bound().net_log();
3311 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3310 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3312 3311
3313 // Since we have proxy, should try to establish tunnel. 3312 // Since we have proxy, should try to establish tunnel.
3314 MockWrite data_writes1[] = { 3313 MockWrite data_writes1[] = {
3315 MockWrite( 3314 MockWrite(
3316 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3315 "CONNECT www.example.org:443 HTTP/1.1\r\n"
3317 "Host: www.example.org\r\n" 3316 "Host: www.example.org\r\n"
3318 "Proxy-Connection: keep-alive\r\n\r\n"), 3317 "Proxy-Connection: keep-alive\r\n\r\n"),
3319 3318
3320 MockWrite( 3319 MockWrite(
3321 "GET /1 HTTP/1.1\r\n" 3320 "GET /1 HTTP/1.1\r\n"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3399 TEST_P(HttpNetworkTransactionTest, HttpsProxyGet) { 3398 TEST_P(HttpNetworkTransactionTest, HttpsProxyGet) {
3400 HttpRequestInfo request; 3399 HttpRequestInfo request;
3401 request.method = "GET"; 3400 request.method = "GET";
3402 request.url = GURL("http://www.example.org/"); 3401 request.url = GURL("http://www.example.org/");
3403 3402
3404 // Configure against https proxy server "proxy:70". 3403 // Configure against https proxy server "proxy:70".
3405 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3404 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
3406 "https://proxy:70")); 3405 "https://proxy:70"));
3407 BoundTestNetLog log; 3406 BoundTestNetLog log;
3408 session_deps_.net_log = log.bound().net_log(); 3407 session_deps_.net_log = log.bound().net_log();
3409 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3408 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3410 3409
3411 // Since we have proxy, should use full url 3410 // Since we have proxy, should use full url
3412 MockWrite data_writes1[] = { 3411 MockWrite data_writes1[] = {
3413 MockWrite( 3412 MockWrite(
3414 "GET http://www.example.org/ HTTP/1.1\r\n" 3413 "GET http://www.example.org/ HTTP/1.1\r\n"
3415 "Host: www.example.org\r\n" 3414 "Host: www.example.org\r\n"
3416 "Proxy-Connection: keep-alive\r\n\r\n"), 3415 "Proxy-Connection: keep-alive\r\n\r\n"),
3417 }; 3416 };
3418 3417
3419 MockRead data_reads1[] = { 3418 MockRead data_reads1[] = {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3462 HttpRequestInfo request; 3461 HttpRequestInfo request;
3463 request.method = "GET"; 3462 request.method = "GET";
3464 request.url = GURL("http://www.example.org/"); 3463 request.url = GURL("http://www.example.org/");
3465 request.load_flags = 0; 3464 request.load_flags = 0;
3466 3465
3467 // Configure against https proxy server "proxy:70". 3466 // Configure against https proxy server "proxy:70".
3468 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3467 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
3469 "https://proxy:70")); 3468 "https://proxy:70"));
3470 BoundTestNetLog log; 3469 BoundTestNetLog log;
3471 session_deps_.net_log = log.bound().net_log(); 3470 session_deps_.net_log = log.bound().net_log();
3472 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3471 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3473 3472
3474 // fetch http://www.example.org/ via SPDY 3473 // fetch http://www.example.org/ via SPDY
3475 scoped_ptr<SpdyFrame> req( 3474 scoped_ptr<SpdyFrame> req(
3476 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 3475 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
3477 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; 3476 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)};
3478 3477
3479 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 3478 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
3480 scoped_ptr<SpdyFrame> data(spdy_util_.ConstructSpdyBodyFrame(1, true)); 3479 scoped_ptr<SpdyFrame> data(spdy_util_.ConstructSpdyBodyFrame(1, true));
3481 MockRead spdy_reads[] = { 3480 MockRead spdy_reads[] = {
3482 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), 3481 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3523 HttpRequestInfo request; 3522 HttpRequestInfo request;
3524 request.method = "GET"; 3523 request.method = "GET";
3525 request.url = GURL("http://www.example.org/"); 3524 request.url = GURL("http://www.example.org/");
3526 request.load_flags = 0; 3525 request.load_flags = 0;
3527 3526
3528 // Configure SPDY proxy server "proxy:70". 3527 // Configure SPDY proxy server "proxy:70".
3529 session_deps_.proxy_service.reset( 3528 session_deps_.proxy_service.reset(
3530 ProxyService::CreateFixed("https://proxy:70")); 3529 ProxyService::CreateFixed("https://proxy:70"));
3531 BoundTestNetLog log; 3530 BoundTestNetLog log;
3532 session_deps_.net_log = log.bound().net_log(); 3531 session_deps_.net_log = log.bound().net_log();
3533 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3532 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3534 3533
3535 // Fetch http://www.example.org/ through the SPDY proxy. 3534 // Fetch http://www.example.org/ through the SPDY proxy.
3536 scoped_ptr<SpdyFrame> req( 3535 scoped_ptr<SpdyFrame> req(
3537 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 3536 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
3538 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; 3537 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)};
3539 3538
3540 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 3539 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
3541 scoped_ptr<SpdyFrame> data(spdy_util_.ConstructSpdyBodyFrame(1, true)); 3540 scoped_ptr<SpdyFrame> data(spdy_util_.ConstructSpdyBodyFrame(1, true));
3542 MockRead spdy_reads[] = { 3541 MockRead spdy_reads[] = {
3543 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), 3542 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3),
(...skipping 17 matching lines...) Expand all
3561 session_deps_.host_resolver->set_ondemand_mode(true); 3560 session_deps_.host_resolver->set_ondemand_mode(true);
3562 3561
3563 int rv = trans->Start(&request, callback1.callback(), log.bound()); 3562 int rv = trans->Start(&request, callback1.callback(), log.bound());
3564 EXPECT_EQ(ERR_IO_PENDING, rv); 3563 EXPECT_EQ(ERR_IO_PENDING, rv);
3565 3564
3566 // Race a session to the proxy, which completes first. 3565 // Race a session to the proxy, which completes first.
3567 session_deps_.host_resolver->set_ondemand_mode(false); 3566 session_deps_.host_resolver->set_ondemand_mode(false);
3568 SpdySessionKey key( 3567 SpdySessionKey key(
3569 HostPortPair("proxy", 70), ProxyServer::Direct(), PRIVACY_MODE_DISABLED); 3568 HostPortPair("proxy", 70), ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
3570 base::WeakPtr<SpdySession> spdy_session = 3569 base::WeakPtr<SpdySession> spdy_session =
3571 CreateSecureSpdySession(session.get(), key, log.bound()); 3570 CreateSecureSpdySession(session, key, log.bound());
3572 3571
3573 // Unstall the resolution begun by the transaction. 3572 // Unstall the resolution begun by the transaction.
3574 session_deps_.host_resolver->set_ondemand_mode(true); 3573 session_deps_.host_resolver->set_ondemand_mode(true);
3575 session_deps_.host_resolver->ResolveAllPending(); 3574 session_deps_.host_resolver->ResolveAllPending();
3576 3575
3577 EXPECT_FALSE(callback1.have_result()); 3576 EXPECT_FALSE(callback1.have_result());
3578 rv = callback1.WaitForResult(); 3577 rv = callback1.WaitForResult();
3579 EXPECT_EQ(OK, rv); 3578 EXPECT_EQ(OK, rv);
3580 3579
3581 const HttpResponseInfo* response = trans->GetResponseInfo(); 3580 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 11 matching lines...) Expand all
3593 HttpRequestInfo request; 3592 HttpRequestInfo request;
3594 request.method = "GET"; 3593 request.method = "GET";
3595 request.url = GURL("http://www.example.org/"); 3594 request.url = GURL("http://www.example.org/");
3596 request.load_flags = 0; 3595 request.load_flags = 0;
3597 3596
3598 // Configure against https proxy server "myproxy:70". 3597 // Configure against https proxy server "myproxy:70".
3599 session_deps_.proxy_service.reset( 3598 session_deps_.proxy_service.reset(
3600 ProxyService::CreateFixed("https://myproxy:70")); 3599 ProxyService::CreateFixed("https://myproxy:70"));
3601 BoundTestNetLog log; 3600 BoundTestNetLog log;
3602 session_deps_.net_log = log.bound().net_log(); 3601 session_deps_.net_log = log.bound().net_log();
3603 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3602 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3604 3603
3605 // The first request will be a bare GET, the second request will be a 3604 // The first request will be a bare GET, the second request will be a
3606 // GET with a Proxy-Authorization header. 3605 // GET with a Proxy-Authorization header.
3607 scoped_ptr<SpdyFrame> req_get( 3606 scoped_ptr<SpdyFrame> req_get(
3608 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 3607 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
3609 const char* const kExtraAuthorizationHeaders[] = { 3608 const char* const kExtraAuthorizationHeaders[] = {
3610 "proxy-authorization", "Basic Zm9vOmJhcg==" 3609 "proxy-authorization", "Basic Zm9vOmJhcg=="
3611 }; 3610 };
3612 scoped_ptr<SpdyFrame> req_get_authorization( 3611 scoped_ptr<SpdyFrame> req_get_authorization(
3613 spdy_util_.ConstructSpdyGet(kExtraAuthorizationHeaders, 3612 spdy_util_.ConstructSpdyGet(kExtraAuthorizationHeaders,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3694 HttpRequestInfo request; 3693 HttpRequestInfo request;
3695 request.method = "GET"; 3694 request.method = "GET";
3696 request.url = GURL("https://www.example.org/"); 3695 request.url = GURL("https://www.example.org/");
3697 request.load_flags = 0; 3696 request.load_flags = 0;
3698 3697
3699 // Configure against https proxy server "proxy:70". 3698 // Configure against https proxy server "proxy:70".
3700 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3699 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
3701 "https://proxy:70")); 3700 "https://proxy:70"));
3702 BoundTestNetLog log; 3701 BoundTestNetLog log;
3703 session_deps_.net_log = log.bound().net_log(); 3702 session_deps_.net_log = log.bound().net_log();
3704 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3703 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3705 3704
3706 scoped_ptr<HttpTransaction> trans( 3705 scoped_ptr<HttpTransaction> trans(
3707 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3706 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3708 3707
3709 // CONNECT to www.example.org:443 via SPDY 3708 // CONNECT to www.example.org:443 via SPDY
3710 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( 3709 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(
3711 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 3710 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
3712 // fetch https://www.example.org/ via HTTP 3711 // fetch https://www.example.org/ via HTTP
3713 3712
3714 const char get[] = 3713 const char get[] =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3779 HttpRequestInfo request; 3778 HttpRequestInfo request;
3780 request.method = "GET"; 3779 request.method = "GET";
3781 request.url = GURL("https://www.example.org/"); 3780 request.url = GURL("https://www.example.org/");
3782 request.load_flags = 0; 3781 request.load_flags = 0;
3783 3782
3784 // Configure against https proxy server "proxy:70". 3783 // Configure against https proxy server "proxy:70".
3785 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3784 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
3786 "https://proxy:70")); 3785 "https://proxy:70"));
3787 BoundTestNetLog log; 3786 BoundTestNetLog log;
3788 session_deps_.net_log = log.bound().net_log(); 3787 session_deps_.net_log = log.bound().net_log();
3789 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3788 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3790 3789
3791 scoped_ptr<HttpTransaction> trans( 3790 scoped_ptr<HttpTransaction> trans(
3792 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3791 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3793 3792
3794 // CONNECT to www.example.org:443 via SPDY 3793 // CONNECT to www.example.org:443 via SPDY
3795 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( 3794 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(
3796 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 3795 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
3797 // fetch https://www.example.org/ via SPDY 3796 // fetch https://www.example.org/ via SPDY
3798 const char kMyUrl[] = "https://www.example.org/"; 3797 const char kMyUrl[] = "https://www.example.org/";
3799 scoped_ptr<SpdyFrame> get( 3798 scoped_ptr<SpdyFrame> get(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3871 HttpRequestInfo request; 3870 HttpRequestInfo request;
3872 request.method = "GET"; 3871 request.method = "GET";
3873 request.url = GURL("https://www.example.org/"); 3872 request.url = GURL("https://www.example.org/");
3874 request.load_flags = 0; 3873 request.load_flags = 0;
3875 3874
3876 // Configure against https proxy server "proxy:70". 3875 // Configure against https proxy server "proxy:70".
3877 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3876 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
3878 "https://proxy:70")); 3877 "https://proxy:70"));
3879 BoundTestNetLog log; 3878 BoundTestNetLog log;
3880 session_deps_.net_log = log.bound().net_log(); 3879 session_deps_.net_log = log.bound().net_log();
3881 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3880 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3882 3881
3883 scoped_ptr<HttpTransaction> trans( 3882 scoped_ptr<HttpTransaction> trans(
3884 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3883 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3885 3884
3886 // CONNECT to www.example.org:443 via SPDY 3885 // CONNECT to www.example.org:443 via SPDY
3887 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( 3886 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(
3888 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 3887 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
3889 scoped_ptr<SpdyFrame> get( 3888 scoped_ptr<SpdyFrame> get(
3890 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 3889 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
3891 3890
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3923 3922
3924 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY 3923 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY
3925 // HTTPS Proxy to different servers. 3924 // HTTPS Proxy to different servers.
3926 TEST_P(HttpNetworkTransactionTest, 3925 TEST_P(HttpNetworkTransactionTest,
3927 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsTwoServers) { 3926 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsTwoServers) {
3928 // Configure against https proxy server "proxy:70". 3927 // Configure against https proxy server "proxy:70".
3929 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3928 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
3930 "https://proxy:70")); 3929 "https://proxy:70"));
3931 BoundTestNetLog log; 3930 BoundTestNetLog log;
3932 session_deps_.net_log = log.bound().net_log(); 3931 session_deps_.net_log = log.bound().net_log();
3933 scoped_ptr<HttpNetworkSession> session( 3932 scoped_refptr<HttpNetworkSession> session(
3934 SpdySessionDependencies::SpdyCreateSession(&session_deps_)); 3933 SpdySessionDependencies::SpdyCreateSession(&session_deps_));
3935 3934
3936 HttpRequestInfo request1; 3935 HttpRequestInfo request1;
3937 request1.method = "GET"; 3936 request1.method = "GET";
3938 request1.url = GURL("https://www.example.org/"); 3937 request1.url = GURL("https://www.example.org/");
3939 request1.load_flags = 0; 3938 request1.load_flags = 0;
3940 3939
3941 HttpRequestInfo request2; 3940 HttpRequestInfo request2;
3942 request2.method = "GET"; 3941 request2.method = "GET";
3943 request2.url = GURL("https://mail.example.org/"); 3942 request2.url = GURL("https://mail.example.org/");
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
4066 4065
4067 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY 4066 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY
4068 // HTTPS Proxy to the same server. 4067 // HTTPS Proxy to the same server.
4069 TEST_P(HttpNetworkTransactionTest, 4068 TEST_P(HttpNetworkTransactionTest,
4070 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) { 4069 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) {
4071 // Configure against https proxy server "proxy:70". 4070 // Configure against https proxy server "proxy:70".
4072 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 4071 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
4073 "https://proxy:70")); 4072 "https://proxy:70"));
4074 BoundTestNetLog log; 4073 BoundTestNetLog log;
4075 session_deps_.net_log = log.bound().net_log(); 4074 session_deps_.net_log = log.bound().net_log();
4076 scoped_ptr<HttpNetworkSession> session( 4075 scoped_refptr<HttpNetworkSession> session(
4077 SpdySessionDependencies::SpdyCreateSession(&session_deps_)); 4076 SpdySessionDependencies::SpdyCreateSession(&session_deps_));
4078 4077
4079 HttpRequestInfo request1; 4078 HttpRequestInfo request1;
4080 request1.method = "GET"; 4079 request1.method = "GET";
4081 request1.url = GURL("https://www.example.org/"); 4080 request1.url = GURL("https://www.example.org/");
4082 request1.load_flags = 0; 4081 request1.load_flags = 0;
4083 4082
4084 HttpRequestInfo request2; 4083 HttpRequestInfo request2;
4085 request2.method = "GET"; 4084 request2.method = "GET";
4086 request2.url = GURL("https://www.example.org/2"); 4085 request2.url = GURL("https://www.example.org/2");
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
4190 } 4189 }
4191 4190
4192 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS 4191 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS
4193 // Proxy to different servers. 4192 // Proxy to different servers.
4194 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyLoadTimingTwoHttpRequests) { 4193 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyLoadTimingTwoHttpRequests) {
4195 // Configure against https proxy server "proxy:70". 4194 // Configure against https proxy server "proxy:70".
4196 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 4195 session_deps_.proxy_service.reset(ProxyService::CreateFixed(
4197 "https://proxy:70")); 4196 "https://proxy:70"));
4198 BoundTestNetLog log; 4197 BoundTestNetLog log;
4199 session_deps_.net_log = log.bound().net_log(); 4198 session_deps_.net_log = log.bound().net_log();
4200 scoped_ptr<HttpNetworkSession> session( 4199 scoped_refptr<HttpNetworkSession> session(
4201 SpdySessionDependencies::SpdyCreateSession(&session_deps_)); 4200 SpdySessionDependencies::SpdyCreateSession(&session_deps_));
4202 4201
4203 HttpRequestInfo request1; 4202 HttpRequestInfo request1;
4204 request1.method = "GET"; 4203 request1.method = "GET";
4205 request1.url = GURL("http://www.example.org/"); 4204 request1.url = GURL("http://www.example.org/");
4206 request1.load_flags = 0; 4205 request1.load_flags = 0;
4207 4206
4208 HttpRequestInfo request2; 4207 HttpRequestInfo request2;
4209 request2.method = "GET"; 4208 request2.method = "GET";
4210 request2.url = GURL("http://mail.example.org/"); 4209 request2.url = GURL("http://mail.example.org/");
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
4297 request.method = "GET"; 4296 request.method = "GET";
4298 request.url = GURL("http://www.example.org/"); 4297 request.url = GURL("http://www.example.org/");
4299 // when the no authentication data flag is set. 4298 // when the no authentication data flag is set.
4300 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 4299 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
4301 4300
4302 // Configure against https proxy server "myproxy:70". 4301 // Configure against https proxy server "myproxy:70".
4303 session_deps_.proxy_service.reset( 4302 session_deps_.proxy_service.reset(
4304 ProxyService::CreateFixed("https://myproxy:70")); 4303 ProxyService::CreateFixed("https://myproxy:70"));
4305 BoundTestNetLog log; 4304 BoundTestNetLog log;
4306 session_deps_.net_log = log.bound().net_log(); 4305 session_deps_.net_log = log.bound().net_log();
4307 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4306 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4308 4307
4309 // Since we have proxy, should use full url 4308 // Since we have proxy, should use full url
4310 MockWrite data_writes1[] = { 4309 MockWrite data_writes1[] = {
4311 MockWrite( 4310 MockWrite(
4312 "GET http://www.example.org/ HTTP/1.1\r\n" 4311 "GET http://www.example.org/ HTTP/1.1\r\n"
4313 "Host: www.example.org\r\n" 4312 "Host: www.example.org\r\n"
4314 "Proxy-Connection: keep-alive\r\n\r\n"), 4313 "Proxy-Connection: keep-alive\r\n\r\n"),
4315 4314
4316 // After calling trans->RestartWithAuth(), this is the request we should 4315 // After calling trans->RestartWithAuth(), this is the request we should
4317 // be issuing -- the final header line contains the credentials. 4316 // be issuing -- the final header line contains the credentials.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4394 4393
4395 void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( 4394 void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus(
4396 const MockRead& status, int expected_status) { 4395 const MockRead& status, int expected_status) {
4397 HttpRequestInfo request; 4396 HttpRequestInfo request;
4398 request.method = "GET"; 4397 request.method = "GET";
4399 request.url = GURL("https://www.example.org/"); 4398 request.url = GURL("https://www.example.org/");
4400 request.load_flags = 0; 4399 request.load_flags = 0;
4401 4400
4402 // Configure against proxy server "myproxy:70". 4401 // Configure against proxy server "myproxy:70".
4403 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 4402 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
4404 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4403 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4405 4404
4406 // Since we have proxy, should try to establish tunnel. 4405 // Since we have proxy, should try to establish tunnel.
4407 MockWrite data_writes[] = { 4406 MockWrite data_writes[] = {
4408 MockWrite( 4407 MockWrite(
4409 "CONNECT www.example.org:443 HTTP/1.1\r\n" 4408 "CONNECT www.example.org:443 HTTP/1.1\r\n"
4410 "Host: www.example.org\r\n" 4409 "Host: www.example.org\r\n"
4411 "Proxy-Connection: keep-alive\r\n\r\n"), 4410 "Proxy-Connection: keep-alive\r\n\r\n"),
4412 }; 4411 };
4413 4412
4414 MockRead data_reads[] = { 4413 MockRead data_reads[] = {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4612 // authentication. Again, this uses basic auth for both since that is 4611 // authentication. Again, this uses basic auth for both since that is
4613 // the simplest to mock. 4612 // the simplest to mock.
4614 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { 4613 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyThenServer) {
4615 HttpRequestInfo request; 4614 HttpRequestInfo request;
4616 request.method = "GET"; 4615 request.method = "GET";
4617 request.url = GURL("http://www.example.org/"); 4616 request.url = GURL("http://www.example.org/");
4618 request.load_flags = 0; 4617 request.load_flags = 0;
4619 4618
4620 // Configure against proxy server "myproxy:70". 4619 // Configure against proxy server "myproxy:70".
4621 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 4620 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
4622 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4621 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4623 4622
4624 scoped_ptr<HttpTransaction> trans( 4623 scoped_ptr<HttpTransaction> trans(
4625 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 4624 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
4626 4625
4627 MockWrite data_writes1[] = { 4626 MockWrite data_writes1[] = {
4628 MockWrite( 4627 MockWrite(
4629 "GET http://www.example.org/ HTTP/1.1\r\n" 4628 "GET http://www.example.org/ HTTP/1.1\r\n"
4630 "Host: www.example.org\r\n" 4629 "Host: www.example.org\r\n"
4631 "Proxy-Connection: keep-alive\r\n\r\n"), 4630 "Proxy-Connection: keep-alive\r\n\r\n"),
4632 }; 4631 };
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4748 HttpRequestInfo request; 4747 HttpRequestInfo request;
4749 request.method = "GET"; 4748 request.method = "GET";
4750 request.url = GURL("http://172.22.68.17/kids/login.aspx"); 4749 request.url = GURL("http://172.22.68.17/kids/login.aspx");
4751 4750
4752 // Ensure load is not disrupted by flags which suppress behaviour specific 4751 // Ensure load is not disrupted by flags which suppress behaviour specific
4753 // to other auth schemes. 4752 // to other auth schemes.
4754 request.load_flags = LOAD_DO_NOT_USE_EMBEDDED_IDENTITY; 4753 request.load_flags = LOAD_DO_NOT_USE_EMBEDDED_IDENTITY;
4755 4754
4756 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1, 4755 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1,
4757 MockGetHostName); 4756 MockGetHostName);
4758 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4757 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4759 4758
4760 MockWrite data_writes1[] = { 4759 MockWrite data_writes1[] = {
4761 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" 4760 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n"
4762 "Host: 172.22.68.17\r\n" 4761 "Host: 172.22.68.17\r\n"
4763 "Connection: keep-alive\r\n\r\n"), 4762 "Connection: keep-alive\r\n\r\n"),
4764 }; 4763 };
4765 4764
4766 MockRead data_reads1[] = { 4765 MockRead data_reads1[] = {
4767 MockRead("HTTP/1.1 401 Access Denied\r\n"), 4766 MockRead("HTTP/1.1 401 Access Denied\r\n"),
4768 // Negotiate and NTLM are often requested together. However, we only want 4767 // Negotiate and NTLM are often requested together. However, we only want
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4877 4876
4878 // Enter a wrong password, and then the correct one. 4877 // Enter a wrong password, and then the correct one.
4879 TEST_P(HttpNetworkTransactionTest, NTLMAuth2) { 4878 TEST_P(HttpNetworkTransactionTest, NTLMAuth2) {
4880 HttpRequestInfo request; 4879 HttpRequestInfo request;
4881 request.method = "GET"; 4880 request.method = "GET";
4882 request.url = GURL("http://172.22.68.17/kids/login.aspx"); 4881 request.url = GURL("http://172.22.68.17/kids/login.aspx");
4883 request.load_flags = 0; 4882 request.load_flags = 0;
4884 4883
4885 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, 4884 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2,
4886 MockGetHostName); 4885 MockGetHostName);
4887 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4886 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4888 4887
4889 MockWrite data_writes1[] = { 4888 MockWrite data_writes1[] = {
4890 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" 4889 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n"
4891 "Host: 172.22.68.17\r\n" 4890 "Host: 172.22.68.17\r\n"
4892 "Connection: keep-alive\r\n\r\n"), 4891 "Connection: keep-alive\r\n\r\n"),
4893 }; 4892 };
4894 4893
4895 MockRead data_reads1[] = { 4894 MockRead data_reads1[] = {
4896 MockRead("HTTP/1.1 401 Access Denied\r\n"), 4895 MockRead("HTTP/1.1 401 Access Denied\r\n"),
4897 // Negotiate and NTLM are often requested together. However, we only want 4896 // Negotiate and NTLM are often requested together. However, we only want
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
5077 5076
5078 // Test reading a server response which has only headers, and no body. 5077 // Test reading a server response which has only headers, and no body.
5079 // After some maximum number of bytes is consumed, the transaction should 5078 // After some maximum number of bytes is consumed, the transaction should
5080 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. 5079 // fail with ERR_RESPONSE_HEADERS_TOO_BIG.
5081 TEST_P(HttpNetworkTransactionTest, LargeHeadersNoBody) { 5080 TEST_P(HttpNetworkTransactionTest, LargeHeadersNoBody) {
5082 HttpRequestInfo request; 5081 HttpRequestInfo request;
5083 request.method = "GET"; 5082 request.method = "GET";
5084 request.url = GURL("http://www.example.org/"); 5083 request.url = GURL("http://www.example.org/");
5085 request.load_flags = 0; 5084 request.load_flags = 0;
5086 5085
5087 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5086 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5088 scoped_ptr<HttpTransaction> trans( 5087 scoped_ptr<HttpTransaction> trans(
5089 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5088 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5090 5089
5091 // Respond with 300 kb of headers (we should fail after 256 kb). 5090 // Respond with 300 kb of headers (we should fail after 256 kb).
5092 std::string large_headers_string; 5091 std::string large_headers_string;
5093 FillLargeHeadersString(&large_headers_string, 300 * 1024); 5092 FillLargeHeadersString(&large_headers_string, 300 * 1024);
5094 5093
5095 MockRead data_reads[] = { 5094 MockRead data_reads[] = {
5096 MockRead("HTTP/1.0 200 OK\r\n"), 5095 MockRead("HTTP/1.0 200 OK\r\n"),
5097 MockRead(ASYNC, large_headers_string.data(), large_headers_string.size()), 5096 MockRead(ASYNC, large_headers_string.data(), large_headers_string.size()),
(...skipping 18 matching lines...) Expand all
5116 TEST_P(HttpNetworkTransactionTest, 5115 TEST_P(HttpNetworkTransactionTest,
5117 DontRecycleTransportSocketForSSLTunnel) { 5116 DontRecycleTransportSocketForSSLTunnel) {
5118 HttpRequestInfo request; 5117 HttpRequestInfo request;
5119 request.method = "GET"; 5118 request.method = "GET";
5120 request.url = GURL("https://www.example.org/"); 5119 request.url = GURL("https://www.example.org/");
5121 request.load_flags = 0; 5120 request.load_flags = 0;
5122 5121
5123 // Configure against proxy server "myproxy:70". 5122 // Configure against proxy server "myproxy:70".
5124 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 5123 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
5125 5124
5126 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5125 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5127 5126
5128 scoped_ptr<HttpTransaction> trans( 5127 scoped_ptr<HttpTransaction> trans(
5129 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5128 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5130 5129
5131 // Since we have proxy, should try to establish tunnel. 5130 // Since we have proxy, should try to establish tunnel.
5132 MockWrite data_writes1[] = { 5131 MockWrite data_writes1[] = {
5133 MockWrite( 5132 MockWrite(
5134 "CONNECT www.example.org:443 HTTP/1.1\r\n" 5133 "CONNECT www.example.org:443 HTTP/1.1\r\n"
5135 "Host: www.example.org\r\n" 5134 "Host: www.example.org\r\n"
5136 "Proxy-Connection: keep-alive\r\n\r\n"), 5135 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5170 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); 5169 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get()));
5171 } 5170 }
5172 5171
5173 // Make sure that we recycle a socket after reading all of the response body. 5172 // Make sure that we recycle a socket after reading all of the response body.
5174 TEST_P(HttpNetworkTransactionTest, RecycleSocket) { 5173 TEST_P(HttpNetworkTransactionTest, RecycleSocket) {
5175 HttpRequestInfo request; 5174 HttpRequestInfo request;
5176 request.method = "GET"; 5175 request.method = "GET";
5177 request.url = GURL("http://www.example.org/"); 5176 request.url = GURL("http://www.example.org/");
5178 request.load_flags = 0; 5177 request.load_flags = 0;
5179 5178
5180 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5179 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5181 5180
5182 scoped_ptr<HttpTransaction> trans( 5181 scoped_ptr<HttpTransaction> trans(
5183 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5182 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5184 5183
5185 MockRead data_reads[] = { 5184 MockRead data_reads[] = {
5186 // A part of the response body is received with the response headers. 5185 // A part of the response body is received with the response headers.
5187 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), 5186 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"),
5188 // The rest of the response body is received in two parts. 5187 // The rest of the response body is received in two parts.
5189 MockRead("lo"), 5188 MockRead("lo"),
5190 MockRead(" world"), 5189 MockRead(" world"),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
5249 5248
5250 SSLSocketDataProvider ssl(ASYNC, OK); 5249 SSLSocketDataProvider ssl(ASYNC, OK);
5251 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 5250 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
5252 5251
5253 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 5252 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
5254 data_writes, arraysize(data_writes)); 5253 data_writes, arraysize(data_writes));
5255 session_deps_.socket_factory->AddSocketDataProvider(&data); 5254 session_deps_.socket_factory->AddSocketDataProvider(&data);
5256 5255
5257 TestCompletionCallback callback; 5256 TestCompletionCallback callback;
5258 5257
5259 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5258 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5260 scoped_ptr<HttpTransaction> trans( 5259 scoped_ptr<HttpTransaction> trans(
5261 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5260 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5262 5261
5263 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5262 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5264 5263
5265 EXPECT_EQ(ERR_IO_PENDING, rv); 5264 EXPECT_EQ(ERR_IO_PENDING, rv);
5266 EXPECT_EQ(OK, callback.WaitForResult()); 5265 EXPECT_EQ(OK, callback.WaitForResult());
5267 5266
5268 const HttpResponseInfo* response = trans->GetResponseInfo(); 5267 const HttpResponseInfo* response = trans->GetResponseInfo();
5269 ASSERT_TRUE(response != NULL); 5268 ASSERT_TRUE(response != NULL);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5319 5318
5320 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 5319 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
5321 data_writes, arraysize(data_writes)); 5320 data_writes, arraysize(data_writes));
5322 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), 5321 StaticSocketDataProvider data2(data_reads, arraysize(data_reads),
5323 data_writes, arraysize(data_writes)); 5322 data_writes, arraysize(data_writes));
5324 session_deps_.socket_factory->AddSocketDataProvider(&data); 5323 session_deps_.socket_factory->AddSocketDataProvider(&data);
5325 session_deps_.socket_factory->AddSocketDataProvider(&data2); 5324 session_deps_.socket_factory->AddSocketDataProvider(&data2);
5326 5325
5327 TestCompletionCallback callback; 5326 TestCompletionCallback callback;
5328 5327
5329 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5328 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5330 scoped_ptr<HttpTransaction> trans( 5329 scoped_ptr<HttpTransaction> trans(
5331 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5330 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5332 5331
5333 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5332 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5334 5333
5335 EXPECT_EQ(ERR_IO_PENDING, rv); 5334 EXPECT_EQ(ERR_IO_PENDING, rv);
5336 EXPECT_EQ(OK, callback.WaitForResult()); 5335 EXPECT_EQ(OK, callback.WaitForResult());
5337 5336
5338 const HttpResponseInfo* response = trans->GetResponseInfo(); 5337 const HttpResponseInfo* response = trans->GetResponseInfo();
5339 ASSERT_TRUE(response != NULL); 5338 ASSERT_TRUE(response != NULL);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5387 TEST_P(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { 5386 TEST_P(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) {
5388 HttpRequestInfo request; 5387 HttpRequestInfo request;
5389 request.method = "GET"; 5388 request.method = "GET";
5390 request.url = GURL( 5389 request.url = GURL(
5391 "http://www.example.org/csi?v=3&s=web&action=&" 5390 "http://www.example.org/csi?v=3&s=web&action=&"
5392 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" 5391 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&"
5393 "e=17259,18167,19592,19773,19981,20133,20173,20233&" 5392 "e=17259,18167,19592,19773,19981,20133,20173,20233&"
5394 "rt=prt.2642,ol.2649,xjs.2951"); 5393 "rt=prt.2642,ol.2649,xjs.2951");
5395 request.load_flags = 0; 5394 request.load_flags = 0;
5396 5395
5397 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5396 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5398 5397
5399 scoped_ptr<HttpTransaction> trans( 5398 scoped_ptr<HttpTransaction> trans(
5400 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5399 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5401 5400
5402 MockRead data_reads[] = { 5401 MockRead data_reads[] = {
5403 MockRead("HTTP/1.1 204 No Content\r\n" 5402 MockRead("HTTP/1.1 204 No Content\r\n"
5404 "Content-Length: 0\r\n" 5403 "Content-Length: 0\r\n"
5405 "Content-Type: text/html\r\n\r\n"), 5404 "Content-Type: text/html\r\n\r\n"),
5406 MockRead("junk"), // Should not be read!! 5405 MockRead("junk"), // Should not be read!!
5407 MockRead(SYNCHRONOUS, OK), 5406 MockRead(SYNCHRONOUS, OK),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5453 request[0].load_flags = 0; 5452 request[0].load_flags = 0;
5454 // Transaction 2: a POST request. Reuses the socket kept alive from 5453 // Transaction 2: a POST request. Reuses the socket kept alive from
5455 // transaction 1. The first attempts fails when writing the POST data. 5454 // transaction 1. The first attempts fails when writing the POST data.
5456 // This causes the transaction to retry with a new socket. The second 5455 // This causes the transaction to retry with a new socket. The second
5457 // attempt succeeds. 5456 // attempt succeeds.
5458 request[1].method = "POST"; 5457 request[1].method = "POST";
5459 request[1].url = GURL("http://www.google.com/login.cgi"); 5458 request[1].url = GURL("http://www.google.com/login.cgi");
5460 request[1].upload_data_stream = &upload_data_stream; 5459 request[1].upload_data_stream = &upload_data_stream;
5461 request[1].load_flags = 0; 5460 request[1].load_flags = 0;
5462 5461
5463 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5462 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5464 5463
5465 // The first socket is used for transaction 1 and the first attempt of 5464 // The first socket is used for transaction 1 and the first attempt of
5466 // transaction 2. 5465 // transaction 2.
5467 5466
5468 // The response of transaction 1. 5467 // The response of transaction 1.
5469 MockRead data_reads1[] = { 5468 MockRead data_reads1[] = {
5470 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"), 5469 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"),
5471 MockRead("hello world"), 5470 MockRead("hello world"),
5472 MockRead(SYNCHRONOUS, OK), 5471 MockRead(SYNCHRONOUS, OK),
5473 }; 5472 };
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5531 5530
5532 // Test the request-challenge-retry sequence for basic auth when there is 5531 // Test the request-challenge-retry sequence for basic auth when there is
5533 // an identity in the URL. The request should be sent as normal, but when 5532 // an identity in the URL. The request should be sent as normal, but when
5534 // it fails the identity from the URL is used to answer the challenge. 5533 // it fails the identity from the URL is used to answer the challenge.
5535 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURL) { 5534 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURL) {
5536 HttpRequestInfo request; 5535 HttpRequestInfo request;
5537 request.method = "GET"; 5536 request.method = "GET";
5538 request.url = GURL("http://foo:b@r@www.example.org/"); 5537 request.url = GURL("http://foo:b@r@www.example.org/");
5539 request.load_flags = LOAD_NORMAL; 5538 request.load_flags = LOAD_NORMAL;
5540 5539
5541 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5540 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5542 scoped_ptr<HttpTransaction> trans( 5541 scoped_ptr<HttpTransaction> trans(
5543 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5542 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5544 5543
5545 // The password contains an escaped character -- for this test to pass it 5544 // The password contains an escaped character -- for this test to pass it
5546 // will need to be unescaped by HttpNetworkTransaction. 5545 // will need to be unescaped by HttpNetworkTransaction.
5547 EXPECT_EQ("b%40r", request.url.password()); 5546 EXPECT_EQ("b%40r", request.url.password());
5548 5547
5549 MockWrite data_writes1[] = { 5548 MockWrite data_writes1[] = {
5550 MockWrite( 5549 MockWrite(
5551 "GET / HTTP/1.1\r\n" 5550 "GET / HTTP/1.1\r\n"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5614 // once. 5613 // once.
5615 TEST_P(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { 5614 TEST_P(HttpNetworkTransactionTest, WrongAuthIdentityInURL) {
5616 HttpRequestInfo request; 5615 HttpRequestInfo request;
5617 request.method = "GET"; 5616 request.method = "GET";
5618 // Note: the URL has a username:password in it. The password "baz" is 5617 // Note: the URL has a username:password in it. The password "baz" is
5619 // wrong (should be "bar"). 5618 // wrong (should be "bar").
5620 request.url = GURL("http://foo:baz@www.example.org/"); 5619 request.url = GURL("http://foo:baz@www.example.org/");
5621 5620
5622 request.load_flags = LOAD_NORMAL; 5621 request.load_flags = LOAD_NORMAL;
5623 5622
5624 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5623 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5625 scoped_ptr<HttpTransaction> trans( 5624 scoped_ptr<HttpTransaction> trans(
5626 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5625 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5627 5626
5628 MockWrite data_writes1[] = { 5627 MockWrite data_writes1[] = {
5629 MockWrite( 5628 MockWrite(
5630 "GET / HTTP/1.1\r\n" 5629 "GET / HTTP/1.1\r\n"
5631 "Host: www.example.org\r\n" 5630 "Host: www.example.org\r\n"
5632 "Connection: keep-alive\r\n\r\n"), 5631 "Connection: keep-alive\r\n\r\n"),
5633 }; 5632 };
5634 5633
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
5725 5724
5726 // Test the request-challenge-retry sequence for basic auth when there is a 5725 // Test the request-challenge-retry sequence for basic auth when there is a
5727 // correct identity in the URL, but its use is being suppressed. The identity 5726 // correct identity in the URL, but its use is being suppressed. The identity
5728 // from the URL should never be used. 5727 // from the URL should never be used.
5729 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURLSuppressed) { 5728 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURLSuppressed) {
5730 HttpRequestInfo request; 5729 HttpRequestInfo request;
5731 request.method = "GET"; 5730 request.method = "GET";
5732 request.url = GURL("http://foo:bar@www.example.org/"); 5731 request.url = GURL("http://foo:bar@www.example.org/");
5733 request.load_flags = LOAD_DO_NOT_USE_EMBEDDED_IDENTITY; 5732 request.load_flags = LOAD_DO_NOT_USE_EMBEDDED_IDENTITY;
5734 5733
5735 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5734 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5736 scoped_ptr<HttpTransaction> trans( 5735 scoped_ptr<HttpTransaction> trans(
5737 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5736 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5738 5737
5739 MockWrite data_writes1[] = { 5738 MockWrite data_writes1[] = {
5740 MockWrite( 5739 MockWrite(
5741 "GET / HTTP/1.1\r\n" 5740 "GET / HTTP/1.1\r\n"
5742 "Host: www.example.org\r\n" 5741 "Host: www.example.org\r\n"
5743 "Connection: keep-alive\r\n\r\n"), 5742 "Connection: keep-alive\r\n\r\n"),
5744 }; 5743 };
5745 5744
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5799 // There is no challenge info, since the identity worked. 5798 // There is no challenge info, since the identity worked.
5800 EXPECT_TRUE(response->auth_challenge.get() == NULL); 5799 EXPECT_TRUE(response->auth_challenge.get() == NULL);
5801 EXPECT_EQ(100, response->headers->GetContentLength()); 5800 EXPECT_EQ(100, response->headers->GetContentLength());
5802 5801
5803 // Empty the current queue. 5802 // Empty the current queue.
5804 base::MessageLoop::current()->RunUntilIdle(); 5803 base::MessageLoop::current()->RunUntilIdle();
5805 } 5804 }
5806 5805
5807 // Test that previously tried username/passwords for a realm get re-used. 5806 // Test that previously tried username/passwords for a realm get re-used.
5808 TEST_P(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { 5807 TEST_P(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) {
5809 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5808 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5810 5809
5811 // Transaction 1: authenticate (foo, bar) on MyRealm1 5810 // Transaction 1: authenticate (foo, bar) on MyRealm1
5812 { 5811 {
5813 HttpRequestInfo request; 5812 HttpRequestInfo request;
5814 request.method = "GET"; 5813 request.method = "GET";
5815 request.url = GURL("http://www.example.org/x/y/z"); 5814 request.url = GURL("http://www.example.org/x/y/z");
5816 request.load_flags = 0; 5815 request.load_flags = 0;
5817 5816
5818 scoped_ptr<HttpTransaction> trans( 5817 scoped_ptr<HttpTransaction> trans(
5819 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5818 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
6199 6198
6200 // Tests that nonce count increments when multiple auth attempts 6199 // Tests that nonce count increments when multiple auth attempts
6201 // are started with the same nonce. 6200 // are started with the same nonce.
6202 TEST_P(HttpNetworkTransactionTest, DigestPreAuthNonceCount) { 6201 TEST_P(HttpNetworkTransactionTest, DigestPreAuthNonceCount) {
6203 HttpAuthHandlerDigest::Factory* digest_factory = 6202 HttpAuthHandlerDigest::Factory* digest_factory =
6204 new HttpAuthHandlerDigest::Factory(); 6203 new HttpAuthHandlerDigest::Factory();
6205 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator = 6204 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator =
6206 new HttpAuthHandlerDigest::FixedNonceGenerator("0123456789abcdef"); 6205 new HttpAuthHandlerDigest::FixedNonceGenerator("0123456789abcdef");
6207 digest_factory->set_nonce_generator(nonce_generator); 6206 digest_factory->set_nonce_generator(nonce_generator);
6208 session_deps_.http_auth_handler_factory.reset(digest_factory); 6207 session_deps_.http_auth_handler_factory.reset(digest_factory);
6209 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6208 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6210 6209
6211 // Transaction 1: authenticate (foo, bar) on MyRealm1 6210 // Transaction 1: authenticate (foo, bar) on MyRealm1
6212 { 6211 {
6213 HttpRequestInfo request; 6212 HttpRequestInfo request;
6214 request.method = "GET"; 6213 request.method = "GET";
6215 request.url = GURL("http://www.example.org/x/y/z"); 6214 request.url = GURL("http://www.example.org/x/y/z");
6216 request.load_flags = 0; 6215 request.load_flags = 0;
6217 6216
6218 scoped_ptr<HttpTransaction> trans( 6217 scoped_ptr<HttpTransaction> trans(
6219 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6218 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
6331 6330
6332 const HttpResponseInfo* response = trans->GetResponseInfo(); 6331 const HttpResponseInfo* response = trans->GetResponseInfo();
6333 ASSERT_TRUE(response != NULL); 6332 ASSERT_TRUE(response != NULL);
6334 EXPECT_TRUE(response->auth_challenge.get() == NULL); 6333 EXPECT_TRUE(response->auth_challenge.get() == NULL);
6335 } 6334 }
6336 } 6335 }
6337 6336
6338 // Test the ResetStateForRestart() private method. 6337 // Test the ResetStateForRestart() private method.
6339 TEST_P(HttpNetworkTransactionTest, ResetStateForRestart) { 6338 TEST_P(HttpNetworkTransactionTest, ResetStateForRestart) {
6340 // Create a transaction (the dependencies aren't important). 6339 // Create a transaction (the dependencies aren't important).
6341 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6340 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6342 scoped_ptr<HttpNetworkTransaction> trans( 6341 scoped_ptr<HttpNetworkTransaction> trans(
6343 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6342 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6344 6343
6345 // Setup some state (which we expect ResetStateForRestart() will clear). 6344 // Setup some state (which we expect ResetStateForRestart() will clear).
6346 trans->read_buf_ = new IOBuffer(15); 6345 trans->read_buf_ = new IOBuffer(15);
6347 trans->read_buf_len_ = 15; 6346 trans->read_buf_len_ = 15;
6348 trans->request_headers_.SetHeader("Authorization", "NTLM"); 6347 trans->request_headers_.SetHeader("Authorization", "NTLM");
6349 6348
6350 // Setup state in response_ 6349 // Setup state in response_
6351 HttpResponseInfo* response = &trans->response_; 6350 HttpResponseInfo* response = &trans->response_;
(...skipping 26 matching lines...) Expand all
6378 EXPECT_FALSE(response->vary_data.is_valid()); 6377 EXPECT_FALSE(response->vary_data.is_valid());
6379 } 6378 }
6380 6379
6381 // Test HTTPS connections to a site with a bad certificate 6380 // Test HTTPS connections to a site with a bad certificate
6382 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificate) { 6381 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificate) {
6383 HttpRequestInfo request; 6382 HttpRequestInfo request;
6384 request.method = "GET"; 6383 request.method = "GET";
6385 request.url = GURL("https://www.example.org/"); 6384 request.url = GURL("https://www.example.org/");
6386 request.load_flags = 0; 6385 request.load_flags = 0;
6387 6386
6388 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6387 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6389 scoped_ptr<HttpTransaction> trans( 6388 scoped_ptr<HttpTransaction> trans(
6390 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6389 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6391 6390
6392 MockWrite data_writes[] = { 6391 MockWrite data_writes[] = {
6393 MockWrite( 6392 MockWrite(
6394 "GET / HTTP/1.1\r\n" 6393 "GET / HTTP/1.1\r\n"
6395 "Host: www.example.org\r\n" 6394 "Host: www.example.org\r\n"
6396 "Connection: keep-alive\r\n\r\n"), 6395 "Connection: keep-alive\r\n\r\n"),
6397 }; 6396 };
6398 6397
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
6486 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate); 6485 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate);
6487 session_deps_.socket_factory->AddSocketDataProvider(&data); 6486 session_deps_.socket_factory->AddSocketDataProvider(&data);
6488 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad); 6487 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad);
6489 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 6488 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
6490 6489
6491 TestCompletionCallback callback; 6490 TestCompletionCallback callback;
6492 6491
6493 for (int i = 0; i < 2; i++) { 6492 for (int i = 0; i < 2; i++) {
6494 session_deps_.socket_factory->ResetNextMockIndexes(); 6493 session_deps_.socket_factory->ResetNextMockIndexes();
6495 6494
6496 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6495 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6497 scoped_ptr<HttpTransaction> trans( 6496 scoped_ptr<HttpTransaction> trans(
6498 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6497 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6499 6498
6500 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 6499 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
6501 EXPECT_EQ(ERR_IO_PENDING, rv); 6500 EXPECT_EQ(ERR_IO_PENDING, rv);
6502 6501
6503 rv = callback.WaitForResult(); 6502 rv = callback.WaitForResult();
6504 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 6503 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
6505 6504
6506 rv = trans->RestartIgnoringLastError(callback.callback()); 6505 rv = trans->RestartIgnoringLastError(callback.callback());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6552 data_writes, arraysize(data_writes)); 6551 data_writes, arraysize(data_writes));
6553 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 6552 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
6554 SSLSocketDataProvider tunnel_ssl(ASYNC, OK); // SSL through the tunnel 6553 SSLSocketDataProvider tunnel_ssl(ASYNC, OK); // SSL through the tunnel
6555 6554
6556 session_deps_.socket_factory->AddSocketDataProvider(&data); 6555 session_deps_.socket_factory->AddSocketDataProvider(&data);
6557 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 6556 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
6558 session_deps_.socket_factory->AddSSLSocketDataProvider(&tunnel_ssl); 6557 session_deps_.socket_factory->AddSSLSocketDataProvider(&tunnel_ssl);
6559 6558
6560 TestCompletionCallback callback; 6559 TestCompletionCallback callback;
6561 6560
6562 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6561 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6563 scoped_ptr<HttpTransaction> trans( 6562 scoped_ptr<HttpTransaction> trans(
6564 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6563 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6565 6564
6566 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 6565 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
6567 EXPECT_EQ(ERR_IO_PENDING, rv); 6566 EXPECT_EQ(ERR_IO_PENDING, rv);
6568 6567
6569 rv = callback.WaitForResult(); 6568 rv = callback.WaitForResult();
6570 EXPECT_EQ(OK, rv); 6569 EXPECT_EQ(OK, rv);
6571 const HttpResponseInfo* response = trans->GetResponseInfo(); 6570 const HttpResponseInfo* response = trans->GetResponseInfo();
6572 6571
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6611 6610
6612 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 6611 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
6613 data_writes, arraysize(data_writes)); 6612 data_writes, arraysize(data_writes));
6614 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 6613 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
6615 6614
6616 session_deps_.socket_factory->AddSocketDataProvider(&data); 6615 session_deps_.socket_factory->AddSocketDataProvider(&data);
6617 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 6616 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
6618 6617
6619 TestCompletionCallback callback; 6618 TestCompletionCallback callback;
6620 6619
6621 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6620 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6622 scoped_ptr<HttpTransaction> trans( 6621 scoped_ptr<HttpTransaction> trans(
6623 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6622 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6624 6623
6625 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 6624 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
6626 EXPECT_EQ(ERR_IO_PENDING, rv); 6625 EXPECT_EQ(ERR_IO_PENDING, rv);
6627 6626
6628 rv = callback.WaitForResult(); 6627 rv = callback.WaitForResult();
6629 EXPECT_EQ(OK, rv); 6628 EXPECT_EQ(OK, rv);
6630 const HttpResponseInfo* response = trans->GetResponseInfo(); 6629 const HttpResponseInfo* response = trans->GetResponseInfo();
6631 6630
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
6693 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes, 6692 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes,
6694 arraysize(data_writes)); 6693 arraysize(data_writes));
6695 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 6694 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
6696 proxy_ssl.SetNextProto(GetParam()); 6695 proxy_ssl.SetNextProto(GetParam());
6697 6696
6698 session_deps_.socket_factory->AddSocketDataProvider(&data); 6697 session_deps_.socket_factory->AddSocketDataProvider(&data);
6699 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 6698 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
6700 6699
6701 TestCompletionCallback callback; 6700 TestCompletionCallback callback;
6702 6701
6703 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6702 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6704 scoped_ptr<HttpTransaction> trans( 6703 scoped_ptr<HttpTransaction> trans(
6705 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6704 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6706 6705
6707 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 6706 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
6708 EXPECT_EQ(ERR_IO_PENDING, rv); 6707 EXPECT_EQ(ERR_IO_PENDING, rv);
6709 6708
6710 rv = callback.WaitForResult(); 6709 rv = callback.WaitForResult();
6711 EXPECT_EQ(OK, rv); 6710 EXPECT_EQ(OK, rv);
6712 const HttpResponseInfo* response = trans->GetResponseInfo(); 6711 const HttpResponseInfo* response = trans->GetResponseInfo();
6713 6712
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6746 6745
6747 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 6746 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
6748 data_writes, arraysize(data_writes)); 6747 data_writes, arraysize(data_writes));
6749 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 6748 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
6750 6749
6751 session_deps_.socket_factory->AddSocketDataProvider(&data); 6750 session_deps_.socket_factory->AddSocketDataProvider(&data);
6752 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 6751 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
6753 6752
6754 TestCompletionCallback callback; 6753 TestCompletionCallback callback;
6755 6754
6756 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6755 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6757 scoped_ptr<HttpTransaction> trans( 6756 scoped_ptr<HttpTransaction> trans(
6758 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6757 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6759 6758
6760 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 6759 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
6761 EXPECT_EQ(ERR_IO_PENDING, rv); 6760 EXPECT_EQ(ERR_IO_PENDING, rv);
6762 6761
6763 rv = callback.WaitForResult(); 6762 rv = callback.WaitForResult();
6764 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 6763 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
6765 6764
6766 // TODO(ttuttle): Anything else to check here? 6765 // TODO(ttuttle): Anything else to check here?
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6804 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes, 6803 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes,
6805 arraysize(data_writes)); 6804 arraysize(data_writes));
6806 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy 6805 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy
6807 proxy_ssl.SetNextProto(GetParam()); 6806 proxy_ssl.SetNextProto(GetParam());
6808 6807
6809 session_deps_.socket_factory->AddSocketDataProvider(&data); 6808 session_deps_.socket_factory->AddSocketDataProvider(&data);
6810 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); 6809 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy_ssl);
6811 6810
6812 TestCompletionCallback callback; 6811 TestCompletionCallback callback;
6813 6812
6814 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6813 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6815 scoped_ptr<HttpTransaction> trans( 6814 scoped_ptr<HttpTransaction> trans(
6816 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6815 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6817 6816
6818 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 6817 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
6819 EXPECT_EQ(ERR_IO_PENDING, rv); 6818 EXPECT_EQ(ERR_IO_PENDING, rv);
6820 6819
6821 rv = callback.WaitForResult(); 6820 rv = callback.WaitForResult();
6822 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 6821 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
6823 6822
6824 // TODO(ttuttle): Anything else to check here? 6823 // TODO(ttuttle): Anything else to check here?
6825 } 6824 }
6826 6825
6827 // Test the request-challenge-retry sequence for basic auth, through 6826 // Test the request-challenge-retry sequence for basic auth, through
6828 // a SPDY proxy over a single SPDY session. 6827 // a SPDY proxy over a single SPDY session.
6829 TEST_P(HttpNetworkTransactionTest, BasicAuthSpdyProxy) { 6828 TEST_P(HttpNetworkTransactionTest, BasicAuthSpdyProxy) {
6830 HttpRequestInfo request; 6829 HttpRequestInfo request;
6831 request.method = "GET"; 6830 request.method = "GET";
6832 request.url = GURL("https://www.example.org/"); 6831 request.url = GURL("https://www.example.org/");
6833 // when the no authentication data flag is set. 6832 // when the no authentication data flag is set.
6834 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 6833 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
6835 6834
6836 // Configure against https proxy server "myproxy:70". 6835 // Configure against https proxy server "myproxy:70".
6837 session_deps_.proxy_service.reset( 6836 session_deps_.proxy_service.reset(
6838 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); 6837 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"));
6839 BoundTestNetLog log; 6838 BoundTestNetLog log;
6840 session_deps_.net_log = log.bound().net_log(); 6839 session_deps_.net_log = log.bound().net_log();
6841 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6840 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6842 6841
6843 // Since we have proxy, should try to establish tunnel. 6842 // Since we have proxy, should try to establish tunnel.
6844 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyConnect( 6843 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyConnect(
6845 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 6844 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
6846 scoped_ptr<SpdyFrame> rst( 6845 scoped_ptr<SpdyFrame> rst(
6847 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 6846 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
6848 6847
6849 // After calling trans->RestartWithAuth(), this is the request we should 6848 // After calling trans->RestartWithAuth(), this is the request we should
6850 // be issuing -- the final header line contains the credentials. 6849 // be issuing -- the final header line contains the credentials.
6851 const char* const kAuthCredentials[] = { 6850 const char* const kAuthCredentials[] = {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
6976 6975
6977 // Configure against https proxy server "myproxy:70". 6976 // Configure against https proxy server "myproxy:70".
6978 session_deps_.proxy_service.reset( 6977 session_deps_.proxy_service.reset(
6979 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); 6978 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"));
6980 BoundTestNetLog log; 6979 BoundTestNetLog log;
6981 session_deps_.net_log = log.bound().net_log(); 6980 session_deps_.net_log = log.bound().net_log();
6982 6981
6983 // Enable cross-origin push. 6982 // Enable cross-origin push.
6984 session_deps_.trusted_spdy_proxy = "myproxy:70"; 6983 session_deps_.trusted_spdy_proxy = "myproxy:70";
6985 6984
6986 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6985 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6987 6986
6988 scoped_ptr<SpdyFrame> stream1_syn( 6987 scoped_ptr<SpdyFrame> stream1_syn(
6989 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 6988 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
6990 6989
6991 MockWrite spdy_writes[] = { 6990 MockWrite spdy_writes[] = {
6992 CreateMockWrite(*stream1_syn, 0, ASYNC), 6991 CreateMockWrite(*stream1_syn, 0, ASYNC),
6993 }; 6992 };
6994 6993
6995 scoped_ptr<SpdyFrame> 6994 scoped_ptr<SpdyFrame>
6996 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 6995 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
7090 7089
7091 // Configure against https proxy server "myproxy:70". 7090 // Configure against https proxy server "myproxy:70".
7092 session_deps_.proxy_service.reset( 7091 session_deps_.proxy_service.reset(
7093 ProxyService::CreateFixed("https://myproxy:70")); 7092 ProxyService::CreateFixed("https://myproxy:70"));
7094 BoundTestNetLog log; 7093 BoundTestNetLog log;
7095 session_deps_.net_log = log.bound().net_log(); 7094 session_deps_.net_log = log.bound().net_log();
7096 7095
7097 // Enable cross-origin push. 7096 // Enable cross-origin push.
7098 session_deps_.trusted_spdy_proxy = "myproxy:70"; 7097 session_deps_.trusted_spdy_proxy = "myproxy:70";
7099 7098
7100 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7099 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7101 7100
7102 scoped_ptr<SpdyFrame> stream1_syn( 7101 scoped_ptr<SpdyFrame> stream1_syn(
7103 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 7102 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
7104 7103
7105 scoped_ptr<SpdyFrame> push_rst( 7104 scoped_ptr<SpdyFrame> push_rst(
7106 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); 7105 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM));
7107 7106
7108 MockWrite spdy_writes[] = { 7107 MockWrite spdy_writes[] = {
7109 CreateMockWrite(*stream1_syn, 0, ASYNC), CreateMockWrite(*push_rst, 3), 7108 CreateMockWrite(*stream1_syn, 0, ASYNC), CreateMockWrite(*push_rst, 3),
7110 }; 7109 };
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
7219 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate); 7218 session_deps_.socket_factory->AddSocketDataProvider(&ssl_bad_certificate);
7220 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad); 7219 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_bad);
7221 7220
7222 // SSL to the proxy, then CONNECT request, then valid SSL certificate 7221 // SSL to the proxy, then CONNECT request, then valid SSL certificate
7223 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 7222 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
7224 session_deps_.socket_factory->AddSocketDataProvider(&data); 7223 session_deps_.socket_factory->AddSocketDataProvider(&data);
7225 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 7224 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
7226 7225
7227 TestCompletionCallback callback; 7226 TestCompletionCallback callback;
7228 7227
7229 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7228 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7230 scoped_ptr<HttpTransaction> trans( 7229 scoped_ptr<HttpTransaction> trans(
7231 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7230 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7232 7231
7233 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 7232 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
7234 EXPECT_EQ(ERR_IO_PENDING, rv); 7233 EXPECT_EQ(ERR_IO_PENDING, rv);
7235 7234
7236 rv = callback.WaitForResult(); 7235 rv = callback.WaitForResult();
7237 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 7236 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
7238 7237
7239 rv = trans->RestartIgnoringLastError(callback.callback()); 7238 rv = trans->RestartIgnoringLastError(callback.callback());
7240 EXPECT_EQ(ERR_IO_PENDING, rv); 7239 EXPECT_EQ(ERR_IO_PENDING, rv);
7241 7240
7242 rv = callback.WaitForResult(); 7241 rv = callback.WaitForResult();
7243 EXPECT_EQ(OK, rv); 7242 EXPECT_EQ(OK, rv);
7244 7243
7245 const HttpResponseInfo* response = trans->GetResponseInfo(); 7244 const HttpResponseInfo* response = trans->GetResponseInfo();
7246 7245
7247 ASSERT_TRUE(response != NULL); 7246 ASSERT_TRUE(response != NULL);
7248 EXPECT_EQ(100, response->headers->GetContentLength()); 7247 EXPECT_EQ(100, response->headers->GetContentLength());
7249 } 7248 }
7250 7249
7251 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgent) { 7250 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgent) {
7252 HttpRequestInfo request; 7251 HttpRequestInfo request;
7253 request.method = "GET"; 7252 request.method = "GET";
7254 request.url = GURL("http://www.example.org/"); 7253 request.url = GURL("http://www.example.org/");
7255 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 7254 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
7256 "Chromium Ultra Awesome X Edition"); 7255 "Chromium Ultra Awesome X Edition");
7257 7256
7258 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7257 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7259 scoped_ptr<HttpTransaction> trans( 7258 scoped_ptr<HttpTransaction> trans(
7260 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7259 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7261 7260
7262 MockWrite data_writes[] = { 7261 MockWrite data_writes[] = {
7263 MockWrite( 7262 MockWrite(
7264 "GET / HTTP/1.1\r\n" 7263 "GET / HTTP/1.1\r\n"
7265 "Host: www.example.org\r\n" 7264 "Host: www.example.org\r\n"
7266 "Connection: keep-alive\r\n" 7265 "Connection: keep-alive\r\n"
7267 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), 7266 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"),
7268 }; 7267 };
(...skipping 20 matching lines...) Expand all
7289 } 7288 }
7290 7289
7291 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) { 7290 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) {
7292 HttpRequestInfo request; 7291 HttpRequestInfo request;
7293 request.method = "GET"; 7292 request.method = "GET";
7294 request.url = GURL("https://www.example.org/"); 7293 request.url = GURL("https://www.example.org/");
7295 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 7294 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
7296 "Chromium Ultra Awesome X Edition"); 7295 "Chromium Ultra Awesome X Edition");
7297 7296
7298 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 7297 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
7299 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7298 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7300 scoped_ptr<HttpTransaction> trans( 7299 scoped_ptr<HttpTransaction> trans(
7301 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7300 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7302 7301
7303 MockWrite data_writes[] = { 7302 MockWrite data_writes[] = {
7304 MockWrite( 7303 MockWrite(
7305 "CONNECT www.example.org:443 HTTP/1.1\r\n" 7304 "CONNECT www.example.org:443 HTTP/1.1\r\n"
7306 "Host: www.example.org\r\n" 7305 "Host: www.example.org\r\n"
7307 "Proxy-Connection: keep-alive\r\n" 7306 "Proxy-Connection: keep-alive\r\n"
7308 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), 7307 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"),
7309 }; 7308 };
(...skipping 19 matching lines...) Expand all
7329 } 7328 }
7330 7329
7331 TEST_P(HttpNetworkTransactionTest, BuildRequest_Referer) { 7330 TEST_P(HttpNetworkTransactionTest, BuildRequest_Referer) {
7332 HttpRequestInfo request; 7331 HttpRequestInfo request;
7333 request.method = "GET"; 7332 request.method = "GET";
7334 request.url = GURL("http://www.example.org/"); 7333 request.url = GURL("http://www.example.org/");
7335 request.load_flags = 0; 7334 request.load_flags = 0;
7336 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer, 7335 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer,
7337 "http://the.previous.site.com/"); 7336 "http://the.previous.site.com/");
7338 7337
7339 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7338 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7340 scoped_ptr<HttpTransaction> trans( 7339 scoped_ptr<HttpTransaction> trans(
7341 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7340 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7342 7341
7343 MockWrite data_writes[] = { 7342 MockWrite data_writes[] = {
7344 MockWrite( 7343 MockWrite(
7345 "GET / HTTP/1.1\r\n" 7344 "GET / HTTP/1.1\r\n"
7346 "Host: www.example.org\r\n" 7345 "Host: www.example.org\r\n"
7347 "Connection: keep-alive\r\n" 7346 "Connection: keep-alive\r\n"
7348 "Referer: http://the.previous.site.com/\r\n\r\n"), 7347 "Referer: http://the.previous.site.com/\r\n\r\n"),
7349 }; 7348 };
(...skipping 17 matching lines...) Expand all
7367 7366
7368 rv = callback.WaitForResult(); 7367 rv = callback.WaitForResult();
7369 EXPECT_EQ(OK, rv); 7368 EXPECT_EQ(OK, rv);
7370 } 7369 }
7371 7370
7372 TEST_P(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) { 7371 TEST_P(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) {
7373 HttpRequestInfo request; 7372 HttpRequestInfo request;
7374 request.method = "POST"; 7373 request.method = "POST";
7375 request.url = GURL("http://www.example.org/"); 7374 request.url = GURL("http://www.example.org/");
7376 7375
7377 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7376 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7378 scoped_ptr<HttpTransaction> trans( 7377 scoped_ptr<HttpTransaction> trans(
7379 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7378 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7380 7379
7381 MockWrite data_writes[] = { 7380 MockWrite data_writes[] = {
7382 MockWrite( 7381 MockWrite(
7383 "POST / HTTP/1.1\r\n" 7382 "POST / HTTP/1.1\r\n"
7384 "Host: www.example.org\r\n" 7383 "Host: www.example.org\r\n"
7385 "Connection: keep-alive\r\n" 7384 "Connection: keep-alive\r\n"
7386 "Content-Length: 0\r\n\r\n"), 7385 "Content-Length: 0\r\n\r\n"),
7387 }; 7386 };
(...skipping 17 matching lines...) Expand all
7405 7404
7406 rv = callback.WaitForResult(); 7405 rv = callback.WaitForResult();
7407 EXPECT_EQ(OK, rv); 7406 EXPECT_EQ(OK, rv);
7408 } 7407 }
7409 7408
7410 TEST_P(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) { 7409 TEST_P(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) {
7411 HttpRequestInfo request; 7410 HttpRequestInfo request;
7412 request.method = "PUT"; 7411 request.method = "PUT";
7413 request.url = GURL("http://www.example.org/"); 7412 request.url = GURL("http://www.example.org/");
7414 7413
7415 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7414 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7416 scoped_ptr<HttpTransaction> trans( 7415 scoped_ptr<HttpTransaction> trans(
7417 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7416 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7418 7417
7419 MockWrite data_writes[] = { 7418 MockWrite data_writes[] = {
7420 MockWrite( 7419 MockWrite(
7421 "PUT / HTTP/1.1\r\n" 7420 "PUT / HTTP/1.1\r\n"
7422 "Host: www.example.org\r\n" 7421 "Host: www.example.org\r\n"
7423 "Connection: keep-alive\r\n" 7422 "Connection: keep-alive\r\n"
7424 "Content-Length: 0\r\n\r\n"), 7423 "Content-Length: 0\r\n\r\n"),
7425 }; 7424 };
(...skipping 17 matching lines...) Expand all
7443 7442
7444 rv = callback.WaitForResult(); 7443 rv = callback.WaitForResult();
7445 EXPECT_EQ(OK, rv); 7444 EXPECT_EQ(OK, rv);
7446 } 7445 }
7447 7446
7448 TEST_P(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) { 7447 TEST_P(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) {
7449 HttpRequestInfo request; 7448 HttpRequestInfo request;
7450 request.method = "HEAD"; 7449 request.method = "HEAD";
7451 request.url = GURL("http://www.example.org/"); 7450 request.url = GURL("http://www.example.org/");
7452 7451
7453 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7452 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7454 scoped_ptr<HttpTransaction> trans( 7453 scoped_ptr<HttpTransaction> trans(
7455 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7454 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7456 7455
7457 MockWrite data_writes[] = { 7456 MockWrite data_writes[] = {
7458 MockWrite("HEAD / HTTP/1.1\r\n" 7457 MockWrite("HEAD / HTTP/1.1\r\n"
7459 "Host: www.example.org\r\n" 7458 "Host: www.example.org\r\n"
7460 "Connection: keep-alive\r\n\r\n"), 7459 "Connection: keep-alive\r\n\r\n"),
7461 }; 7460 };
7462 7461
7463 // Lastly, the server responds with the actual content. 7462 // Lastly, the server responds with the actual content.
(...skipping 16 matching lines...) Expand all
7480 rv = callback.WaitForResult(); 7479 rv = callback.WaitForResult();
7481 EXPECT_EQ(OK, rv); 7480 EXPECT_EQ(OK, rv);
7482 } 7481 }
7483 7482
7484 TEST_P(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) { 7483 TEST_P(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) {
7485 HttpRequestInfo request; 7484 HttpRequestInfo request;
7486 request.method = "GET"; 7485 request.method = "GET";
7487 request.url = GURL("http://www.example.org/"); 7486 request.url = GURL("http://www.example.org/");
7488 request.load_flags = LOAD_BYPASS_CACHE; 7487 request.load_flags = LOAD_BYPASS_CACHE;
7489 7488
7490 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7489 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7491 scoped_ptr<HttpTransaction> trans( 7490 scoped_ptr<HttpTransaction> trans(
7492 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7491 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7493 7492
7494 MockWrite data_writes[] = { 7493 MockWrite data_writes[] = {
7495 MockWrite( 7494 MockWrite(
7496 "GET / HTTP/1.1\r\n" 7495 "GET / HTTP/1.1\r\n"
7497 "Host: www.example.org\r\n" 7496 "Host: www.example.org\r\n"
7498 "Connection: keep-alive\r\n" 7497 "Connection: keep-alive\r\n"
7499 "Pragma: no-cache\r\n" 7498 "Pragma: no-cache\r\n"
7500 "Cache-Control: no-cache\r\n\r\n"), 7499 "Cache-Control: no-cache\r\n\r\n"),
(...skipping 20 matching lines...) Expand all
7521 EXPECT_EQ(OK, rv); 7520 EXPECT_EQ(OK, rv);
7522 } 7521 }
7523 7522
7524 TEST_P(HttpNetworkTransactionTest, 7523 TEST_P(HttpNetworkTransactionTest,
7525 BuildRequest_CacheControlValidateCache) { 7524 BuildRequest_CacheControlValidateCache) {
7526 HttpRequestInfo request; 7525 HttpRequestInfo request;
7527 request.method = "GET"; 7526 request.method = "GET";
7528 request.url = GURL("http://www.example.org/"); 7527 request.url = GURL("http://www.example.org/");
7529 request.load_flags = LOAD_VALIDATE_CACHE; 7528 request.load_flags = LOAD_VALIDATE_CACHE;
7530 7529
7531 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7530 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7532 scoped_ptr<HttpTransaction> trans( 7531 scoped_ptr<HttpTransaction> trans(
7533 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7532 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7534 7533
7535 MockWrite data_writes[] = { 7534 MockWrite data_writes[] = {
7536 MockWrite( 7535 MockWrite(
7537 "GET / HTTP/1.1\r\n" 7536 "GET / HTTP/1.1\r\n"
7538 "Host: www.example.org\r\n" 7537 "Host: www.example.org\r\n"
7539 "Connection: keep-alive\r\n" 7538 "Connection: keep-alive\r\n"
7540 "Cache-Control: max-age=0\r\n\r\n"), 7539 "Cache-Control: max-age=0\r\n\r\n"),
7541 }; 7540 };
(...skipping 18 matching lines...) Expand all
7560 rv = callback.WaitForResult(); 7559 rv = callback.WaitForResult();
7561 EXPECT_EQ(OK, rv); 7560 EXPECT_EQ(OK, rv);
7562 } 7561 }
7563 7562
7564 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) { 7563 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) {
7565 HttpRequestInfo request; 7564 HttpRequestInfo request;
7566 request.method = "GET"; 7565 request.method = "GET";
7567 request.url = GURL("http://www.example.org/"); 7566 request.url = GURL("http://www.example.org/");
7568 request.extra_headers.SetHeader("FooHeader", "Bar"); 7567 request.extra_headers.SetHeader("FooHeader", "Bar");
7569 7568
7570 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7569 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7571 scoped_ptr<HttpTransaction> trans( 7570 scoped_ptr<HttpTransaction> trans(
7572 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7571 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7573 7572
7574 MockWrite data_writes[] = { 7573 MockWrite data_writes[] = {
7575 MockWrite( 7574 MockWrite(
7576 "GET / HTTP/1.1\r\n" 7575 "GET / HTTP/1.1\r\n"
7577 "Host: www.example.org\r\n" 7576 "Host: www.example.org\r\n"
7578 "Connection: keep-alive\r\n" 7577 "Connection: keep-alive\r\n"
7579 "FooHeader: Bar\r\n\r\n"), 7578 "FooHeader: Bar\r\n\r\n"),
7580 }; 7579 };
(...skipping 20 matching lines...) Expand all
7601 } 7600 }
7602 7601
7603 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) { 7602 TEST_P(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) {
7604 HttpRequestInfo request; 7603 HttpRequestInfo request;
7605 request.method = "GET"; 7604 request.method = "GET";
7606 request.url = GURL("http://www.example.org/"); 7605 request.url = GURL("http://www.example.org/");
7607 request.extra_headers.SetHeader("referer", "www.foo.com"); 7606 request.extra_headers.SetHeader("referer", "www.foo.com");
7608 request.extra_headers.SetHeader("hEllo", "Kitty"); 7607 request.extra_headers.SetHeader("hEllo", "Kitty");
7609 request.extra_headers.SetHeader("FoO", "bar"); 7608 request.extra_headers.SetHeader("FoO", "bar");
7610 7609
7611 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7610 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7612 scoped_ptr<HttpTransaction> trans( 7611 scoped_ptr<HttpTransaction> trans(
7613 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7612 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7614 7613
7615 MockWrite data_writes[] = { 7614 MockWrite data_writes[] = {
7616 MockWrite( 7615 MockWrite(
7617 "GET / HTTP/1.1\r\n" 7616 "GET / HTTP/1.1\r\n"
7618 "Host: www.example.org\r\n" 7617 "Host: www.example.org\r\n"
7619 "Connection: keep-alive\r\n" 7618 "Connection: keep-alive\r\n"
7620 "referer: www.foo.com\r\n" 7619 "referer: www.foo.com\r\n"
7621 "hEllo: Kitty\r\n" 7620 "hEllo: Kitty\r\n"
(...skipping 25 matching lines...) Expand all
7647 HttpRequestInfo request; 7646 HttpRequestInfo request;
7648 request.method = "GET"; 7647 request.method = "GET";
7649 request.url = GURL("http://www.example.org/"); 7648 request.url = GURL("http://www.example.org/");
7650 request.load_flags = 0; 7649 request.load_flags = 0;
7651 7650
7652 session_deps_.proxy_service.reset( 7651 session_deps_.proxy_service.reset(
7653 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080")); 7652 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080"));
7654 TestNetLog net_log; 7653 TestNetLog net_log;
7655 session_deps_.net_log = &net_log; 7654 session_deps_.net_log = &net_log;
7656 7655
7657 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7656 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7658 scoped_ptr<HttpTransaction> trans( 7657 scoped_ptr<HttpTransaction> trans(
7659 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7658 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7660 7659
7661 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; 7660 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
7662 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 7661 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
7663 7662
7664 MockWrite data_writes[] = { 7663 MockWrite data_writes[] = {
7665 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)), 7664 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)),
7666 MockWrite( 7665 MockWrite(
7667 "GET / HTTP/1.1\r\n" 7666 "GET / HTTP/1.1\r\n"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
7706 HttpRequestInfo request; 7705 HttpRequestInfo request;
7707 request.method = "GET"; 7706 request.method = "GET";
7708 request.url = GURL("https://www.example.org/"); 7707 request.url = GURL("https://www.example.org/");
7709 request.load_flags = 0; 7708 request.load_flags = 0;
7710 7709
7711 session_deps_.proxy_service.reset( 7710 session_deps_.proxy_service.reset(
7712 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080")); 7711 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080"));
7713 TestNetLog net_log; 7712 TestNetLog net_log;
7714 session_deps_.net_log = &net_log; 7713 session_deps_.net_log = &net_log;
7715 7714
7716 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7715 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7717 scoped_ptr<HttpTransaction> trans( 7716 scoped_ptr<HttpTransaction> trans(
7718 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7717 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7719 7718
7720 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 }; 7719 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 };
7721 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 7720 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
7722 7721
7723 MockWrite data_writes[] = { 7722 MockWrite data_writes[] = {
7724 MockWrite(ASYNC, reinterpret_cast<char*>(write_buffer), 7723 MockWrite(ASYNC, reinterpret_cast<char*>(write_buffer),
7725 arraysize(write_buffer)), 7724 arraysize(write_buffer)),
7726 MockWrite( 7725 MockWrite(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7770 HttpRequestInfo request; 7769 HttpRequestInfo request;
7771 request.method = "GET"; 7770 request.method = "GET";
7772 request.url = GURL("http://www.example.org/"); 7771 request.url = GURL("http://www.example.org/");
7773 request.load_flags = 0; 7772 request.load_flags = 0;
7774 7773
7775 session_deps_.proxy_service.reset( 7774 session_deps_.proxy_service.reset(
7776 ProxyService::CreateFixed("socks4://myproxy:1080")); 7775 ProxyService::CreateFixed("socks4://myproxy:1080"));
7777 TestNetLog net_log; 7776 TestNetLog net_log;
7778 session_deps_.net_log = &net_log; 7777 session_deps_.net_log = &net_log;
7779 7778
7780 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7779 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7781 scoped_ptr<HttpTransaction> trans( 7780 scoped_ptr<HttpTransaction> trans(
7782 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7781 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7783 7782
7784 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; 7783 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
7785 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 7784 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
7786 7785
7787 MockWrite data_writes[] = { 7786 MockWrite data_writes[] = {
7788 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)), 7787 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)),
7789 MockWrite( 7788 MockWrite(
7790 "GET / HTTP/1.1\r\n" 7789 "GET / HTTP/1.1\r\n"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
7829 HttpRequestInfo request; 7828 HttpRequestInfo request;
7830 request.method = "GET"; 7829 request.method = "GET";
7831 request.url = GURL("http://www.example.org/"); 7830 request.url = GURL("http://www.example.org/");
7832 request.load_flags = 0; 7831 request.load_flags = 0;
7833 7832
7834 session_deps_.proxy_service.reset( 7833 session_deps_.proxy_service.reset(
7835 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080")); 7834 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080"));
7836 TestNetLog net_log; 7835 TestNetLog net_log;
7837 session_deps_.net_log = &net_log; 7836 session_deps_.net_log = &net_log;
7838 7837
7839 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7838 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7840 scoped_ptr<HttpTransaction> trans( 7839 scoped_ptr<HttpTransaction> trans(
7841 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7840 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7842 7841
7843 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 7842 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
7844 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 7843 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
7845 const char kSOCKS5OkRequest[] = { 7844 const char kSOCKS5OkRequest[] = {
7846 0x05, // Version 7845 0x05, // Version
7847 0x01, // Command (CONNECT) 7846 0x01, // Command (CONNECT)
7848 0x00, // Reserved. 7847 0x00, // Reserved.
7849 0x03, // Address type (DOMAINNAME). 7848 0x03, // Address type (DOMAINNAME).
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
7901 HttpRequestInfo request; 7900 HttpRequestInfo request;
7902 request.method = "GET"; 7901 request.method = "GET";
7903 request.url = GURL("https://www.example.org/"); 7902 request.url = GURL("https://www.example.org/");
7904 request.load_flags = 0; 7903 request.load_flags = 0;
7905 7904
7906 session_deps_.proxy_service.reset( 7905 session_deps_.proxy_service.reset(
7907 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080")); 7906 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080"));
7908 TestNetLog net_log; 7907 TestNetLog net_log;
7909 session_deps_.net_log = &net_log; 7908 session_deps_.net_log = &net_log;
7910 7909
7911 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7910 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7912 scoped_ptr<HttpTransaction> trans( 7911 scoped_ptr<HttpTransaction> trans(
7913 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7912 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7914 7913
7915 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 7914 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
7916 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 7915 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
7917 const unsigned char kSOCKS5OkRequest[] = { 7916 const unsigned char kSOCKS5OkRequest[] = {
7918 0x05, // Version 7917 0x05, // Version
7919 0x01, // Command (CONNECT) 7918 0x01, // Command (CONNECT)
7920 0x00, // Reserved. 7919 0x00, // Reserved.
7921 0x03, // Address type (DOMAINNAME). 7920 0x03, // Address type (DOMAINNAME).
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
7978 7977
7979 // Tests that for connection endpoints the group names are correctly set. 7978 // Tests that for connection endpoints the group names are correctly set.
7980 7979
7981 struct GroupNameTest { 7980 struct GroupNameTest {
7982 std::string proxy_server; 7981 std::string proxy_server;
7983 std::string url; 7982 std::string url;
7984 std::string expected_group_name; 7983 std::string expected_group_name;
7985 bool ssl; 7984 bool ssl;
7986 }; 7985 };
7987 7986
7988 scoped_ptr<HttpNetworkSession> SetupSessionForGroupNameTests( 7987 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests(
7989 NextProto next_proto, 7988 NextProto next_proto,
7990 SpdySessionDependencies* session_deps_) { 7989 SpdySessionDependencies* session_deps_) {
7991 scoped_ptr<HttpNetworkSession> session(CreateSession(session_deps_)); 7990 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps_));
7992 7991
7993 base::WeakPtr<HttpServerProperties> http_server_properties = 7992 base::WeakPtr<HttpServerProperties> http_server_properties =
7994 session->http_server_properties(); 7993 session->http_server_properties();
7995 AlternativeService alternative_service( 7994 AlternativeService alternative_service(
7996 AlternateProtocolFromNextProto(next_proto), "", 443); 7995 AlternateProtocolFromNextProto(next_proto), "", 443);
7997 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 7996 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
7998 http_server_properties->SetAlternativeService( 7997 http_server_properties->SetAlternativeService(
7999 HostPortPair("host.with.alternate", 80), alternative_service, 1.0, 7998 HostPortPair("host.with.alternate", 80), alternative_service, 1.0,
8000 expiration); 7999 expiration);
8001 8000
8002 return session; 8001 return session;
8003 } 8002 }
8004 8003
8005 int GroupNameTransactionHelper(const std::string& url, 8004 int GroupNameTransactionHelper(
8006 HttpNetworkSession* session) { 8005 const std::string& url,
8006 const scoped_refptr<HttpNetworkSession>& session) {
8007 HttpRequestInfo request; 8007 HttpRequestInfo request;
8008 request.method = "GET"; 8008 request.method = "GET";
8009 request.url = GURL(url); 8009 request.url = GURL(url);
8010 request.load_flags = 0; 8010 request.load_flags = 0;
8011 8011
8012 scoped_ptr<HttpTransaction> trans( 8012 scoped_ptr<HttpTransaction> trans(
8013 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); 8013 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8014 8014
8015 TestCompletionCallback callback; 8015 TestCompletionCallback callback;
8016 8016
8017 // We do not complete this request, the dtor will clean the transaction up. 8017 // We do not complete this request, the dtor will clean the transaction up.
8018 return trans->Start(&request, callback.callback(), BoundNetLog()); 8018 return trans->Start(&request, callback.callback(), BoundNetLog());
8019 } 8019 }
8020 8020
8021 } // namespace 8021 } // namespace
8022 8022
8023 TEST_P(HttpNetworkTransactionTest, GroupNameForDirectConnections) { 8023 TEST_P(HttpNetworkTransactionTest, GroupNameForDirectConnections) {
(...skipping 30 matching lines...) Expand all
8054 "ssl/host.with.alternate:443", 8054 "ssl/host.with.alternate:443",
8055 true, 8055 true,
8056 }, 8056 },
8057 }; 8057 };
8058 8058
8059 session_deps_.use_alternative_services = true; 8059 session_deps_.use_alternative_services = true;
8060 8060
8061 for (size_t i = 0; i < arraysize(tests); ++i) { 8061 for (size_t i = 0; i < arraysize(tests); ++i) {
8062 session_deps_.proxy_service.reset( 8062 session_deps_.proxy_service.reset(
8063 ProxyService::CreateFixed(tests[i].proxy_server)); 8063 ProxyService::CreateFixed(tests[i].proxy_server));
8064 scoped_ptr<HttpNetworkSession> session( 8064 scoped_refptr<HttpNetworkSession> session(
8065 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8065 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8066 8066
8067 HttpNetworkSessionPeer peer(session.get()); 8067 HttpNetworkSessionPeer peer(session);
8068 CaptureGroupNameTransportSocketPool* transport_conn_pool = 8068 CaptureGroupNameTransportSocketPool* transport_conn_pool =
8069 new CaptureGroupNameTransportSocketPool(NULL, NULL); 8069 new CaptureGroupNameTransportSocketPool(NULL, NULL);
8070 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 8070 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
8071 new CaptureGroupNameSSLSocketPool(NULL, NULL); 8071 new CaptureGroupNameSSLSocketPool(NULL, NULL);
8072 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager( 8072 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager(
8073 new MockClientSocketPoolManager); 8073 new MockClientSocketPoolManager);
8074 mock_pool_manager->SetTransportSocketPool(transport_conn_pool); 8074 mock_pool_manager->SetTransportSocketPool(transport_conn_pool);
8075 mock_pool_manager->SetSSLSocketPool(ssl_conn_pool); 8075 mock_pool_manager->SetSSLSocketPool(ssl_conn_pool);
8076 peer.SetClientSocketPoolManager(mock_pool_manager.Pass()); 8076 peer.SetClientSocketPoolManager(mock_pool_manager.Pass());
8077 8077
8078 EXPECT_EQ(ERR_IO_PENDING, 8078 EXPECT_EQ(ERR_IO_PENDING,
8079 GroupNameTransactionHelper(tests[i].url, session.get())); 8079 GroupNameTransactionHelper(tests[i].url, session));
8080 if (tests[i].ssl) 8080 if (tests[i].ssl)
8081 EXPECT_EQ(tests[i].expected_group_name, 8081 EXPECT_EQ(tests[i].expected_group_name,
8082 ssl_conn_pool->last_group_name_received()); 8082 ssl_conn_pool->last_group_name_received());
8083 else 8083 else
8084 EXPECT_EQ(tests[i].expected_group_name, 8084 EXPECT_EQ(tests[i].expected_group_name,
8085 transport_conn_pool->last_group_name_received()); 8085 transport_conn_pool->last_group_name_received());
8086 } 8086 }
8087 } 8087 }
8088 8088
8089 TEST_P(HttpNetworkTransactionTest, GroupNameForHTTPProxyConnections) { 8089 TEST_P(HttpNetworkTransactionTest, GroupNameForHTTPProxyConnections) {
(...skipping 26 matching lines...) Expand all
8116 "ftp/ftp.google.com:21", 8116 "ftp/ftp.google.com:21",
8117 false, 8117 false,
8118 }, 8118 },
8119 }; 8119 };
8120 8120
8121 session_deps_.use_alternative_services = true; 8121 session_deps_.use_alternative_services = true;
8122 8122
8123 for (size_t i = 0; i < arraysize(tests); ++i) { 8123 for (size_t i = 0; i < arraysize(tests); ++i) {
8124 session_deps_.proxy_service.reset( 8124 session_deps_.proxy_service.reset(
8125 ProxyService::CreateFixed(tests[i].proxy_server)); 8125 ProxyService::CreateFixed(tests[i].proxy_server));
8126 scoped_ptr<HttpNetworkSession> session( 8126 scoped_refptr<HttpNetworkSession> session(
8127 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8127 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8128 8128
8129 HttpNetworkSessionPeer peer(session.get()); 8129 HttpNetworkSessionPeer peer(session);
8130 8130
8131 HostPortPair proxy_host("http_proxy", 80); 8131 HostPortPair proxy_host("http_proxy", 80);
8132 CaptureGroupNameHttpProxySocketPool* http_proxy_pool = 8132 CaptureGroupNameHttpProxySocketPool* http_proxy_pool =
8133 new CaptureGroupNameHttpProxySocketPool(NULL, NULL); 8133 new CaptureGroupNameHttpProxySocketPool(NULL, NULL);
8134 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 8134 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
8135 new CaptureGroupNameSSLSocketPool(NULL, NULL); 8135 new CaptureGroupNameSSLSocketPool(NULL, NULL);
8136 8136
8137 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager( 8137 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager(
8138 new MockClientSocketPoolManager); 8138 new MockClientSocketPoolManager);
8139 mock_pool_manager->SetSocketPoolForHTTPProxy(proxy_host, http_proxy_pool); 8139 mock_pool_manager->SetSocketPoolForHTTPProxy(proxy_host, http_proxy_pool);
8140 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); 8140 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool);
8141 peer.SetClientSocketPoolManager(mock_pool_manager.Pass()); 8141 peer.SetClientSocketPoolManager(mock_pool_manager.Pass());
8142 8142
8143 EXPECT_EQ(ERR_IO_PENDING, 8143 EXPECT_EQ(ERR_IO_PENDING,
8144 GroupNameTransactionHelper(tests[i].url, session.get())); 8144 GroupNameTransactionHelper(tests[i].url, session));
8145 if (tests[i].ssl) 8145 if (tests[i].ssl)
8146 EXPECT_EQ(tests[i].expected_group_name, 8146 EXPECT_EQ(tests[i].expected_group_name,
8147 ssl_conn_pool->last_group_name_received()); 8147 ssl_conn_pool->last_group_name_received());
8148 else 8148 else
8149 EXPECT_EQ(tests[i].expected_group_name, 8149 EXPECT_EQ(tests[i].expected_group_name,
8150 http_proxy_pool->last_group_name_received()); 8150 http_proxy_pool->last_group_name_received());
8151 } 8151 }
8152 } 8152 }
8153 8153
8154 TEST_P(HttpNetworkTransactionTest, GroupNameForSOCKSConnections) { 8154 TEST_P(HttpNetworkTransactionTest, GroupNameForSOCKSConnections) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
8186 "socks4/ssl/host.with.alternate:443", 8186 "socks4/ssl/host.with.alternate:443",
8187 true, 8187 true,
8188 }, 8188 },
8189 }; 8189 };
8190 8190
8191 session_deps_.use_alternative_services = true; 8191 session_deps_.use_alternative_services = true;
8192 8192
8193 for (size_t i = 0; i < arraysize(tests); ++i) { 8193 for (size_t i = 0; i < arraysize(tests); ++i) {
8194 session_deps_.proxy_service.reset( 8194 session_deps_.proxy_service.reset(
8195 ProxyService::CreateFixed(tests[i].proxy_server)); 8195 ProxyService::CreateFixed(tests[i].proxy_server));
8196 scoped_ptr<HttpNetworkSession> session( 8196 scoped_refptr<HttpNetworkSession> session(
8197 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8197 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8198 8198
8199 HttpNetworkSessionPeer peer(session.get()); 8199 HttpNetworkSessionPeer peer(session);
8200 8200
8201 HostPortPair proxy_host("socks_proxy", 1080); 8201 HostPortPair proxy_host("socks_proxy", 1080);
8202 CaptureGroupNameSOCKSSocketPool* socks_conn_pool = 8202 CaptureGroupNameSOCKSSocketPool* socks_conn_pool =
8203 new CaptureGroupNameSOCKSSocketPool(NULL, NULL); 8203 new CaptureGroupNameSOCKSSocketPool(NULL, NULL);
8204 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 8204 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
8205 new CaptureGroupNameSSLSocketPool(NULL, NULL); 8205 new CaptureGroupNameSSLSocketPool(NULL, NULL);
8206 8206
8207 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager( 8207 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager(
8208 new MockClientSocketPoolManager); 8208 new MockClientSocketPoolManager);
8209 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool); 8209 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool);
8210 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); 8210 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool);
8211 peer.SetClientSocketPoolManager(mock_pool_manager.Pass()); 8211 peer.SetClientSocketPoolManager(mock_pool_manager.Pass());
8212 8212
8213 scoped_ptr<HttpTransaction> trans( 8213 scoped_ptr<HttpTransaction> trans(
8214 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8214 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8215 8215
8216 EXPECT_EQ(ERR_IO_PENDING, 8216 EXPECT_EQ(ERR_IO_PENDING,
8217 GroupNameTransactionHelper(tests[i].url, session.get())); 8217 GroupNameTransactionHelper(tests[i].url, session));
8218 if (tests[i].ssl) 8218 if (tests[i].ssl)
8219 EXPECT_EQ(tests[i].expected_group_name, 8219 EXPECT_EQ(tests[i].expected_group_name,
8220 ssl_conn_pool->last_group_name_received()); 8220 ssl_conn_pool->last_group_name_received());
8221 else 8221 else
8222 EXPECT_EQ(tests[i].expected_group_name, 8222 EXPECT_EQ(tests[i].expected_group_name,
8223 socks_conn_pool->last_group_name_received()); 8223 socks_conn_pool->last_group_name_received());
8224 } 8224 }
8225 } 8225 }
8226 8226
8227 TEST_P(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) { 8227 TEST_P(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) {
8228 HttpRequestInfo request; 8228 HttpRequestInfo request;
8229 request.method = "GET"; 8229 request.method = "GET";
8230 request.url = GURL("http://www.example.org/"); 8230 request.url = GURL("http://www.example.org/");
8231 8231
8232 session_deps_.proxy_service.reset( 8232 session_deps_.proxy_service.reset(
8233 ProxyService::CreateFixed("myproxy:70;foobar:80")); 8233 ProxyService::CreateFixed("myproxy:70;foobar:80"));
8234 8234
8235 // This simulates failure resolving all hostnames; that means we will fail 8235 // This simulates failure resolving all hostnames; that means we will fail
8236 // connecting to both proxies (myproxy:70 and foobar:80). 8236 // connecting to both proxies (myproxy:70 and foobar:80).
8237 session_deps_.host_resolver->rules()->AddSimulatedFailure("*"); 8237 session_deps_.host_resolver->rules()->AddSimulatedFailure("*");
8238 8238
8239 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8239 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8240 scoped_ptr<HttpTransaction> trans( 8240 scoped_ptr<HttpTransaction> trans(
8241 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8241 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8242 8242
8243 TestCompletionCallback callback; 8243 TestCompletionCallback callback;
8244 8244
8245 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8245 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8246 EXPECT_EQ(ERR_IO_PENDING, rv); 8246 EXPECT_EQ(ERR_IO_PENDING, rv);
8247 8247
8248 rv = callback.WaitForResult(); 8248 rv = callback.WaitForResult();
8249 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); 8249 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv);
8250 } 8250 }
8251 8251
8252 // Base test to make sure that when the load flags for a request specify to 8252 // Base test to make sure that when the load flags for a request specify to
8253 // bypass the cache, the DNS cache is not used. 8253 // bypass the cache, the DNS cache is not used.
8254 void HttpNetworkTransactionTest::BypassHostCacheOnRefreshHelper( 8254 void HttpNetworkTransactionTest::BypassHostCacheOnRefreshHelper(
8255 int load_flags) { 8255 int load_flags) {
8256 // Issue a request, asking to bypass the cache(s). 8256 // Issue a request, asking to bypass the cache(s).
8257 HttpRequestInfo request; 8257 HttpRequestInfo request;
8258 request.method = "GET"; 8258 request.method = "GET";
8259 request.load_flags = load_flags; 8259 request.load_flags = load_flags;
8260 request.url = GURL("http://www.example.org/"); 8260 request.url = GURL("http://www.example.org/");
8261 8261
8262 // Select a host resolver that does caching. 8262 // Select a host resolver that does caching.
8263 session_deps_.host_resolver.reset(new MockCachingHostResolver); 8263 session_deps_.host_resolver.reset(new MockCachingHostResolver);
8264 8264
8265 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8265 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8266 scoped_ptr<HttpTransaction> trans( 8266 scoped_ptr<HttpTransaction> trans(
8267 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8267 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8268 8268
8269 // Warm up the host cache so it has an entry for "www.example.org". 8269 // Warm up the host cache so it has an entry for "www.example.org".
8270 AddressList addrlist; 8270 AddressList addrlist;
8271 TestCompletionCallback callback; 8271 TestCompletionCallback callback;
8272 int rv = session_deps_.host_resolver->Resolve( 8272 int rv = session_deps_.host_resolver->Resolve(
8273 HostResolver::RequestInfo(HostPortPair("www.example.org", 80)), 8273 HostResolver::RequestInfo(HostPortPair("www.example.org", 80)),
8274 DEFAULT_PRIORITY, &addrlist, callback.callback(), NULL, BoundNetLog()); 8274 DEFAULT_PRIORITY, &addrlist, callback.callback(), NULL, BoundNetLog());
8275 EXPECT_EQ(ERR_IO_PENDING, rv); 8275 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
8324 request.method = "GET"; 8324 request.method = "GET";
8325 request.url = GURL("http://www.foo.com/"); 8325 request.url = GURL("http://www.foo.com/");
8326 request.load_flags = 0; 8326 request.load_flags = 0;
8327 8327
8328 MockWrite write_failure[] = { 8328 MockWrite write_failure[] = {
8329 MockWrite(ASYNC, ERR_CONNECTION_RESET), 8329 MockWrite(ASYNC, ERR_CONNECTION_RESET),
8330 }; 8330 };
8331 StaticSocketDataProvider data(NULL, 0, 8331 StaticSocketDataProvider data(NULL, 0,
8332 write_failure, arraysize(write_failure)); 8332 write_failure, arraysize(write_failure));
8333 session_deps_.socket_factory->AddSocketDataProvider(&data); 8333 session_deps_.socket_factory->AddSocketDataProvider(&data);
8334 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8334 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8335 8335
8336 TestCompletionCallback callback; 8336 TestCompletionCallback callback;
8337 8337
8338 scoped_ptr<HttpTransaction> trans( 8338 scoped_ptr<HttpTransaction> trans(
8339 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8339 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8340 8340
8341 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8341 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8342 EXPECT_EQ(ERR_IO_PENDING, rv); 8342 EXPECT_EQ(ERR_IO_PENDING, rv);
8343 8343
8344 rv = callback.WaitForResult(); 8344 rv = callback.WaitForResult();
8345 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 8345 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
8346 } 8346 }
8347 8347
8348 // Check that a connection closed after the start of the headers finishes ok. 8348 // Check that a connection closed after the start of the headers finishes ok.
8349 TEST_P(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { 8349 TEST_P(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) {
8350 HttpRequestInfo request; 8350 HttpRequestInfo request;
8351 request.method = "GET"; 8351 request.method = "GET";
8352 request.url = GURL("http://www.foo.com/"); 8352 request.url = GURL("http://www.foo.com/");
8353 request.load_flags = 0; 8353 request.load_flags = 0;
8354 8354
8355 MockRead data_reads[] = { 8355 MockRead data_reads[] = {
8356 MockRead("HTTP/1."), 8356 MockRead("HTTP/1."),
8357 MockRead(SYNCHRONOUS, OK), 8357 MockRead(SYNCHRONOUS, OK),
8358 }; 8358 };
8359 8359
8360 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 8360 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
8361 session_deps_.socket_factory->AddSocketDataProvider(&data); 8361 session_deps_.socket_factory->AddSocketDataProvider(&data);
8362 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8362 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8363 8363
8364 TestCompletionCallback callback; 8364 TestCompletionCallback callback;
8365 8365
8366 scoped_ptr<HttpTransaction> trans( 8366 scoped_ptr<HttpTransaction> trans(
8367 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8367 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8368 8368
8369 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8369 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8370 EXPECT_EQ(ERR_IO_PENDING, rv); 8370 EXPECT_EQ(ERR_IO_PENDING, rv);
8371 8371
8372 rv = callback.WaitForResult(); 8372 rv = callback.WaitForResult();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
8426 MockRead data_reads2[] = { 8426 MockRead data_reads2[] = {
8427 MockRead("HTTP/1.1 200 OK\r\n"), 8427 MockRead("HTTP/1.1 200 OK\r\n"),
8428 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 8428 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
8429 MockRead("Content-Length: 100\r\n\r\n"), 8429 MockRead("Content-Length: 100\r\n\r\n"),
8430 MockRead(SYNCHRONOUS, OK), 8430 MockRead(SYNCHRONOUS, OK),
8431 }; 8431 };
8432 8432
8433 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), 8433 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2),
8434 data_writes2, arraysize(data_writes2)); 8434 data_writes2, arraysize(data_writes2));
8435 session_deps_.socket_factory->AddSocketDataProvider(&data2); 8435 session_deps_.socket_factory->AddSocketDataProvider(&data2);
8436 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8436 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8437 8437
8438 TestCompletionCallback callback1; 8438 TestCompletionCallback callback1;
8439 8439
8440 scoped_ptr<HttpTransaction> trans( 8440 scoped_ptr<HttpTransaction> trans(
8441 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8441 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8442 8442
8443 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); 8443 int rv = trans->Start(&request, callback1.callback(), BoundNetLog());
8444 EXPECT_EQ(ERR_IO_PENDING, rv); 8444 EXPECT_EQ(ERR_IO_PENDING, rv);
8445 8445
8446 rv = callback1.WaitForResult(); 8446 rv = callback1.WaitForResult();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
8482 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0); 8482 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0);
8483 SSLSocketDataProvider ssl(ASYNC, OK); 8483 SSLSocketDataProvider ssl(ASYNC, OK);
8484 8484
8485 session_deps_.socket_factory->AddSocketDataProvider(&data); 8485 session_deps_.socket_factory->AddSocketDataProvider(&data);
8486 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 8486 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
8487 8487
8488 TestCompletionCallback callback; 8488 TestCompletionCallback callback;
8489 8489
8490 session_deps_.socket_factory->ResetNextMockIndexes(); 8490 session_deps_.socket_factory->ResetNextMockIndexes();
8491 8491
8492 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8492 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8493 scoped_ptr<HttpTransaction> trans( 8493 scoped_ptr<HttpTransaction> trans(
8494 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8494 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8495 8495
8496 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8496 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8497 EXPECT_EQ(ERR_IO_PENDING, rv); 8497 EXPECT_EQ(ERR_IO_PENDING, rv);
8498 8498
8499 rv = callback.WaitForResult(); 8499 rv = callback.WaitForResult();
8500 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 8500 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
8501 } 8501 }
8502 8502
8503 TEST_P(HttpNetworkTransactionTest, LargeContentLengthThenClose) { 8503 TEST_P(HttpNetworkTransactionTest, LargeContentLengthThenClose) {
8504 HttpRequestInfo request; 8504 HttpRequestInfo request;
8505 request.method = "GET"; 8505 request.method = "GET";
8506 request.url = GURL("http://www.example.org/"); 8506 request.url = GURL("http://www.example.org/");
8507 request.load_flags = 0; 8507 request.load_flags = 0;
8508 8508
8509 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8509 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8510 scoped_ptr<HttpTransaction> trans( 8510 scoped_ptr<HttpTransaction> trans(
8511 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8511 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8512 8512
8513 MockRead data_reads[] = { 8513 MockRead data_reads[] = {
8514 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), 8514 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"),
8515 MockRead(SYNCHRONOUS, OK), 8515 MockRead(SYNCHRONOUS, OK),
8516 }; 8516 };
8517 8517
8518 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 8518 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
8519 session_deps_.socket_factory->AddSocketDataProvider(&data); 8519 session_deps_.socket_factory->AddSocketDataProvider(&data);
(...skipping 28 matching lines...) Expand all
8548 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(), 8548 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(),
8549 temp_file_path, 0, kuint64max, base::Time())); 8549 temp_file_path, 0, kuint64max, base::Time()));
8550 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 8550 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
8551 8551
8552 HttpRequestInfo request; 8552 HttpRequestInfo request;
8553 request.method = "POST"; 8553 request.method = "POST";
8554 request.url = GURL("http://www.example.org/upload"); 8554 request.url = GURL("http://www.example.org/upload");
8555 request.upload_data_stream = &upload_data_stream; 8555 request.upload_data_stream = &upload_data_stream;
8556 request.load_flags = 0; 8556 request.load_flags = 0;
8557 8557
8558 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8558 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8559 scoped_ptr<HttpTransaction> trans( 8559 scoped_ptr<HttpTransaction> trans(
8560 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8560 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8561 8561
8562 MockRead data_reads[] = { 8562 MockRead data_reads[] = {
8563 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 8563 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
8564 MockRead("hello world"), 8564 MockRead("hello world"),
8565 MockRead(SYNCHRONOUS, OK), 8565 MockRead(SYNCHRONOUS, OK),
8566 }; 8566 };
8567 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 8567 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
8568 session_deps_.socket_factory->AddSocketDataProvider(&data); 8568 session_deps_.socket_factory->AddSocketDataProvider(&data);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
8603 temp_file, 0, kuint64max, base::Time())); 8603 temp_file, 0, kuint64max, base::Time()));
8604 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 8604 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
8605 8605
8606 HttpRequestInfo request; 8606 HttpRequestInfo request;
8607 request.method = "POST"; 8607 request.method = "POST";
8608 request.url = GURL("http://www.example.org/upload"); 8608 request.url = GURL("http://www.example.org/upload");
8609 request.upload_data_stream = &upload_data_stream; 8609 request.upload_data_stream = &upload_data_stream;
8610 request.load_flags = 0; 8610 request.load_flags = 0;
8611 8611
8612 // If we try to upload an unreadable file, the transaction should fail. 8612 // If we try to upload an unreadable file, the transaction should fail.
8613 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8613 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8614 scoped_ptr<HttpTransaction> trans( 8614 scoped_ptr<HttpTransaction> trans(
8615 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8615 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8616 8616
8617 StaticSocketDataProvider data(NULL, 0, NULL, 0); 8617 StaticSocketDataProvider data(NULL, 0, NULL, 0);
8618 session_deps_.socket_factory->AddSocketDataProvider(&data); 8618 session_deps_.socket_factory->AddSocketDataProvider(&data);
8619 8619
8620 TestCompletionCallback callback; 8620 TestCompletionCallback callback;
8621 8621
8622 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8622 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8623 EXPECT_EQ(ERR_IO_PENDING, rv); 8623 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8657 ScopedVector<UploadElementReader> element_readers; 8657 ScopedVector<UploadElementReader> element_readers;
8658 element_readers.push_back(fake_reader); 8658 element_readers.push_back(fake_reader);
8659 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 8659 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
8660 8660
8661 HttpRequestInfo request; 8661 HttpRequestInfo request;
8662 request.method = "POST"; 8662 request.method = "POST";
8663 request.url = GURL("http://www.example.org/upload"); 8663 request.url = GURL("http://www.example.org/upload");
8664 request.upload_data_stream = &upload_data_stream; 8664 request.upload_data_stream = &upload_data_stream;
8665 request.load_flags = 0; 8665 request.load_flags = 0;
8666 8666
8667 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8667 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8668 scoped_ptr<HttpTransaction> trans( 8668 scoped_ptr<HttpTransaction> trans(
8669 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8669 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8670 8670
8671 StaticSocketDataProvider data; 8671 StaticSocketDataProvider data;
8672 session_deps_.socket_factory->AddSocketDataProvider(&data); 8672 session_deps_.socket_factory->AddSocketDataProvider(&data);
8673 8673
8674 TestCompletionCallback callback; 8674 TestCompletionCallback callback;
8675 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8675 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8676 EXPECT_EQ(ERR_IO_PENDING, rv); 8676 EXPECT_EQ(ERR_IO_PENDING, rv);
8677 base::MessageLoop::current()->RunUntilIdle(); 8677 base::MessageLoop::current()->RunUntilIdle();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
8764 data_writes3, arraysize(data_writes3)); 8764 data_writes3, arraysize(data_writes3));
8765 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4), 8765 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4),
8766 data_writes4, arraysize(data_writes4)); 8766 data_writes4, arraysize(data_writes4));
8767 session_deps_.socket_factory->AddSocketDataProvider(&data1); 8767 session_deps_.socket_factory->AddSocketDataProvider(&data1);
8768 session_deps_.socket_factory->AddSocketDataProvider(&data2); 8768 session_deps_.socket_factory->AddSocketDataProvider(&data2);
8769 session_deps_.socket_factory->AddSocketDataProvider(&data3); 8769 session_deps_.socket_factory->AddSocketDataProvider(&data3);
8770 session_deps_.socket_factory->AddSocketDataProvider(&data4); 8770 session_deps_.socket_factory->AddSocketDataProvider(&data4);
8771 8771
8772 TestCompletionCallback callback1; 8772 TestCompletionCallback callback1;
8773 8773
8774 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8774 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8775 scoped_ptr<HttpTransaction> trans( 8775 scoped_ptr<HttpTransaction> trans(
8776 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8776 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8777 8777
8778 // Issue the first request with Authorize headers. There should be a 8778 // Issue the first request with Authorize headers. There should be a
8779 // password prompt for first_realm waiting to be filled in after the 8779 // password prompt for first_realm waiting to be filled in after the
8780 // transaction completes. 8780 // transaction completes.
8781 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); 8781 int rv = trans->Start(&request, callback1.callback(), BoundNetLog());
8782 EXPECT_EQ(ERR_IO_PENDING, rv); 8782 EXPECT_EQ(ERR_IO_PENDING, rv);
8783 rv = callback1.WaitForResult(); 8783 rv = callback1.WaitForResult();
8784 EXPECT_EQ(OK, rv); 8784 EXPECT_EQ(OK, rv);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
8859 request.method = "GET"; 8859 request.method = "GET";
8860 request.url = GURL("http://www.example.org/"); 8860 request.url = GURL("http://www.example.org/");
8861 request.load_flags = 0; 8861 request.load_flags = 0;
8862 8862
8863 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 8863 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
8864 8864
8865 session_deps_.socket_factory->AddSocketDataProvider(&data); 8865 session_deps_.socket_factory->AddSocketDataProvider(&data);
8866 8866
8867 TestCompletionCallback callback; 8867 TestCompletionCallback callback;
8868 8868
8869 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8869 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8870 scoped_ptr<HttpTransaction> trans( 8870 scoped_ptr<HttpTransaction> trans(
8871 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8871 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8872 8872
8873 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8873 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8874 EXPECT_EQ(ERR_IO_PENDING, rv); 8874 EXPECT_EQ(ERR_IO_PENDING, rv);
8875 8875
8876 HostPortPair http_host_port_pair("www.example.org", 80); 8876 HostPortPair http_host_port_pair("www.example.org", 80);
8877 HttpServerProperties& http_server_properties = 8877 HttpServerProperties& http_server_properties =
8878 *session->http_server_properties(); 8878 *session->http_server_properties();
8879 AlternativeServiceVector alternative_service_vector = 8879 AlternativeServiceVector alternative_service_vector =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
8923 request.method = "GET"; 8923 request.method = "GET";
8924 request.url = GURL("http://www.example.org/"); 8924 request.url = GURL("http://www.example.org/");
8925 request.load_flags = 0; 8925 request.load_flags = 0;
8926 8926
8927 StaticSocketDataProvider data(data_reads, arraysize(data_reads), nullptr, 0); 8927 StaticSocketDataProvider data(data_reads, arraysize(data_reads), nullptr, 0);
8928 8928
8929 session_deps_.socket_factory->AddSocketDataProvider(&data); 8929 session_deps_.socket_factory->AddSocketDataProvider(&data);
8930 8930
8931 TestCompletionCallback callback; 8931 TestCompletionCallback callback;
8932 8932
8933 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); 8933 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8934 scoped_ptr<HttpTransaction> trans( 8934 scoped_ptr<HttpTransaction> trans(
8935 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8935 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8936 8936
8937 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8937 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8938 EXPECT_EQ(ERR_IO_PENDING, rv); 8938 EXPECT_EQ(ERR_IO_PENDING, rv);
8939 8939
8940 HostPortPair http_host_port_pair("www.example.org", 80); 8940 HostPortPair http_host_port_pair("www.example.org", 80);
8941 HttpServerProperties& http_server_properties = 8941 HttpServerProperties& http_server_properties =
8942 *session->http_server_properties(); 8942 *session->http_server_properties();
8943 AlternativeServiceVector alternative_service_vector = 8943 AlternativeServiceVector alternative_service_vector =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
8980 request.method = "GET"; 8980 request.method = "GET";
8981 request.url = GURL("http://www.example.org/"); 8981 request.url = GURL("http://www.example.org/");
8982 request.load_flags = 0; 8982 request.load_flags = 0;
8983 8983
8984 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 8984 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
8985 8985
8986 session_deps_.socket_factory->AddSocketDataProvider(&data); 8986 session_deps_.socket_factory->AddSocketDataProvider(&data);
8987 8987
8988 TestCompletionCallback callback; 8988 TestCompletionCallback callback;
8989 8989
8990 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8990 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8991 scoped_ptr<HttpTransaction> trans( 8991 scoped_ptr<HttpTransaction> trans(
8992 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8992 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8993 8993
8994 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8994 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8995 EXPECT_EQ(ERR_IO_PENDING, rv); 8995 EXPECT_EQ(ERR_IO_PENDING, rv);
8996 8996
8997 HostPortPair http_host_port_pair("www.example.org", 80); 8997 HostPortPair http_host_port_pair("www.example.org", 80);
8998 HttpServerProperties& http_server_properties = 8998 HttpServerProperties& http_server_properties =
8999 *session->http_server_properties(); 8999 *session->http_server_properties();
9000 AlternativeServiceVector alternative_service_vector = 9000 AlternativeServiceVector alternative_service_vector =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
9047 request.method = "GET"; 9047 request.method = "GET";
9048 request.url = GURL("http://www.example.org/"); 9048 request.url = GURL("http://www.example.org/");
9049 request.load_flags = 0; 9049 request.load_flags = 0;
9050 9050
9051 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 9051 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
9052 9052
9053 session_deps_.socket_factory->AddSocketDataProvider(&data); 9053 session_deps_.socket_factory->AddSocketDataProvider(&data);
9054 9054
9055 TestCompletionCallback callback; 9055 TestCompletionCallback callback;
9056 9056
9057 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9057 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9058 scoped_ptr<HttpTransaction> trans( 9058 scoped_ptr<HttpTransaction> trans(
9059 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9059 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9060 9060
9061 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9061 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9062 EXPECT_EQ(ERR_IO_PENDING, rv); 9062 EXPECT_EQ(ERR_IO_PENDING, rv);
9063 9063
9064 HostPortPair http_host_port_pair("www.example.org", 80); 9064 HostPortPair http_host_port_pair("www.example.org", 80);
9065 HttpServerProperties& http_server_properties = 9065 HttpServerProperties& http_server_properties =
9066 *session->http_server_properties(); 9066 *session->http_server_properties();
9067 AlternativeServiceVector alternative_service_vector = 9067 AlternativeServiceVector alternative_service_vector =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
9104 request.method = "GET"; 9104 request.method = "GET";
9105 request.url = GURL("http://www.example.org/"); 9105 request.url = GURL("http://www.example.org/");
9106 request.load_flags = 0; 9106 request.load_flags = 0;
9107 9107
9108 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 9108 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
9109 9109
9110 session_deps_.socket_factory->AddSocketDataProvider(&data); 9110 session_deps_.socket_factory->AddSocketDataProvider(&data);
9111 9111
9112 TestCompletionCallback callback; 9112 TestCompletionCallback callback;
9113 9113
9114 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9114 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9115 9115
9116 HostPortPair http_host_port_pair("www.example.org", 80); 9116 HostPortPair http_host_port_pair("www.example.org", 80);
9117 HttpServerProperties& http_server_properties = 9117 HttpServerProperties& http_server_properties =
9118 *session->http_server_properties(); 9118 *session->http_server_properties();
9119 AlternativeService alternative_service(QUIC, "", 80); 9119 AlternativeService alternative_service(QUIC, "", 80);
9120 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9120 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9121 http_server_properties.SetAlternativeService( 9121 http_server_properties.SetAlternativeService(
9122 http_host_port_pair, alternative_service, 1.0, expiration); 9122 http_host_port_pair, alternative_service, 1.0, expiration);
9123 9123
9124 AlternativeServiceVector alternative_service_vector = 9124 AlternativeServiceVector alternative_service_vector =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
9171 request.method = "GET"; 9171 request.method = "GET";
9172 request.url = GURL("http://www.example.org/"); 9172 request.url = GURL("http://www.example.org/");
9173 request.load_flags = 0; 9173 request.load_flags = 0;
9174 9174
9175 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 9175 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
9176 9176
9177 session_deps_.socket_factory->AddSocketDataProvider(&data); 9177 session_deps_.socket_factory->AddSocketDataProvider(&data);
9178 9178
9179 TestCompletionCallback callback; 9179 TestCompletionCallback callback;
9180 9180
9181 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9181 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9182 scoped_ptr<HttpTransaction> trans( 9182 scoped_ptr<HttpTransaction> trans(
9183 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9183 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9184 9184
9185 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9185 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9186 EXPECT_EQ(ERR_IO_PENDING, rv); 9186 EXPECT_EQ(ERR_IO_PENDING, rv);
9187 9187
9188 HostPortPair http_host_port_pair("www.example.org", 80); 9188 HostPortPair http_host_port_pair("www.example.org", 80);
9189 HttpServerProperties& http_server_properties = 9189 HttpServerProperties& http_server_properties =
9190 *session->http_server_properties(); 9190 *session->http_server_properties();
9191 AlternativeServiceVector alternative_service_vector = 9191 AlternativeServiceVector alternative_service_vector =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
9230 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9230 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
9231 9231
9232 MockRead data_reads[] = { 9232 MockRead data_reads[] = {
9233 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello world"), 9233 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello world"),
9234 MockRead(ASYNC, OK), 9234 MockRead(ASYNC, OK),
9235 }; 9235 };
9236 StaticSocketDataProvider second_data(data_reads, arraysize(data_reads), 9236 StaticSocketDataProvider second_data(data_reads, arraysize(data_reads),
9237 nullptr, 0); 9237 nullptr, 0);
9238 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 9238 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9239 9239
9240 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); 9240 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9241 9241
9242 base::WeakPtr<HttpServerProperties> http_server_properties = 9242 base::WeakPtr<HttpServerProperties> http_server_properties =
9243 session->http_server_properties(); 9243 session->http_server_properties();
9244 AlternativeService alternative_service( 9244 AlternativeService alternative_service(
9245 AlternateProtocolFromNextProto(GetParam()), "different.example.org", 80); 9245 AlternateProtocolFromNextProto(GetParam()), "different.example.org", 80);
9246 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9246 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9247 http_server_properties->SetAlternativeService( 9247 http_server_properties->SetAlternativeService(
9248 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration); 9248 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration);
9249 9249
9250 scoped_ptr<HttpTransaction> trans( 9250 scoped_ptr<HttpTransaction> trans(
(...skipping 23 matching lines...) Expand all
9274 9274
9275 MockRead data_reads[] = { 9275 MockRead data_reads[] = {
9276 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9276 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
9277 MockRead("hello world"), 9277 MockRead("hello world"),
9278 MockRead(ASYNC, OK), 9278 MockRead(ASYNC, OK),
9279 }; 9279 };
9280 StaticSocketDataProvider second_data( 9280 StaticSocketDataProvider second_data(
9281 data_reads, arraysize(data_reads), NULL, 0); 9281 data_reads, arraysize(data_reads), NULL, 0);
9282 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 9282 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9283 9283
9284 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9284 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9285 9285
9286 base::WeakPtr<HttpServerProperties> http_server_properties = 9286 base::WeakPtr<HttpServerProperties> http_server_properties =
9287 session->http_server_properties(); 9287 session->http_server_properties();
9288 const HostPortPair host_port_pair = HostPortPair::FromURL(request.url); 9288 const HostPortPair host_port_pair = HostPortPair::FromURL(request.url);
9289 // Port must be < 1024, or the header will be ignored (since initial port was 9289 // Port must be < 1024, or the header will be ignored (since initial port was
9290 // port 80 (another restricted port). 9290 // port 80 (another restricted port).
9291 const AlternativeService alternative_service( 9291 const AlternativeService alternative_service(
9292 AlternateProtocolFromNextProto(GetParam()), "www.example.org", 9292 AlternateProtocolFromNextProto(GetParam()), "www.example.org",
9293 666); // Port is ignored by MockConnect anyway. 9293 666); // Port is ignored by MockConnect anyway.
9294 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9294 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
9340 9340
9341 MockRead data_reads[] = { 9341 MockRead data_reads[] = {
9342 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9342 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
9343 MockRead("hello world"), 9343 MockRead("hello world"),
9344 MockRead(ASYNC, OK), 9344 MockRead(ASYNC, OK),
9345 }; 9345 };
9346 StaticSocketDataProvider second_data( 9346 StaticSocketDataProvider second_data(
9347 data_reads, arraysize(data_reads), NULL, 0); 9347 data_reads, arraysize(data_reads), NULL, 0);
9348 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 9348 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9349 9349
9350 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9350 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9351 9351
9352 base::WeakPtr<HttpServerProperties> http_server_properties = 9352 base::WeakPtr<HttpServerProperties> http_server_properties =
9353 session->http_server_properties(); 9353 session->http_server_properties();
9354 const int kUnrestrictedAlternatePort = 1024; 9354 const int kUnrestrictedAlternatePort = 1024;
9355 AlternativeService alternative_service( 9355 AlternativeService alternative_service(
9356 AlternateProtocolFromNextProto(GetParam()), "www.example.org", 9356 AlternateProtocolFromNextProto(GetParam()), "www.example.org",
9357 kUnrestrictedAlternatePort); 9357 kUnrestrictedAlternatePort);
9358 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9358 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9359 http_server_properties->SetAlternativeService( 9359 http_server_properties->SetAlternativeService(
9360 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 9360 HostPortPair::FromURL(restricted_port_request.url), alternative_service,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
9392 9392
9393 MockRead data_reads[] = { 9393 MockRead data_reads[] = {
9394 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9394 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
9395 MockRead("hello world"), 9395 MockRead("hello world"),
9396 MockRead(ASYNC, OK), 9396 MockRead(ASYNC, OK),
9397 }; 9397 };
9398 StaticSocketDataProvider second_data( 9398 StaticSocketDataProvider second_data(
9399 data_reads, arraysize(data_reads), NULL, 0); 9399 data_reads, arraysize(data_reads), NULL, 0);
9400 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 9400 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9401 9401
9402 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9402 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9403 9403
9404 base::WeakPtr<HttpServerProperties> http_server_properties = 9404 base::WeakPtr<HttpServerProperties> http_server_properties =
9405 session->http_server_properties(); 9405 session->http_server_properties();
9406 const int kUnrestrictedAlternatePort = 1024; 9406 const int kUnrestrictedAlternatePort = 1024;
9407 AlternativeService alternative_service( 9407 AlternativeService alternative_service(
9408 AlternateProtocolFromNextProto(GetParam()), "www.example.org", 9408 AlternateProtocolFromNextProto(GetParam()), "www.example.org",
9409 kUnrestrictedAlternatePort); 9409 kUnrestrictedAlternatePort);
9410 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9410 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9411 http_server_properties->SetAlternativeService( 9411 http_server_properties->SetAlternativeService(
9412 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 9412 HostPortPair::FromURL(restricted_port_request.url), alternative_service,
(...skipping 30 matching lines...) Expand all
9443 9443
9444 MockRead data_reads[] = { 9444 MockRead data_reads[] = {
9445 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9445 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
9446 MockRead("hello world"), 9446 MockRead("hello world"),
9447 MockRead(ASYNC, OK), 9447 MockRead(ASYNC, OK),
9448 }; 9448 };
9449 StaticSocketDataProvider second_data( 9449 StaticSocketDataProvider second_data(
9450 data_reads, arraysize(data_reads), NULL, 0); 9450 data_reads, arraysize(data_reads), NULL, 0);
9451 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 9451 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9452 9452
9453 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9453 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9454 9454
9455 base::WeakPtr<HttpServerProperties> http_server_properties = 9455 base::WeakPtr<HttpServerProperties> http_server_properties =
9456 session->http_server_properties(); 9456 session->http_server_properties();
9457 const int kRestrictedAlternatePort = 80; 9457 const int kRestrictedAlternatePort = 80;
9458 AlternativeService alternative_service( 9458 AlternativeService alternative_service(
9459 AlternateProtocolFromNextProto(GetParam()), "www.example.org", 9459 AlternateProtocolFromNextProto(GetParam()), "www.example.org",
9460 kRestrictedAlternatePort); 9460 kRestrictedAlternatePort);
9461 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9461 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9462 http_server_properties->SetAlternativeService( 9462 http_server_properties->SetAlternativeService(
9463 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 9463 HostPortPair::FromURL(restricted_port_request.url), alternative_service,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
9495 9495
9496 MockRead data_reads[] = { 9496 MockRead data_reads[] = {
9497 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9497 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
9498 MockRead("hello world"), 9498 MockRead("hello world"),
9499 MockRead(ASYNC, OK), 9499 MockRead(ASYNC, OK),
9500 }; 9500 };
9501 StaticSocketDataProvider second_data( 9501 StaticSocketDataProvider second_data(
9502 data_reads, arraysize(data_reads), NULL, 0); 9502 data_reads, arraysize(data_reads), NULL, 0);
9503 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 9503 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9504 9504
9505 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9505 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9506 9506
9507 base::WeakPtr<HttpServerProperties> http_server_properties = 9507 base::WeakPtr<HttpServerProperties> http_server_properties =
9508 session->http_server_properties(); 9508 session->http_server_properties();
9509 const int kRestrictedAlternatePort = 80; 9509 const int kRestrictedAlternatePort = 80;
9510 AlternativeService alternative_service( 9510 AlternativeService alternative_service(
9511 AlternateProtocolFromNextProto(GetParam()), "www.example.org", 9511 AlternateProtocolFromNextProto(GetParam()), "www.example.org",
9512 kRestrictedAlternatePort); 9512 kRestrictedAlternatePort);
9513 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9513 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9514 http_server_properties->SetAlternativeService( 9514 http_server_properties->SetAlternativeService(
9515 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, 9515 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service,
(...skipping 30 matching lines...) Expand all
9546 9546
9547 MockRead data_reads[] = { 9547 MockRead data_reads[] = {
9548 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9548 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
9549 MockRead("hello world"), 9549 MockRead("hello world"),
9550 MockRead(ASYNC, OK), 9550 MockRead(ASYNC, OK),
9551 }; 9551 };
9552 StaticSocketDataProvider second_data( 9552 StaticSocketDataProvider second_data(
9553 data_reads, arraysize(data_reads), NULL, 0); 9553 data_reads, arraysize(data_reads), NULL, 0);
9554 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 9554 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9555 9555
9556 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9556 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9557 9557
9558 base::WeakPtr<HttpServerProperties> http_server_properties = 9558 base::WeakPtr<HttpServerProperties> http_server_properties =
9559 session->http_server_properties(); 9559 session->http_server_properties();
9560 const int kUnrestrictedAlternatePort = 1025; 9560 const int kUnrestrictedAlternatePort = 1025;
9561 AlternativeService alternative_service( 9561 AlternativeService alternative_service(
9562 AlternateProtocolFromNextProto(GetParam()), "www.example.org", 9562 AlternateProtocolFromNextProto(GetParam()), "www.example.org",
9563 kUnrestrictedAlternatePort); 9563 kUnrestrictedAlternatePort);
9564 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9564 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9565 http_server_properties->SetAlternativeService( 9565 http_server_properties->SetAlternativeService(
9566 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, 9566 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service,
(...skipping 25 matching lines...) Expand all
9592 // so only the standard HTTP request will try to connect. 9592 // so only the standard HTTP request will try to connect.
9593 MockRead data_reads[] = { 9593 MockRead data_reads[] = {
9594 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9594 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
9595 MockRead("hello world"), 9595 MockRead("hello world"),
9596 MockRead(ASYNC, OK), 9596 MockRead(ASYNC, OK),
9597 }; 9597 };
9598 StaticSocketDataProvider data( 9598 StaticSocketDataProvider data(
9599 data_reads, arraysize(data_reads), NULL, 0); 9599 data_reads, arraysize(data_reads), NULL, 0);
9600 session_deps_.socket_factory->AddSocketDataProvider(&data); 9600 session_deps_.socket_factory->AddSocketDataProvider(&data);
9601 9601
9602 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9602 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9603 9603
9604 base::WeakPtr<HttpServerProperties> http_server_properties = 9604 base::WeakPtr<HttpServerProperties> http_server_properties =
9605 session->http_server_properties(); 9605 session->http_server_properties();
9606 const int kUnsafePort = 7; 9606 const int kUnsafePort = 7;
9607 AlternativeService alternative_service( 9607 AlternativeService alternative_service(
9608 AlternateProtocolFromNextProto(GetParam()), "www.example.org", 9608 AlternateProtocolFromNextProto(GetParam()), "www.example.org",
9609 kUnsafePort); 9609 kUnsafePort);
9610 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9610 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9611 http_server_properties->SetAlternativeService( 9611 http_server_properties->SetAlternativeService(
9612 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration); 9612 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
9677 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); 9677 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
9678 StaticSocketDataProvider hanging_non_alternate_protocol_socket( 9678 StaticSocketDataProvider hanging_non_alternate_protocol_socket(
9679 NULL, 0, NULL, 0); 9679 NULL, 0, NULL, 0);
9680 hanging_non_alternate_protocol_socket.set_connect_data( 9680 hanging_non_alternate_protocol_socket.set_connect_data(
9681 never_finishing_connect); 9681 never_finishing_connect);
9682 session_deps_.socket_factory->AddSocketDataProvider( 9682 session_deps_.socket_factory->AddSocketDataProvider(
9683 &hanging_non_alternate_protocol_socket); 9683 &hanging_non_alternate_protocol_socket);
9684 9684
9685 TestCompletionCallback callback; 9685 TestCompletionCallback callback;
9686 9686
9687 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9687 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9688 scoped_ptr<HttpTransaction> trans( 9688 scoped_ptr<HttpTransaction> trans(
9689 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9689 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9690 9690
9691 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9691 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9692 EXPECT_EQ(ERR_IO_PENDING, rv); 9692 EXPECT_EQ(ERR_IO_PENDING, rv);
9693 EXPECT_EQ(OK, callback.WaitForResult()); 9693 EXPECT_EQ(OK, callback.WaitForResult());
9694 9694
9695 const HttpResponseInfo* response = trans->GetResponseInfo(); 9695 const HttpResponseInfo* response = trans->GetResponseInfo();
9696 ASSERT_TRUE(response != NULL); 9696 ASSERT_TRUE(response != NULL);
9697 ASSERT_TRUE(response->headers.get() != NULL); 9697 ASSERT_TRUE(response->headers.get() != NULL);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
9779 }; 9779 };
9780 9780
9781 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, 9781 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes,
9782 arraysize(spdy_writes)); 9782 arraysize(spdy_writes));
9783 // Socket 4 is the successful Alternate-Protocol for transaction 3. 9783 // Socket 4 is the successful Alternate-Protocol for transaction 3.
9784 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); 9784 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data);
9785 9785
9786 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. 9786 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3.
9787 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket); 9787 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket);
9788 9788
9789 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9789 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9790 TestCompletionCallback callback1; 9790 TestCompletionCallback callback1;
9791 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 9791 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
9792 9792
9793 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); 9793 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog());
9794 EXPECT_EQ(ERR_IO_PENDING, rv); 9794 EXPECT_EQ(ERR_IO_PENDING, rv);
9795 EXPECT_EQ(OK, callback1.WaitForResult()); 9795 EXPECT_EQ(OK, callback1.WaitForResult());
9796 9796
9797 const HttpResponseInfo* response = trans1.GetResponseInfo(); 9797 const HttpResponseInfo* response = trans1.GetResponseInfo();
9798 ASSERT_TRUE(response != NULL); 9798 ASSERT_TRUE(response != NULL);
9799 ASSERT_TRUE(response->headers.get() != NULL); 9799 ASSERT_TRUE(response->headers.get() != NULL);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
9870 hanging_alternate_protocol_socket.set_connect_data( 9870 hanging_alternate_protocol_socket.set_connect_data(
9871 never_finishing_connect); 9871 never_finishing_connect);
9872 session_deps_.socket_factory->AddSocketDataProvider( 9872 session_deps_.socket_factory->AddSocketDataProvider(
9873 &hanging_alternate_protocol_socket); 9873 &hanging_alternate_protocol_socket);
9874 9874
9875 // 2nd request is just a copy of the first one, over HTTP again. 9875 // 2nd request is just a copy of the first one, over HTTP again.
9876 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); 9876 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction);
9877 9877
9878 TestCompletionCallback callback; 9878 TestCompletionCallback callback;
9879 9879
9880 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9880 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9881 scoped_ptr<HttpTransaction> trans( 9881 scoped_ptr<HttpTransaction> trans(
9882 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9882 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9883 9883
9884 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9884 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9885 EXPECT_EQ(ERR_IO_PENDING, rv); 9885 EXPECT_EQ(ERR_IO_PENDING, rv);
9886 EXPECT_EQ(OK, callback.WaitForResult()); 9886 EXPECT_EQ(OK, callback.WaitForResult());
9887 9887
9888 const HttpResponseInfo* response = trans->GetResponseInfo(); 9888 const HttpResponseInfo* response = trans->GetResponseInfo();
9889 ASSERT_TRUE(response != NULL); 9889 ASSERT_TRUE(response != NULL);
9890 ASSERT_TRUE(response->headers.get() != NULL); 9890 ASSERT_TRUE(response->headers.get() != NULL);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
10034 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); 10034 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
10035 StaticSocketDataProvider hanging_non_alternate_protocol_socket( 10035 StaticSocketDataProvider hanging_non_alternate_protocol_socket(
10036 NULL, 0, NULL, 0); 10036 NULL, 0, NULL, 0);
10037 hanging_non_alternate_protocol_socket.set_connect_data( 10037 hanging_non_alternate_protocol_socket.set_connect_data(
10038 never_finishing_connect); 10038 never_finishing_connect);
10039 session_deps_.socket_factory->AddSocketDataProvider( 10039 session_deps_.socket_factory->AddSocketDataProvider(
10040 &hanging_non_alternate_protocol_socket); 10040 &hanging_non_alternate_protocol_socket);
10041 10041
10042 TestCompletionCallback callback; 10042 TestCompletionCallback callback;
10043 10043
10044 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10044 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10045 scoped_ptr<HttpTransaction> trans( 10045 scoped_ptr<HttpTransaction> trans(
10046 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10046 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10047 10047
10048 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10048 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10049 EXPECT_EQ(ERR_IO_PENDING, rv); 10049 EXPECT_EQ(ERR_IO_PENDING, rv);
10050 EXPECT_EQ(OK, callback.WaitForResult()); 10050 EXPECT_EQ(OK, callback.WaitForResult());
10051 10051
10052 const HttpResponseInfo* response = trans->GetResponseInfo(); 10052 const HttpResponseInfo* response = trans->GetResponseInfo();
10053 ASSERT_TRUE(response != NULL); 10053 ASSERT_TRUE(response != NULL);
10054 ASSERT_TRUE(response->headers.get() != NULL); 10054 ASSERT_TRUE(response->headers.get() != NULL);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
10127 MockRead spdy_reads[] = { 10127 MockRead spdy_reads[] = {
10128 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), 10128 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3),
10129 }; 10129 };
10130 10130
10131 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, 10131 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes,
10132 arraysize(spdy_writes)); 10132 arraysize(spdy_writes));
10133 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); 10133 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data);
10134 10134
10135 TestCompletionCallback callback; 10135 TestCompletionCallback callback;
10136 10136
10137 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10137 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10138 10138
10139 scoped_ptr<HttpTransaction> trans( 10139 scoped_ptr<HttpTransaction> trans(
10140 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10140 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10141 10141
10142 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10142 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10143 EXPECT_EQ(ERR_IO_PENDING, rv); 10143 EXPECT_EQ(ERR_IO_PENDING, rv);
10144 EXPECT_EQ(OK, callback.WaitForResult()); 10144 EXPECT_EQ(OK, callback.WaitForResult());
10145 10145
10146 const HttpResponseInfo* response = trans->GetResponseInfo(); 10146 const HttpResponseInfo* response = trans->GetResponseInfo();
10147 ASSERT_TRUE(response != NULL); 10147 ASSERT_TRUE(response != NULL);
10148 ASSERT_TRUE(response->headers.get() != NULL); 10148 ASSERT_TRUE(response->headers.get() != NULL);
10149 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10149 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10150 10150
10151 std::string response_data; 10151 std::string response_data;
10152 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10152 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10153 EXPECT_EQ("hello world", response_data); 10153 EXPECT_EQ("hello world", response_data);
10154 10154
10155 // Set up an initial SpdySession in the pool to reuse. 10155 // Set up an initial SpdySession in the pool to reuse.
10156 HostPortPair host_port_pair("www.example.org", 443); 10156 HostPortPair host_port_pair("www.example.org", 443);
10157 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), 10157 SpdySessionKey key(host_port_pair, ProxyServer::Direct(),
10158 PRIVACY_MODE_DISABLED); 10158 PRIVACY_MODE_DISABLED);
10159 base::WeakPtr<SpdySession> spdy_session = 10159 base::WeakPtr<SpdySession> spdy_session =
10160 CreateSecureSpdySession(session.get(), key, BoundNetLog()); 10160 CreateSecureSpdySession(session, key, BoundNetLog());
10161 10161
10162 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10162 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10163 10163
10164 rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10164 rv = trans->Start(&request, callback.callback(), BoundNetLog());
10165 EXPECT_EQ(ERR_IO_PENDING, rv); 10165 EXPECT_EQ(ERR_IO_PENDING, rv);
10166 EXPECT_EQ(OK, callback.WaitForResult()); 10166 EXPECT_EQ(OK, callback.WaitForResult());
10167 10167
10168 response = trans->GetResponseInfo(); 10168 response = trans->GetResponseInfo();
10169 ASSERT_TRUE(response != NULL); 10169 ASSERT_TRUE(response != NULL);
10170 ASSERT_TRUE(response->headers.get() != NULL); 10170 ASSERT_TRUE(response->headers.get() != NULL);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
10519 ProxyService::CreateFixed(test_config.proxy_url)); 10519 ProxyService::CreateFixed(test_config.proxy_url));
10520 } else { 10520 } else {
10521 session_deps_.proxy_service.reset(ProxyService::CreateDirect()); 10521 session_deps_.proxy_service.reset(ProxyService::CreateDirect());
10522 } 10522 }
10523 10523
10524 HttpRequestInfo request; 10524 HttpRequestInfo request;
10525 request.method = "GET"; 10525 request.method = "GET";
10526 request.url = GURL(test_config.server_url); 10526 request.url = GURL(test_config.server_url);
10527 request.load_flags = 0; 10527 request.load_flags = 0;
10528 10528
10529 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10529 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10530 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10530 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10531 10531
10532 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK); 10532 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK);
10533 10533
10534 std::vector<std::vector<MockRead>> mock_reads(1); 10534 std::vector<std::vector<MockRead>> mock_reads(1);
10535 std::vector<std::vector<MockWrite>> mock_writes(1); 10535 std::vector<std::vector<MockWrite>> mock_writes(1);
10536 for (int round = 0; round < test_config.num_auth_rounds; ++round) { 10536 for (int round = 0; round < test_config.num_auth_rounds; ++round) {
10537 const TestRound& read_write_round = test_config.rounds[round]; 10537 const TestRound& read_write_round = test_config.rounds[round];
10538 10538
10539 // Set up expected reads and writes. 10539 // Set up expected reads and writes.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
10618 origin, BoundNetLog()); 10618 origin, BoundNetLog());
10619 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); 10619 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER);
10620 10620
10621 int rv = OK; 10621 int rv = OK;
10622 const HttpResponseInfo* response = NULL; 10622 const HttpResponseInfo* response = NULL;
10623 HttpRequestInfo request; 10623 HttpRequestInfo request;
10624 request.method = "GET"; 10624 request.method = "GET";
10625 request.url = origin; 10625 request.url = origin;
10626 request.load_flags = 0; 10626 request.load_flags = 0;
10627 10627
10628 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10628 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10629 10629
10630 // Use a TCP Socket Pool with only one connection per group. This is used 10630 // Use a TCP Socket Pool with only one connection per group. This is used
10631 // to validate that the TCP socket is not released to the pool between 10631 // to validate that the TCP socket is not released to the pool between
10632 // each round of multi-round authentication. 10632 // each round of multi-round authentication.
10633 HttpNetworkSessionPeer session_peer(session.get()); 10633 HttpNetworkSessionPeer session_peer(session);
10634 TransportClientSocketPool* transport_pool = new TransportClientSocketPool( 10634 TransportClientSocketPool* transport_pool = new TransportClientSocketPool(
10635 50, // Max sockets for pool 10635 50, // Max sockets for pool
10636 1, // Max sockets per group 10636 1, // Max sockets per group
10637 session_deps_.host_resolver.get(), 10637 session_deps_.host_resolver.get(),
10638 session_deps_.socket_factory.get(), 10638 session_deps_.socket_factory.get(),
10639 session_deps_.net_log); 10639 session_deps_.net_log);
10640 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager( 10640 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager(
10641 new MockClientSocketPoolManager); 10641 new MockClientSocketPoolManager);
10642 mock_pool_manager->SetTransportSocketPool(transport_pool); 10642 mock_pool_manager->SetTransportSocketPool(transport_pool);
10643 session_peer.SetClientSocketPoolManager(mock_pool_manager.Pass()); 10643 session_peer.SetClientSocketPoolManager(mock_pool_manager.Pass());
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
10818 ssl.SetNextProto(kProtoHTTP11); 10818 ssl.SetNextProto(kProtoHTTP11);
10819 10819
10820 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 10820 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
10821 10821
10822 StaticSocketDataProvider data(data_reads, arraysize(data_reads), 10822 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
10823 data_writes, arraysize(data_writes)); 10823 data_writes, arraysize(data_writes));
10824 session_deps_.socket_factory->AddSocketDataProvider(&data); 10824 session_deps_.socket_factory->AddSocketDataProvider(&data);
10825 10825
10826 TestCompletionCallback callback; 10826 TestCompletionCallback callback;
10827 10827
10828 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10828 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10829 scoped_ptr<HttpTransaction> trans( 10829 scoped_ptr<HttpTransaction> trans(
10830 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10830 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10831 10831
10832 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10832 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10833 10833
10834 EXPECT_EQ(ERR_IO_PENDING, rv); 10834 EXPECT_EQ(ERR_IO_PENDING, rv);
10835 EXPECT_EQ(OK, callback.WaitForResult()); 10835 EXPECT_EQ(OK, callback.WaitForResult());
10836 10836
10837 const HttpResponseInfo* response = trans->GetResponseInfo(); 10837 const HttpResponseInfo* response = trans->GetResponseInfo();
10838 ASSERT_TRUE(response != NULL); 10838 ASSERT_TRUE(response != NULL);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10870 MockRead spdy_reads[] = { 10870 MockRead spdy_reads[] = {
10871 MockRead(SYNCHRONOUS, 0, 0) // Not async - return 0 immediately. 10871 MockRead(SYNCHRONOUS, 0, 0) // Not async - return 0 immediately.
10872 }; 10872 };
10873 10873
10874 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, 10874 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes,
10875 arraysize(spdy_writes)); 10875 arraysize(spdy_writes));
10876 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); 10876 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data);
10877 10877
10878 TestCompletionCallback callback; 10878 TestCompletionCallback callback;
10879 10879
10880 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10880 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10881 scoped_ptr<HttpTransaction> trans( 10881 scoped_ptr<HttpTransaction> trans(
10882 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10882 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10883 10883
10884 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10884 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10885 EXPECT_EQ(ERR_IO_PENDING, rv); 10885 EXPECT_EQ(ERR_IO_PENDING, rv);
10886 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); 10886 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult());
10887 } 10887 }
10888 10888
10889 // A subclass of HttpAuthHandlerMock that records the request URL when 10889 // A subclass of HttpAuthHandlerMock that records the request URL when
10890 // it gets it. This is needed since the auth handler may get destroyed 10890 // it gets it. This is needed since the auth handler may get destroyed
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
11024 StaticSocketDataProvider hanging_non_alternate_protocol_socket( 11024 StaticSocketDataProvider hanging_non_alternate_protocol_socket(
11025 NULL, 0, NULL, 0); 11025 NULL, 0, NULL, 0);
11026 hanging_non_alternate_protocol_socket.set_connect_data( 11026 hanging_non_alternate_protocol_socket.set_connect_data(
11027 never_finishing_connect); 11027 never_finishing_connect);
11028 11028
11029 session_deps_.socket_factory->AddSocketDataProvider(&data_1); 11029 session_deps_.socket_factory->AddSocketDataProvider(&data_1);
11030 session_deps_.socket_factory->AddSocketDataProvider(&data_2); 11030 session_deps_.socket_factory->AddSocketDataProvider(&data_2);
11031 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 11031 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
11032 session_deps_.socket_factory->AddSocketDataProvider( 11032 session_deps_.socket_factory->AddSocketDataProvider(
11033 &hanging_non_alternate_protocol_socket); 11033 &hanging_non_alternate_protocol_socket);
11034 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11034 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11035 11035
11036 // First round should work and provide the Alternate-Protocol state. 11036 // First round should work and provide the Alternate-Protocol state.
11037 TestCompletionCallback callback_1; 11037 TestCompletionCallback callback_1;
11038 scoped_ptr<HttpTransaction> trans_1( 11038 scoped_ptr<HttpTransaction> trans_1(
11039 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 11039 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
11040 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); 11040 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog());
11041 EXPECT_EQ(ERR_IO_PENDING, rv); 11041 EXPECT_EQ(ERR_IO_PENDING, rv);
11042 EXPECT_EQ(OK, callback_1.WaitForResult()); 11042 EXPECT_EQ(OK, callback_1.WaitForResult());
11043 11043
11044 // Second round should attempt a tunnel connect and get an auth challenge. 11044 // Second round should attempt a tunnel connect and get an auth challenge.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
11084 MockRead(SYNCHRONOUS, "hello world"), 11084 MockRead(SYNCHRONOUS, "hello world"),
11085 MockRead(SYNCHRONOUS, OK), 11085 MockRead(SYNCHRONOUS, OK),
11086 }; 11086 };
11087 11087
11088 HttpRequestInfo request; 11088 HttpRequestInfo request;
11089 request.method = "GET"; 11089 request.method = "GET";
11090 request.url = GURL("http://www.example.org/"); 11090 request.url = GURL("http://www.example.org/");
11091 request.load_flags = 0; 11091 request.load_flags = 0;
11092 11092
11093 session_deps_.host_resolver->set_synchronous_mode(true); 11093 session_deps_.host_resolver->set_synchronous_mode(true);
11094 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11094 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11095 scoped_ptr<HttpTransaction> trans( 11095 scoped_ptr<HttpTransaction> trans(
11096 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 11096 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
11097 11097
11098 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 11098 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
11099 data.set_connect_data(mock_connect); 11099 data.set_connect_data(mock_connect);
11100 session_deps_.socket_factory->AddSocketDataProvider(&data); 11100 session_deps_.socket_factory->AddSocketDataProvider(&data);
11101 11101
11102 TestCompletionCallback callback; 11102 TestCompletionCallback callback;
11103 11103
11104 BoundTestNetLog log; 11104 BoundTestNetLog log;
(...skipping 17 matching lines...) Expand all
11122 MockRead(ASYNC, "Connection: Keep-Alive\r\n\r\n"), 11122 MockRead(ASYNC, "Connection: Keep-Alive\r\n\r\n"),
11123 MockRead(ASYNC, "1"), 11123 MockRead(ASYNC, "1"),
11124 // 2 async reads are necessary to trigger a ReadResponseBody call after the 11124 // 2 async reads are necessary to trigger a ReadResponseBody call after the
11125 // HttpNetworkTransaction has been deleted. 11125 // HttpNetworkTransaction has been deleted.
11126 MockRead(ASYNC, "2"), 11126 MockRead(ASYNC, "2"),
11127 MockRead(SYNCHRONOUS, ERR_IO_PENDING), // Should never read this. 11127 MockRead(SYNCHRONOUS, ERR_IO_PENDING), // Should never read this.
11128 }; 11128 };
11129 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 11129 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
11130 session_deps_.socket_factory->AddSocketDataProvider(&data); 11130 session_deps_.socket_factory->AddSocketDataProvider(&data);
11131 11131
11132 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11132 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11133 11133
11134 { 11134 {
11135 HttpRequestInfo request; 11135 HttpRequestInfo request;
11136 request.method = "GET"; 11136 request.method = "GET";
11137 request.url = GURL("http://www.example.org/"); 11137 request.url = GURL("http://www.example.org/");
11138 request.load_flags = 0; 11138 request.load_flags = 0;
11139 11139
11140 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 11140 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
11141 TestCompletionCallback callback; 11141 TestCompletionCallback callback;
11142 11142
(...skipping 15 matching lines...) Expand all
11158 // Socket should now be idle, waiting to be reused. 11158 // Socket should now be idle, waiting to be reused.
11159 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); 11159 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get()));
11160 } 11160 }
11161 11161
11162 // Test a basic GET request through a proxy. 11162 // Test a basic GET request through a proxy.
11163 TEST_P(HttpNetworkTransactionTest, ProxyGet) { 11163 TEST_P(HttpNetworkTransactionTest, ProxyGet) {
11164 session_deps_.proxy_service.reset( 11164 session_deps_.proxy_service.reset(
11165 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 11165 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
11166 BoundTestNetLog log; 11166 BoundTestNetLog log;
11167 session_deps_.net_log = log.bound().net_log(); 11167 session_deps_.net_log = log.bound().net_log();
11168 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11168 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11169 11169
11170 HttpRequestInfo request; 11170 HttpRequestInfo request;
11171 request.method = "GET"; 11171 request.method = "GET";
11172 request.url = GURL("http://www.example.org/"); 11172 request.url = GURL("http://www.example.org/");
11173 11173
11174 MockWrite data_writes1[] = { 11174 MockWrite data_writes1[] = {
11175 MockWrite( 11175 MockWrite(
11176 "GET http://www.example.org/ HTTP/1.1\r\n" 11176 "GET http://www.example.org/ HTTP/1.1\r\n"
11177 "Host: www.example.org\r\n" 11177 "Host: www.example.org\r\n"
11178 "Proxy-Connection: keep-alive\r\n\r\n"), 11178 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
11222 TestLoadTimingNotReusedWithPac(load_timing_info, 11222 TestLoadTimingNotReusedWithPac(load_timing_info,
11223 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); 11223 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY);
11224 } 11224 }
11225 11225
11226 // Test a basic HTTPS GET request through a proxy. 11226 // Test a basic HTTPS GET request through a proxy.
11227 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGet) { 11227 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGet) {
11228 session_deps_.proxy_service.reset( 11228 session_deps_.proxy_service.reset(
11229 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 11229 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
11230 BoundTestNetLog log; 11230 BoundTestNetLog log;
11231 session_deps_.net_log = log.bound().net_log(); 11231 session_deps_.net_log = log.bound().net_log();
11232 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11232 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11233 11233
11234 HttpRequestInfo request; 11234 HttpRequestInfo request;
11235 request.method = "GET"; 11235 request.method = "GET";
11236 request.url = GURL("https://www.example.org/"); 11236 request.url = GURL("https://www.example.org/");
11237 11237
11238 // Since we have proxy, should try to establish tunnel. 11238 // Since we have proxy, should try to establish tunnel.
11239 MockWrite data_writes1[] = { 11239 MockWrite data_writes1[] = {
11240 MockWrite( 11240 MockWrite(
11241 "CONNECT www.example.org:443 HTTP/1.1\r\n" 11241 "CONNECT www.example.org:443 HTTP/1.1\r\n"
11242 "Host: www.example.org\r\n" 11242 "Host: www.example.org\r\n"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
11299 TestLoadTimingNotReusedWithPac(load_timing_info, 11299 TestLoadTimingNotReusedWithPac(load_timing_info,
11300 CONNECT_TIMING_HAS_SSL_TIMES); 11300 CONNECT_TIMING_HAS_SSL_TIMES);
11301 } 11301 }
11302 11302
11303 // Test a basic HTTPS GET request through a proxy, but the server hangs up 11303 // Test a basic HTTPS GET request through a proxy, but the server hangs up
11304 // while establishing the tunnel. 11304 // while establishing the tunnel.
11305 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { 11305 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGetHangup) {
11306 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 11306 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
11307 BoundTestNetLog log; 11307 BoundTestNetLog log;
11308 session_deps_.net_log = log.bound().net_log(); 11308 session_deps_.net_log = log.bound().net_log();
11309 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11309 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11310 11310
11311 HttpRequestInfo request; 11311 HttpRequestInfo request;
11312 request.method = "GET"; 11312 request.method = "GET";
11313 request.url = GURL("https://www.example.org/"); 11313 request.url = GURL("https://www.example.org/");
11314 11314
11315 // Since we have proxy, should try to establish tunnel. 11315 // Since we have proxy, should try to establish tunnel.
11316 MockWrite data_writes1[] = { 11316 MockWrite data_writes1[] = {
11317 MockWrite( 11317 MockWrite(
11318 "CONNECT www.example.org:443 HTTP/1.1\r\n" 11318 "CONNECT www.example.org:443 HTTP/1.1\r\n"
11319 "Host: www.example.org\r\n" 11319 "Host: www.example.org\r\n"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
11371 }; 11371 };
11372 11372
11373 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, 11373 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes,
11374 arraysize(spdy_writes)); 11374 arraysize(spdy_writes));
11375 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); 11375 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data);
11376 11376
11377 SSLSocketDataProvider ssl(ASYNC, OK); 11377 SSLSocketDataProvider ssl(ASYNC, OK);
11378 ssl.SetNextProto(GetParam()); 11378 ssl.SetNextProto(GetParam());
11379 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 11379 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
11380 11380
11381 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11381 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11382 11382
11383 // Set up an initial SpdySession in the pool to reuse. 11383 // Set up an initial SpdySession in the pool to reuse.
11384 HostPortPair host_port_pair("www.example.org", 443); 11384 HostPortPair host_port_pair("www.example.org", 443);
11385 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), 11385 SpdySessionKey key(host_port_pair, ProxyServer::Direct(),
11386 PRIVACY_MODE_DISABLED); 11386 PRIVACY_MODE_DISABLED);
11387 base::WeakPtr<SpdySession> spdy_session = 11387 base::WeakPtr<SpdySession> spdy_session =
11388 CreateInsecureSpdySession(session.get(), key, BoundNetLog()); 11388 CreateInsecureSpdySession(session, key, BoundNetLog());
11389 11389
11390 HttpRequestInfo request; 11390 HttpRequestInfo request;
11391 request.method = "GET"; 11391 request.method = "GET";
11392 request.url = GURL("https://www.example.org/"); 11392 request.url = GURL("https://www.example.org/");
11393 request.load_flags = 0; 11393 request.load_flags = 0;
11394 11394
11395 // This is the important line that marks this as a preconnect. 11395 // This is the important line that marks this as a preconnect.
11396 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; 11396 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED;
11397 11397
11398 scoped_ptr<HttpTransaction> trans( 11398 scoped_ptr<HttpTransaction> trans(
(...skipping 15 matching lines...) Expand all
11414 request_info.load_flags = LOAD_NORMAL; 11414 request_info.load_flags = LOAD_NORMAL;
11415 11415
11416 SSLSocketDataProvider ssl_data(mode, OK); 11416 SSLSocketDataProvider ssl_data(mode, OK);
11417 MockWrite data_writes[] = { 11417 MockWrite data_writes[] = {
11418 MockWrite(mode, error), 11418 MockWrite(mode, error),
11419 }; 11419 };
11420 StaticSocketDataProvider data(NULL, 0, data_writes, arraysize(data_writes)); 11420 StaticSocketDataProvider data(NULL, 0, data_writes, arraysize(data_writes));
11421 session_deps_.socket_factory->AddSocketDataProvider(&data); 11421 session_deps_.socket_factory->AddSocketDataProvider(&data);
11422 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data); 11422 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data);
11423 11423
11424 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11424 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11425 scoped_ptr<HttpTransaction> trans( 11425 scoped_ptr<HttpTransaction> trans(
11426 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 11426 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
11427 11427
11428 TestCompletionCallback callback; 11428 TestCompletionCallback callback;
11429 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog()); 11429 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog());
11430 if (rv == ERR_IO_PENDING) 11430 if (rv == ERR_IO_PENDING)
11431 rv = callback.WaitForResult(); 11431 rv = callback.WaitForResult();
11432 ASSERT_EQ(error, rv); 11432 ASSERT_EQ(error, rv);
11433 } 11433 }
11434 11434
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
11501 // connection was attempted with TLSv1.1. This is transparent to the caller 11501 // connection was attempted with TLSv1.1. This is transparent to the caller
11502 // of the HttpNetworkTransaction. Because this test failure is due to 11502 // of the HttpNetworkTransaction. Because this test failure is due to
11503 // requiring a client certificate, this fallback handshake should also 11503 // requiring a client certificate, this fallback handshake should also
11504 // fail. 11504 // fail.
11505 SSLSocketDataProvider ssl_data4(ASYNC, ERR_SSL_PROTOCOL_ERROR); 11505 SSLSocketDataProvider ssl_data4(ASYNC, ERR_SSL_PROTOCOL_ERROR);
11506 ssl_data4.cert_request_info = cert_request.get(); 11506 ssl_data4.cert_request_info = cert_request.get();
11507 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); 11507 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4);
11508 StaticSocketDataProvider data4(NULL, 0, NULL, 0); 11508 StaticSocketDataProvider data4(NULL, 0, NULL, 0);
11509 session_deps_.socket_factory->AddSocketDataProvider(&data4); 11509 session_deps_.socket_factory->AddSocketDataProvider(&data4);
11510 11510
11511 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11511 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11512 scoped_ptr<HttpTransaction> trans( 11512 scoped_ptr<HttpTransaction> trans(
11513 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 11513 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
11514 11514
11515 // Begin the SSL handshake with the peer. This consumes ssl_data1. 11515 // Begin the SSL handshake with the peer. This consumes ssl_data1.
11516 TestCompletionCallback callback; 11516 TestCompletionCallback callback;
11517 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog()); 11517 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog());
11518 ASSERT_EQ(ERR_IO_PENDING, rv); 11518 ASSERT_EQ(ERR_IO_PENDING, rv);
11519 11519
11520 // Complete the SSL handshake, which should abort due to requiring a 11520 // Complete the SSL handshake, which should abort due to requiring a
11521 // client certificate. 11521 // client certificate.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
11618 StaticSocketDataProvider data4(data2_reads, arraysize(data2_reads), NULL, 0); 11618 StaticSocketDataProvider data4(data2_reads, arraysize(data2_reads), NULL, 0);
11619 session_deps_.socket_factory->AddSocketDataProvider(&data4); 11619 session_deps_.socket_factory->AddSocketDataProvider(&data4);
11620 11620
11621 // Need one more if TLSv1.2 is enabled. 11621 // Need one more if TLSv1.2 is enabled.
11622 SSLSocketDataProvider ssl_data5(ASYNC, OK); 11622 SSLSocketDataProvider ssl_data5(ASYNC, OK);
11623 ssl_data5.cert_request_info = cert_request.get(); 11623 ssl_data5.cert_request_info = cert_request.get();
11624 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); 11624 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5);
11625 StaticSocketDataProvider data5(data2_reads, arraysize(data2_reads), NULL, 0); 11625 StaticSocketDataProvider data5(data2_reads, arraysize(data2_reads), NULL, 0);
11626 session_deps_.socket_factory->AddSocketDataProvider(&data5); 11626 session_deps_.socket_factory->AddSocketDataProvider(&data5);
11627 11627
11628 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11628 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11629 scoped_ptr<HttpTransaction> trans( 11629 scoped_ptr<HttpTransaction> trans(
11630 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 11630 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
11631 11631
11632 // Begin the initial SSL handshake. 11632 // Begin the initial SSL handshake.
11633 TestCompletionCallback callback; 11633 TestCompletionCallback callback;
11634 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog()); 11634 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog());
11635 ASSERT_EQ(ERR_IO_PENDING, rv); 11635 ASSERT_EQ(ERR_IO_PENDING, rv);
11636 11636
11637 // Complete the SSL handshake, which should abort due to requiring a 11637 // Complete the SSL handshake, which should abort due to requiring a
11638 // client certificate. 11638 // client certificate.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
11711 requests[0].url = GURL("https://www.example.com/"); 11711 requests[0].url = GURL("https://www.example.com/");
11712 requests[0].method = "GET"; 11712 requests[0].method = "GET";
11713 requests[0].load_flags = LOAD_NORMAL; 11713 requests[0].load_flags = LOAD_NORMAL;
11714 11714
11715 requests[1].url = GURL("http://www.example.com/"); 11715 requests[1].url = GURL("http://www.example.com/");
11716 requests[1].method = "GET"; 11716 requests[1].method = "GET";
11717 requests[1].load_flags = LOAD_NORMAL; 11717 requests[1].load_flags = LOAD_NORMAL;
11718 11718
11719 for (size_t i = 0; i < arraysize(requests); ++i) { 11719 for (size_t i = 0; i < arraysize(requests); ++i) {
11720 session_deps_.socket_factory->ResetNextMockIndexes(); 11720 session_deps_.socket_factory->ResetNextMockIndexes();
11721 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11721 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11722 scoped_ptr<HttpNetworkTransaction> trans( 11722 scoped_ptr<HttpNetworkTransaction> trans(
11723 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 11723 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
11724 11724
11725 // Begin the SSL handshake with the proxy. 11725 // Begin the SSL handshake with the proxy.
11726 TestCompletionCallback callback; 11726 TestCompletionCallback callback;
11727 int rv = trans->Start(&requests[i], callback.callback(), BoundNetLog()); 11727 int rv = trans->Start(&requests[i], callback.callback(), BoundNetLog());
11728 ASSERT_EQ(ERR_IO_PENDING, rv); 11728 ASSERT_EQ(ERR_IO_PENDING, rv);
11729 11729
11730 // Complete the SSL handshake, which should abort due to requiring a 11730 // Complete the SSL handshake, which should abort due to requiring a
11731 // client certificate. 11731 // client certificate.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
11764 HostPortPair("www.example.com", 443), &client_cert)); 11764 HostPortPair("www.example.com", 443), &client_cert));
11765 } 11765 }
11766 } 11766 }
11767 11767
11768 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) { 11768 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) {
11769 session_deps_.use_alternative_services = true; 11769 session_deps_.use_alternative_services = true;
11770 session_deps_.next_protos = SpdyNextProtos(); 11770 session_deps_.next_protos = SpdyNextProtos();
11771 11771
11772 // Set up a special HttpNetworkSession with a MockCachingHostResolver. 11772 // Set up a special HttpNetworkSession with a MockCachingHostResolver.
11773 session_deps_.host_resolver.reset(new MockCachingHostResolver()); 11773 session_deps_.host_resolver.reset(new MockCachingHostResolver());
11774 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11774 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11775 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11775 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11776 pool_peer.DisableDomainAuthenticationVerification(); 11776 pool_peer.DisableDomainAuthenticationVerification();
11777 11777
11778 SSLSocketDataProvider ssl(ASYNC, OK); 11778 SSLSocketDataProvider ssl(ASYNC, OK);
11779 ssl.SetNextProto(GetParam()); 11779 ssl.SetNextProto(GetParam());
11780 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 11780 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
11781 11781
11782 scoped_ptr<SpdyFrame> host1_req( 11782 scoped_ptr<SpdyFrame> host1_req(
11783 spdy_util_.ConstructSpdyGet("https://www.example.org", false, 1, LOWEST)); 11783 spdy_util_.ConstructSpdyGet("https://www.example.org", false, 1, LOWEST));
11784 scoped_ptr<SpdyFrame> host2_req( 11784 scoped_ptr<SpdyFrame> host2_req(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
11863 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); 11863 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data));
11864 EXPECT_EQ("hello!", response_data); 11864 EXPECT_EQ("hello!", response_data);
11865 } 11865 }
11866 11866
11867 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { 11867 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) {
11868 session_deps_.use_alternative_services = true; 11868 session_deps_.use_alternative_services = true;
11869 session_deps_.next_protos = SpdyNextProtos(); 11869 session_deps_.next_protos = SpdyNextProtos();
11870 11870
11871 // Set up a special HttpNetworkSession with a MockCachingHostResolver. 11871 // Set up a special HttpNetworkSession with a MockCachingHostResolver.
11872 session_deps_.host_resolver.reset(new MockCachingHostResolver()); 11872 session_deps_.host_resolver.reset(new MockCachingHostResolver());
11873 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11873 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11874 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11874 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11875 pool_peer.DisableDomainAuthenticationVerification(); 11875 pool_peer.DisableDomainAuthenticationVerification();
11876 11876
11877 SSLSocketDataProvider ssl(ASYNC, OK); 11877 SSLSocketDataProvider ssl(ASYNC, OK);
11878 ssl.SetNextProto(GetParam()); 11878 ssl.SetNextProto(GetParam());
11879 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 11879 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
11880 11880
11881 scoped_ptr<SpdyFrame> host1_req( 11881 scoped_ptr<SpdyFrame> host1_req(
11882 spdy_util_.ConstructSpdyGet("https://www.example.org", false, 1, LOWEST)); 11882 spdy_util_.ConstructSpdyGet("https://www.example.org", false, 1, LOWEST));
11883 scoped_ptr<SpdyFrame> host2_req( 11883 scoped_ptr<SpdyFrame> host2_req(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
11993 TEST_P(HttpNetworkTransactionTest, 11993 TEST_P(HttpNetworkTransactionTest,
11994 UseIPConnectionPoolingWithHostCacheExpiration) { 11994 UseIPConnectionPoolingWithHostCacheExpiration) {
11995 session_deps_.use_alternative_services = true; 11995 session_deps_.use_alternative_services = true;
11996 session_deps_.next_protos = SpdyNextProtos(); 11996 session_deps_.next_protos = SpdyNextProtos();
11997 11997
11998 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. 11998 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver.
11999 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); 11999 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443));
12000 HttpNetworkSession::Params params = 12000 HttpNetworkSession::Params params =
12001 SpdySessionDependencies::CreateSessionParams(&session_deps_); 12001 SpdySessionDependencies::CreateSessionParams(&session_deps_);
12002 params.host_resolver = &host_resolver; 12002 params.host_resolver = &host_resolver;
12003 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12003 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12004 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 12004 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
12005 pool_peer.DisableDomainAuthenticationVerification(); 12005 pool_peer.DisableDomainAuthenticationVerification();
12006 12006
12007 SSLSocketDataProvider ssl(ASYNC, OK); 12007 SSLSocketDataProvider ssl(ASYNC, OK);
12008 ssl.SetNextProto(GetParam()); 12008 ssl.SetNextProto(GetParam());
12009 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 12009 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
12010 12010
12011 scoped_ptr<SpdyFrame> host1_req( 12011 scoped_ptr<SpdyFrame> host1_req(
12012 spdy_util_.ConstructSpdyGet("https://www.example.org", false, 1, LOWEST)); 12012 spdy_util_.ConstructSpdyGet("https://www.example.org", false, 1, LOWEST));
12013 scoped_ptr<SpdyFrame> host2_req( 12013 scoped_ptr<SpdyFrame> host2_req(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
12133 12133
12134 SequencedSocketData data2(reads2, arraysize(reads2), writes2, 12134 SequencedSocketData data2(reads2, arraysize(reads2), writes2,
12135 arraysize(writes2)); 12135 arraysize(writes2));
12136 12136
12137 SSLSocketDataProvider ssl(ASYNC, OK); 12137 SSLSocketDataProvider ssl(ASYNC, OK);
12138 ssl.SetNextProto(GetParam()); 12138 ssl.SetNextProto(GetParam());
12139 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 12139 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
12140 session_deps_.socket_factory->AddSocketDataProvider(&data1); 12140 session_deps_.socket_factory->AddSocketDataProvider(&data1);
12141 session_deps_.socket_factory->AddSocketDataProvider(&data2); 12141 session_deps_.socket_factory->AddSocketDataProvider(&data2);
12142 12142
12143 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12143 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12144 12144
12145 // Start the first transaction to set up the SpdySession 12145 // Start the first transaction to set up the SpdySession
12146 HttpRequestInfo request1; 12146 HttpRequestInfo request1;
12147 request1.method = "GET"; 12147 request1.method = "GET";
12148 request1.url = GURL(https_url); 12148 request1.url = GURL(https_url);
12149 request1.load_flags = 0; 12149 request1.load_flags = 0;
12150 HttpNetworkTransaction trans1(LOWEST, session.get()); 12150 HttpNetworkTransaction trans1(LOWEST, session.get());
12151 TestCompletionCallback callback1; 12151 TestCompletionCallback callback1;
12152 EXPECT_EQ(ERR_IO_PENDING, 12152 EXPECT_EQ(ERR_IO_PENDING,
12153 trans1.Start(&request1, callback1.callback(), BoundNetLog())); 12153 trans1.Start(&request1, callback1.callback(), BoundNetLog()));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
12245 vector_as_array(&writes), writes.size()); 12245 vector_as_array(&writes), writes.size());
12246 session_deps_.socket_factory->AddSocketDataProvider(&data); 12246 session_deps_.socket_factory->AddSocketDataProvider(&data);
12247 12247
12248 // Connection to the origin fails. 12248 // Connection to the origin fails.
12249 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 12249 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
12250 StaticSocketDataProvider data_refused; 12250 StaticSocketDataProvider data_refused;
12251 data_refused.set_connect_data(mock_connect); 12251 data_refused.set_connect_data(mock_connect);
12252 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12252 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12253 12253
12254 session_deps_.use_alternative_services = true; 12254 session_deps_.use_alternative_services = true;
12255 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12255 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12256 base::WeakPtr<HttpServerProperties> http_server_properties = 12256 base::WeakPtr<HttpServerProperties> http_server_properties =
12257 session->http_server_properties(); 12257 session->http_server_properties();
12258 AlternativeService alternative_service( 12258 AlternativeService alternative_service(
12259 AlternateProtocolFromNextProto(GetParam()), alternative); 12259 AlternateProtocolFromNextProto(GetParam()), alternative);
12260 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12260 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12261 http_server_properties->SetAlternativeService(origin, alternative_service, 12261 http_server_properties->SetAlternativeService(origin, alternative_service,
12262 1.0, expiration); 12262 1.0, expiration);
12263 12263
12264 // First request to alternative. 12264 // First request to alternative.
12265 if (pooling) { 12265 if (pooling) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
12349 12349
12350 // This test documents that an alternate Job should not be used if HTTP/1.1 is 12350 // This test documents that an alternate Job should not be used if HTTP/1.1 is
12351 // negotiated. In order to test this, a failed connection to the origin is 12351 // negotiated. In order to test this, a failed connection to the origin is
12352 // mocked. This way the request relies on the alternate Job. 12352 // mocked. This way the request relies on the alternate Job.
12353 StaticSocketDataProvider data_refused; 12353 StaticSocketDataProvider data_refused;
12354 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 12354 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
12355 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12355 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12356 12356
12357 // Set up alternative service for origin. 12357 // Set up alternative service for origin.
12358 session_deps_.use_alternative_services = true; 12358 session_deps_.use_alternative_services = true;
12359 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12359 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12360 base::WeakPtr<HttpServerProperties> http_server_properties = 12360 base::WeakPtr<HttpServerProperties> http_server_properties =
12361 session->http_server_properties(); 12361 session->http_server_properties();
12362 AlternativeService alternative_service( 12362 AlternativeService alternative_service(
12363 AlternateProtocolFromNextProto(GetParam()), alternative); 12363 AlternateProtocolFromNextProto(GetParam()), alternative);
12364 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12364 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12365 http_server_properties->SetAlternativeService(origin, alternative_service, 12365 http_server_properties->SetAlternativeService(origin, alternative_service,
12366 1.0, expiration); 12366 1.0, expiration);
12367 12367
12368 scoped_ptr<HttpTransaction> trans( 12368 scoped_ptr<HttpTransaction> trans(
12369 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 12369 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
12422 MockRead("Content-Type: text/html\r\n"), 12422 MockRead("Content-Type: text/html\r\n"),
12423 MockRead("Content-Length: 7\r\n\r\n"), 12423 MockRead("Content-Length: 7\r\n\r\n"),
12424 MockRead("another"), 12424 MockRead("another"),
12425 }; 12425 };
12426 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 12426 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
12427 http_writes, arraysize(http_writes)); 12427 http_writes, arraysize(http_writes));
12428 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 12428 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
12429 12429
12430 // Set up alternative service for origin. 12430 // Set up alternative service for origin.
12431 session_deps_.use_alternative_services = true; 12431 session_deps_.use_alternative_services = true;
12432 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12432 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12433 base::WeakPtr<HttpServerProperties> http_server_properties = 12433 base::WeakPtr<HttpServerProperties> http_server_properties =
12434 session->http_server_properties(); 12434 session->http_server_properties();
12435 AlternativeService alternative_service( 12435 AlternativeService alternative_service(
12436 AlternateProtocolFromNextProto(GetParam()), alternative); 12436 AlternateProtocolFromNextProto(GetParam()), alternative);
12437 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12437 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12438 http_server_properties->SetAlternativeService(origin, alternative_service, 12438 http_server_properties->SetAlternativeService(origin, alternative_service,
12439 1.0, expiration); 12439 1.0, expiration);
12440 12440
12441 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 12441 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
12442 HttpRequestInfo request1; 12442 HttpRequestInfo request1;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
12531 12531
12532 // This test documents that an alternate Job should not pool to an already 12532 // This test documents that an alternate Job should not pool to an already
12533 // existing HTTP/1.1 connection. In order to test this, a failed connection 12533 // existing HTTP/1.1 connection. In order to test this, a failed connection
12534 // to the origin is mocked. This way |request2| relies on the alternate Job. 12534 // to the origin is mocked. This way |request2| relies on the alternate Job.
12535 StaticSocketDataProvider data_refused; 12535 StaticSocketDataProvider data_refused;
12536 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 12536 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
12537 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12537 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12538 12538
12539 // Set up alternative service for origin. 12539 // Set up alternative service for origin.
12540 session_deps_.use_alternative_services = true; 12540 session_deps_.use_alternative_services = true;
12541 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12541 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12542 base::WeakPtr<HttpServerProperties> http_server_properties = 12542 base::WeakPtr<HttpServerProperties> http_server_properties =
12543 session->http_server_properties(); 12543 session->http_server_properties();
12544 AlternativeService alternative_service( 12544 AlternativeService alternative_service(
12545 AlternateProtocolFromNextProto(GetParam()), alternative); 12545 AlternateProtocolFromNextProto(GetParam()), alternative);
12546 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12546 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12547 http_server_properties->SetAlternativeService(origin, alternative_service, 12547 http_server_properties->SetAlternativeService(origin, alternative_service,
12548 1.0, expiration); 12548 1.0, expiration);
12549 12549
12550 // First transaction to alternative to open an HTTP/1.1 socket. 12550 // First transaction to alternative to open an HTTP/1.1 socket.
12551 scoped_ptr<HttpTransaction> trans1( 12551 scoped_ptr<HttpTransaction> trans1(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
12665 TestNetLog log; 12665 TestNetLog log;
12666 session_deps_.net_log = &log; 12666 session_deps_.net_log = &log;
12667 SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy 12667 SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy
12668 ssl1.SetNextProto(GetParam()); 12668 ssl1.SetNextProto(GetParam());
12669 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl1); 12669 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl1);
12670 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server 12670 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server
12671 ssl2.SetNextProto(GetParam()); 12671 ssl2.SetNextProto(GetParam());
12672 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); 12672 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2);
12673 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1); 12673 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1);
12674 12674
12675 scoped_ptr<HttpNetworkSession> session( 12675 scoped_refptr<HttpNetworkSession> session(
12676 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); 12676 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_));
12677 12677
12678 // Start the first transaction to set up the SpdySession 12678 // Start the first transaction to set up the SpdySession
12679 HttpRequestInfo request1; 12679 HttpRequestInfo request1;
12680 request1.method = "GET"; 12680 request1.method = "GET";
12681 request1.url = GURL(https_url); 12681 request1.url = GURL(https_url);
12682 request1.load_flags = 0; 12682 request1.load_flags = 0;
12683 HttpNetworkTransaction trans1(LOWEST, session.get()); 12683 HttpNetworkTransaction trans1(LOWEST, session.get());
12684 TestCompletionCallback callback1; 12684 TestCompletionCallback callback1;
12685 EXPECT_EQ(ERR_IO_PENDING, 12685 EXPECT_EQ(ERR_IO_PENDING,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
12799 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server 12799 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server
12800 ssl2.SetNextProto(GetParam()); 12800 ssl2.SetNextProto(GetParam());
12801 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); 12801 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2);
12802 session_deps_.deterministic_socket_factory->AddSocketDataProvider( 12802 session_deps_.deterministic_socket_factory->AddSocketDataProvider(
12803 data2.get()); 12803 data2.get());
12804 12804
12805 session_deps_.host_resolver.reset(new MockCachingHostResolver()); 12805 session_deps_.host_resolver.reset(new MockCachingHostResolver());
12806 session_deps_.host_resolver->rules()->AddRule("news.example.org", ip_addr); 12806 session_deps_.host_resolver->rules()->AddRule("news.example.org", ip_addr);
12807 session_deps_.host_resolver->rules()->AddRule("proxy", ip_addr); 12807 session_deps_.host_resolver->rules()->AddRule("proxy", ip_addr);
12808 12808
12809 scoped_ptr<HttpNetworkSession> session( 12809 scoped_refptr<HttpNetworkSession> session(
12810 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); 12810 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_));
12811 12811
12812 // Start the first transaction to set up the SpdySession 12812 // Start the first transaction to set up the SpdySession
12813 HttpRequestInfo request1; 12813 HttpRequestInfo request1;
12814 request1.method = "GET"; 12814 request1.method = "GET";
12815 request1.url = GURL(url1); 12815 request1.url = GURL(url1);
12816 request1.load_flags = 0; 12816 request1.load_flags = 0;
12817 HttpNetworkTransaction trans1(LOWEST, session.get()); 12817 HttpNetworkTransaction trans1(LOWEST, session.get());
12818 TestCompletionCallback callback1; 12818 TestCompletionCallback callback1;
12819 ASSERT_EQ(ERR_IO_PENDING, 12819 ASSERT_EQ(ERR_IO_PENDING,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
12874 SSLSocketDataProvider ssl1(ASYNC, OK); 12874 SSLSocketDataProvider ssl1(ASYNC, OK);
12875 ssl1.SetNextProto(GetParam()); 12875 ssl1.SetNextProto(GetParam());
12876 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1); 12876 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1);
12877 session_deps_.socket_factory->AddSocketDataProvider(&data1); 12877 session_deps_.socket_factory->AddSocketDataProvider(&data1);
12878 12878
12879 SSLSocketDataProvider ssl2(ASYNC, OK); 12879 SSLSocketDataProvider ssl2(ASYNC, OK);
12880 ssl2.SetNextProto(GetParam()); 12880 ssl2.SetNextProto(GetParam());
12881 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); 12881 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2);
12882 session_deps_.socket_factory->AddSocketDataProvider(&data2); 12882 session_deps_.socket_factory->AddSocketDataProvider(&data2);
12883 12883
12884 scoped_ptr<HttpNetworkSession> session( 12884 scoped_refptr<HttpNetworkSession> session(
12885 SpdySessionDependencies::SpdyCreateSession(&session_deps_)); 12885 SpdySessionDependencies::SpdyCreateSession(&session_deps_));
12886 12886
12887 // Start the first transaction to set up the SpdySession and verify that 12887 // Start the first transaction to set up the SpdySession and verify that
12888 // connection was closed. 12888 // connection was closed.
12889 HttpRequestInfo request1; 12889 HttpRequestInfo request1;
12890 request1.method = "GET"; 12890 request1.method = "GET";
12891 request1.url = GURL(https_url); 12891 request1.url = GURL(https_url);
12892 request1.load_flags = 0; 12892 request1.load_flags = 0;
12893 HttpNetworkTransaction trans1(MEDIUM, session.get()); 12893 HttpNetworkTransaction trans1(MEDIUM, session.get());
12894 TestCompletionCallback callback1; 12894 TestCompletionCallback callback1;
(...skipping 18 matching lines...) Expand all
12913 TEST_P(HttpNetworkTransactionTest, CloseIdleSpdySessionToOpenNewOne) { 12913 TEST_P(HttpNetworkTransactionTest, CloseIdleSpdySessionToOpenNewOne) {
12914 session_deps_.next_protos = SpdyNextProtos(); 12914 session_deps_.next_protos = SpdyNextProtos();
12915 ClientSocketPoolManager::set_max_sockets_per_group( 12915 ClientSocketPoolManager::set_max_sockets_per_group(
12916 HttpNetworkSession::NORMAL_SOCKET_POOL, 1); 12916 HttpNetworkSession::NORMAL_SOCKET_POOL, 1);
12917 ClientSocketPoolManager::set_max_sockets_per_pool( 12917 ClientSocketPoolManager::set_max_sockets_per_pool(
12918 HttpNetworkSession::NORMAL_SOCKET_POOL, 1); 12918 HttpNetworkSession::NORMAL_SOCKET_POOL, 1);
12919 12919
12920 // Use two different hosts with different IPs so they don't get pooled. 12920 // Use two different hosts with different IPs so they don't get pooled.
12921 session_deps_.host_resolver->rules()->AddRule("www.a.com", "10.0.0.1"); 12921 session_deps_.host_resolver->rules()->AddRule("www.a.com", "10.0.0.1");
12922 session_deps_.host_resolver->rules()->AddRule("www.b.com", "10.0.0.2"); 12922 session_deps_.host_resolver->rules()->AddRule("www.b.com", "10.0.0.2");
12923 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12923 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12924 12924
12925 SSLSocketDataProvider ssl1(ASYNC, OK); 12925 SSLSocketDataProvider ssl1(ASYNC, OK);
12926 ssl1.SetNextProto(GetParam()); 12926 ssl1.SetNextProto(GetParam());
12927 SSLSocketDataProvider ssl2(ASYNC, OK); 12927 SSLSocketDataProvider ssl2(ASYNC, OK);
12928 ssl2.SetNextProto(GetParam()); 12928 ssl2.SetNextProto(GetParam());
12929 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1); 12929 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1);
12930 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); 12930 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2);
12931 12931
12932 scoped_ptr<SpdyFrame> host1_req(spdy_util_.ConstructSpdyGet( 12932 scoped_ptr<SpdyFrame> host1_req(spdy_util_.ConstructSpdyGet(
12933 "https://www.a.com", false, 1, DEFAULT_PRIORITY)); 12933 "https://www.a.com", false, 1, DEFAULT_PRIORITY));
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
13073 EXPECT_FALSE( 13073 EXPECT_FALSE(
13074 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); 13074 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b));
13075 } 13075 }
13076 13076
13077 TEST_P(HttpNetworkTransactionTest, HttpSyncConnectError) { 13077 TEST_P(HttpNetworkTransactionTest, HttpSyncConnectError) {
13078 HttpRequestInfo request; 13078 HttpRequestInfo request;
13079 request.method = "GET"; 13079 request.method = "GET";
13080 request.url = GURL("http://www.example.org/"); 13080 request.url = GURL("http://www.example.org/");
13081 request.load_flags = 0; 13081 request.load_flags = 0;
13082 13082
13083 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13083 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13084 scoped_ptr<HttpTransaction> trans( 13084 scoped_ptr<HttpTransaction> trans(
13085 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13085 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13086 13086
13087 MockConnect mock_connect(SYNCHRONOUS, ERR_CONNECTION_REFUSED); 13087 MockConnect mock_connect(SYNCHRONOUS, ERR_CONNECTION_REFUSED);
13088 StaticSocketDataProvider data; 13088 StaticSocketDataProvider data;
13089 data.set_connect_data(mock_connect); 13089 data.set_connect_data(mock_connect);
13090 session_deps_.socket_factory->AddSocketDataProvider(&data); 13090 session_deps_.socket_factory->AddSocketDataProvider(&data);
13091 13091
13092 TestCompletionCallback callback; 13092 TestCompletionCallback callback;
13093 13093
(...skipping 12 matching lines...) Expand all
13106 ASSERT_EQ(1u, attempts.size()); 13106 ASSERT_EQ(1u, attempts.size());
13107 EXPECT_EQ(ERR_CONNECTION_REFUSED, attempts[0].result); 13107 EXPECT_EQ(ERR_CONNECTION_REFUSED, attempts[0].result);
13108 } 13108 }
13109 13109
13110 TEST_P(HttpNetworkTransactionTest, HttpAsyncConnectError) { 13110 TEST_P(HttpNetworkTransactionTest, HttpAsyncConnectError) {
13111 HttpRequestInfo request; 13111 HttpRequestInfo request;
13112 request.method = "GET"; 13112 request.method = "GET";
13113 request.url = GURL("http://www.example.org/"); 13113 request.url = GURL("http://www.example.org/");
13114 request.load_flags = 0; 13114 request.load_flags = 0;
13115 13115
13116 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13116 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13117 scoped_ptr<HttpTransaction> trans( 13117 scoped_ptr<HttpTransaction> trans(
13118 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13118 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13119 13119
13120 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 13120 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
13121 StaticSocketDataProvider data; 13121 StaticSocketDataProvider data;
13122 data.set_connect_data(mock_connect); 13122 data.set_connect_data(mock_connect);
13123 session_deps_.socket_factory->AddSocketDataProvider(&data); 13123 session_deps_.socket_factory->AddSocketDataProvider(&data);
13124 13124
13125 TestCompletionCallback callback; 13125 TestCompletionCallback callback;
13126 13126
(...skipping 12 matching lines...) Expand all
13139 ASSERT_EQ(1u, attempts.size()); 13139 ASSERT_EQ(1u, attempts.size());
13140 EXPECT_EQ(ERR_CONNECTION_REFUSED, attempts[0].result); 13140 EXPECT_EQ(ERR_CONNECTION_REFUSED, attempts[0].result);
13141 } 13141 }
13142 13142
13143 TEST_P(HttpNetworkTransactionTest, HttpSyncWriteError) { 13143 TEST_P(HttpNetworkTransactionTest, HttpSyncWriteError) {
13144 HttpRequestInfo request; 13144 HttpRequestInfo request;
13145 request.method = "GET"; 13145 request.method = "GET";
13146 request.url = GURL("http://www.example.org/"); 13146 request.url = GURL("http://www.example.org/");
13147 request.load_flags = 0; 13147 request.load_flags = 0;
13148 13148
13149 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13149 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13150 scoped_ptr<HttpTransaction> trans( 13150 scoped_ptr<HttpTransaction> trans(
13151 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13151 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13152 13152
13153 MockWrite data_writes[] = { 13153 MockWrite data_writes[] = {
13154 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 13154 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
13155 }; 13155 };
13156 MockRead data_reads[] = { 13156 MockRead data_reads[] = {
13157 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. 13157 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached.
13158 }; 13158 };
13159 13159
(...skipping 13 matching lines...) Expand all
13173 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); 13173 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
13174 EXPECT_TRUE(request_headers.HasHeader("Host")); 13174 EXPECT_TRUE(request_headers.HasHeader("Host"));
13175 } 13175 }
13176 13176
13177 TEST_P(HttpNetworkTransactionTest, HttpAsyncWriteError) { 13177 TEST_P(HttpNetworkTransactionTest, HttpAsyncWriteError) {
13178 HttpRequestInfo request; 13178 HttpRequestInfo request;
13179 request.method = "GET"; 13179 request.method = "GET";
13180 request.url = GURL("http://www.example.org/"); 13180 request.url = GURL("http://www.example.org/");
13181 request.load_flags = 0; 13181 request.load_flags = 0;
13182 13182
13183 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13183 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13184 scoped_ptr<HttpTransaction> trans( 13184 scoped_ptr<HttpTransaction> trans(
13185 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13185 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13186 13186
13187 MockWrite data_writes[] = { 13187 MockWrite data_writes[] = {
13188 MockWrite(ASYNC, ERR_CONNECTION_RESET), 13188 MockWrite(ASYNC, ERR_CONNECTION_RESET),
13189 }; 13189 };
13190 MockRead data_reads[] = { 13190 MockRead data_reads[] = {
13191 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. 13191 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached.
13192 }; 13192 };
13193 13193
(...skipping 13 matching lines...) Expand all
13207 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); 13207 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
13208 EXPECT_TRUE(request_headers.HasHeader("Host")); 13208 EXPECT_TRUE(request_headers.HasHeader("Host"));
13209 } 13209 }
13210 13210
13211 TEST_P(HttpNetworkTransactionTest, HttpSyncReadError) { 13211 TEST_P(HttpNetworkTransactionTest, HttpSyncReadError) {
13212 HttpRequestInfo request; 13212 HttpRequestInfo request;
13213 request.method = "GET"; 13213 request.method = "GET";
13214 request.url = GURL("http://www.example.org/"); 13214 request.url = GURL("http://www.example.org/");
13215 request.load_flags = 0; 13215 request.load_flags = 0;
13216 13216
13217 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13217 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13218 scoped_ptr<HttpTransaction> trans( 13218 scoped_ptr<HttpTransaction> trans(
13219 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13219 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13220 13220
13221 MockWrite data_writes[] = { 13221 MockWrite data_writes[] = {
13222 MockWrite( 13222 MockWrite(
13223 "GET / HTTP/1.1\r\n" 13223 "GET / HTTP/1.1\r\n"
13224 "Host: www.example.org\r\n" 13224 "Host: www.example.org\r\n"
13225 "Connection: keep-alive\r\n\r\n"), 13225 "Connection: keep-alive\r\n\r\n"),
13226 }; 13226 };
13227 MockRead data_reads[] = { 13227 MockRead data_reads[] = {
(...skipping 16 matching lines...) Expand all
13244 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); 13244 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
13245 EXPECT_TRUE(request_headers.HasHeader("Host")); 13245 EXPECT_TRUE(request_headers.HasHeader("Host"));
13246 } 13246 }
13247 13247
13248 TEST_P(HttpNetworkTransactionTest, HttpAsyncReadError) { 13248 TEST_P(HttpNetworkTransactionTest, HttpAsyncReadError) {
13249 HttpRequestInfo request; 13249 HttpRequestInfo request;
13250 request.method = "GET"; 13250 request.method = "GET";
13251 request.url = GURL("http://www.example.org/"); 13251 request.url = GURL("http://www.example.org/");
13252 request.load_flags = 0; 13252 request.load_flags = 0;
13253 13253
13254 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13254 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13255 scoped_ptr<HttpTransaction> trans( 13255 scoped_ptr<HttpTransaction> trans(
13256 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13256 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13257 13257
13258 MockWrite data_writes[] = { 13258 MockWrite data_writes[] = {
13259 MockWrite( 13259 MockWrite(
13260 "GET / HTTP/1.1\r\n" 13260 "GET / HTTP/1.1\r\n"
13261 "Host: www.example.org\r\n" 13261 "Host: www.example.org\r\n"
13262 "Connection: keep-alive\r\n\r\n"), 13262 "Connection: keep-alive\r\n\r\n"),
13263 }; 13263 };
13264 MockRead data_reads[] = { 13264 MockRead data_reads[] = {
(...skipping 17 matching lines...) Expand all
13282 EXPECT_TRUE(request_headers.HasHeader("Host")); 13282 EXPECT_TRUE(request_headers.HasHeader("Host"));
13283 } 13283 }
13284 13284
13285 TEST_P(HttpNetworkTransactionTest, GetFullRequestHeadersIncludesExtraHeader) { 13285 TEST_P(HttpNetworkTransactionTest, GetFullRequestHeadersIncludesExtraHeader) {
13286 HttpRequestInfo request; 13286 HttpRequestInfo request;
13287 request.method = "GET"; 13287 request.method = "GET";
13288 request.url = GURL("http://www.example.org/"); 13288 request.url = GURL("http://www.example.org/");
13289 request.load_flags = 0; 13289 request.load_flags = 0;
13290 request.extra_headers.SetHeader("X-Foo", "bar"); 13290 request.extra_headers.SetHeader("X-Foo", "bar");
13291 13291
13292 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13292 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13293 scoped_ptr<HttpTransaction> trans( 13293 scoped_ptr<HttpTransaction> trans(
13294 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13294 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13295 13295
13296 MockWrite data_writes[] = { 13296 MockWrite data_writes[] = {
13297 MockWrite( 13297 MockWrite(
13298 "GET / HTTP/1.1\r\n" 13298 "GET / HTTP/1.1\r\n"
13299 "Host: www.example.org\r\n" 13299 "Host: www.example.org\r\n"
13300 "Connection: keep-alive\r\n" 13300 "Connection: keep-alive\r\n"
13301 "X-Foo: bar\r\n\r\n"), 13301 "X-Foo: bar\r\n\r\n"),
13302 }; 13302 };
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
13668 NOTREACHED(); 13668 NOTREACHED();
13669 return scoped_ptr<WebSocketStream>(); 13669 return scoped_ptr<WebSocketStream>();
13670 } 13670 }
13671 }; 13671 };
13672 13672
13673 } // namespace 13673 } // namespace
13674 13674
13675 // Make sure that HttpNetworkTransaction passes on its priority to its 13675 // Make sure that HttpNetworkTransaction passes on its priority to its
13676 // stream request on start. 13676 // stream request on start.
13677 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriorityOnStart) { 13677 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriorityOnStart) {
13678 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13678 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13679 HttpNetworkSessionPeer peer(session.get()); 13679 HttpNetworkSessionPeer peer(session);
13680 FakeStreamFactory* fake_factory = new FakeStreamFactory(); 13680 FakeStreamFactory* fake_factory = new FakeStreamFactory();
13681 peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory)); 13681 peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory));
13682 13682
13683 HttpNetworkTransaction trans(LOW, session.get()); 13683 HttpNetworkTransaction trans(LOW, session.get());
13684 13684
13685 ASSERT_TRUE(fake_factory->last_stream_request() == NULL); 13685 ASSERT_TRUE(fake_factory->last_stream_request() == NULL);
13686 13686
13687 HttpRequestInfo request; 13687 HttpRequestInfo request;
13688 TestCompletionCallback callback; 13688 TestCompletionCallback callback;
13689 EXPECT_EQ(ERR_IO_PENDING, 13689 EXPECT_EQ(ERR_IO_PENDING,
13690 trans.Start(&request, callback.callback(), BoundNetLog())); 13690 trans.Start(&request, callback.callback(), BoundNetLog()));
13691 13691
13692 base::WeakPtr<FakeStreamRequest> fake_request = 13692 base::WeakPtr<FakeStreamRequest> fake_request =
13693 fake_factory->last_stream_request(); 13693 fake_factory->last_stream_request();
13694 ASSERT_TRUE(fake_request != NULL); 13694 ASSERT_TRUE(fake_request != NULL);
13695 EXPECT_EQ(LOW, fake_request->priority()); 13695 EXPECT_EQ(LOW, fake_request->priority());
13696 } 13696 }
13697 13697
13698 // Make sure that HttpNetworkTransaction passes on its priority 13698 // Make sure that HttpNetworkTransaction passes on its priority
13699 // updates to its stream request. 13699 // updates to its stream request.
13700 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriority) { 13700 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriority) {
13701 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13701 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13702 HttpNetworkSessionPeer peer(session.get()); 13702 HttpNetworkSessionPeer peer(session);
13703 FakeStreamFactory* fake_factory = new FakeStreamFactory(); 13703 FakeStreamFactory* fake_factory = new FakeStreamFactory();
13704 peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory)); 13704 peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory));
13705 13705
13706 HttpNetworkTransaction trans(LOW, session.get()); 13706 HttpNetworkTransaction trans(LOW, session.get());
13707 13707
13708 HttpRequestInfo request; 13708 HttpRequestInfo request;
13709 TestCompletionCallback callback; 13709 TestCompletionCallback callback;
13710 EXPECT_EQ(ERR_IO_PENDING, 13710 EXPECT_EQ(ERR_IO_PENDING,
13711 trans.Start(&request, callback.callback(), BoundNetLog())); 13711 trans.Start(&request, callback.callback(), BoundNetLog()));
13712 13712
13713 base::WeakPtr<FakeStreamRequest> fake_request = 13713 base::WeakPtr<FakeStreamRequest> fake_request =
13714 fake_factory->last_stream_request(); 13714 fake_factory->last_stream_request();
13715 ASSERT_TRUE(fake_request != NULL); 13715 ASSERT_TRUE(fake_request != NULL);
13716 EXPECT_EQ(LOW, fake_request->priority()); 13716 EXPECT_EQ(LOW, fake_request->priority());
13717 13717
13718 trans.SetPriority(LOWEST); 13718 trans.SetPriority(LOWEST);
13719 ASSERT_TRUE(fake_request != NULL); 13719 ASSERT_TRUE(fake_request != NULL);
13720 EXPECT_EQ(LOWEST, fake_request->priority()); 13720 EXPECT_EQ(LOWEST, fake_request->priority());
13721 } 13721 }
13722 13722
13723 // Make sure that HttpNetworkTransaction passes on its priority 13723 // Make sure that HttpNetworkTransaction passes on its priority
13724 // updates to its stream. 13724 // updates to its stream.
13725 TEST_P(HttpNetworkTransactionTest, SetStreamPriority) { 13725 TEST_P(HttpNetworkTransactionTest, SetStreamPriority) {
13726 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13726 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13727 HttpNetworkSessionPeer peer(session.get()); 13727 HttpNetworkSessionPeer peer(session);
13728 FakeStreamFactory* fake_factory = new FakeStreamFactory(); 13728 FakeStreamFactory* fake_factory = new FakeStreamFactory();
13729 peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory)); 13729 peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory));
13730 13730
13731 HttpNetworkTransaction trans(LOW, session.get()); 13731 HttpNetworkTransaction trans(LOW, session.get());
13732 13732
13733 HttpRequestInfo request; 13733 HttpRequestInfo request;
13734 TestCompletionCallback callback; 13734 TestCompletionCallback callback;
13735 EXPECT_EQ(ERR_IO_PENDING, 13735 EXPECT_EQ(ERR_IO_PENDING,
13736 trans.Start(&request, callback.callback(), BoundNetLog())); 13736 trans.Start(&request, callback.callback(), BoundNetLog()));
13737 13737
13738 base::WeakPtr<FakeStreamRequest> fake_request = 13738 base::WeakPtr<FakeStreamRequest> fake_request =
13739 fake_factory->last_stream_request(); 13739 fake_factory->last_stream_request();
13740 ASSERT_TRUE(fake_request != NULL); 13740 ASSERT_TRUE(fake_request != NULL);
13741 base::WeakPtr<FakeStream> fake_stream = fake_request->FinishStreamRequest(); 13741 base::WeakPtr<FakeStream> fake_stream = fake_request->FinishStreamRequest();
13742 ASSERT_TRUE(fake_stream != NULL); 13742 ASSERT_TRUE(fake_stream != NULL);
13743 EXPECT_EQ(LOW, fake_stream->priority()); 13743 EXPECT_EQ(LOW, fake_stream->priority());
13744 13744
13745 trans.SetPriority(LOWEST); 13745 trans.SetPriority(LOWEST);
13746 EXPECT_EQ(LOWEST, fake_stream->priority()); 13746 EXPECT_EQ(LOWEST, fake_stream->priority());
13747 } 13747 }
13748 13748
13749 TEST_P(HttpNetworkTransactionTest, CreateWebSocketHandshakeStream) { 13749 TEST_P(HttpNetworkTransactionTest, CreateWebSocketHandshakeStream) {
13750 // The same logic needs to be tested for both ws: and wss: schemes, but this 13750 // The same logic needs to be tested for both ws: and wss: schemes, but this
13751 // test is already parameterised on NextProto, so it uses a loop to verify 13751 // test is already parameterised on NextProto, so it uses a loop to verify
13752 // that the different schemes work. 13752 // that the different schemes work.
13753 std::string test_cases[] = {"ws://www.example.org/", 13753 std::string test_cases[] = {"ws://www.example.org/",
13754 "wss://www.example.org/"}; 13754 "wss://www.example.org/"};
13755 for (size_t i = 0; i < arraysize(test_cases); ++i) { 13755 for (size_t i = 0; i < arraysize(test_cases); ++i) {
13756 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13756 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13757 HttpNetworkSessionPeer peer(session.get()); 13757 HttpNetworkSessionPeer peer(session);
13758 FakeStreamFactory* fake_factory = new FakeStreamFactory(); 13758 FakeStreamFactory* fake_factory = new FakeStreamFactory();
13759 FakeWebSocketStreamCreateHelper websocket_stream_create_helper; 13759 FakeWebSocketStreamCreateHelper websocket_stream_create_helper;
13760 peer.SetHttpStreamFactoryForWebSocket( 13760 peer.SetHttpStreamFactoryForWebSocket(
13761 scoped_ptr<HttpStreamFactory>(fake_factory)); 13761 scoped_ptr<HttpStreamFactory>(fake_factory));
13762 13762
13763 HttpNetworkTransaction trans(LOW, session.get()); 13763 HttpNetworkTransaction trans(LOW, session.get());
13764 trans.SetWebSocketHandshakeStreamCreateHelper( 13764 trans.SetWebSocketHandshakeStreamCreateHelper(
13765 &websocket_stream_create_helper); 13765 &websocket_stream_create_helper);
13766 13766
13767 HttpRequestInfo request; 13767 HttpRequestInfo request;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
13828 MockRead http_reads[] = { 13828 MockRead http_reads[] = {
13829 MockRead("HTTP/1.1 200 OK\r\n"), 13829 MockRead("HTTP/1.1 200 OK\r\n"),
13830 MockRead("Content-Length: 7\r\n\r\n"), 13830 MockRead("Content-Length: 7\r\n\r\n"),
13831 MockRead("falafel"), 13831 MockRead("falafel"),
13832 MockRead(SYNCHRONOUS, OK), 13832 MockRead(SYNCHRONOUS, OK),
13833 }; 13833 };
13834 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 13834 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
13835 http_writes, arraysize(http_writes)); 13835 http_writes, arraysize(http_writes));
13836 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 13836 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
13837 13837
13838 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13838 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13839 13839
13840 // Start the SSL request. 13840 // Start the SSL request.
13841 TestCompletionCallback ssl_callback; 13841 TestCompletionCallback ssl_callback;
13842 scoped_ptr<HttpTransaction> ssl_trans( 13842 scoped_ptr<HttpTransaction> ssl_trans(
13843 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13843 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13844 ASSERT_EQ(ERR_IO_PENDING, 13844 ASSERT_EQ(ERR_IO_PENDING,
13845 ssl_trans->Start(&ssl_request, ssl_callback.callback(), 13845 ssl_trans->Start(&ssl_request, ssl_callback.callback(),
13846 BoundNetLog())); 13846 BoundNetLog()));
13847 13847
13848 // Start the HTTP request. Pool should stall. 13848 // Start the HTTP request. Pool should stall.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
13910 MockRead http_reads[] = { 13910 MockRead http_reads[] = {
13911 MockRead("HTTP/1.1 200 OK\r\n"), 13911 MockRead("HTTP/1.1 200 OK\r\n"),
13912 MockRead("Content-Length: 7\r\n\r\n"), 13912 MockRead("Content-Length: 7\r\n\r\n"),
13913 MockRead("falafel"), 13913 MockRead("falafel"),
13914 MockRead(SYNCHRONOUS, OK), 13914 MockRead(SYNCHRONOUS, OK),
13915 }; 13915 };
13916 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 13916 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
13917 http_writes, arraysize(http_writes)); 13917 http_writes, arraysize(http_writes));
13918 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 13918 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
13919 13919
13920 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13920 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13921 13921
13922 // Preconnect an SSL socket. A preconnect is needed because connect jobs are 13922 // Preconnect an SSL socket. A preconnect is needed because connect jobs are
13923 // cancelled when a normal transaction is cancelled. 13923 // cancelled when a normal transaction is cancelled.
13924 HttpStreamFactory* http_stream_factory = session->http_stream_factory(); 13924 HttpStreamFactory* http_stream_factory = session->http_stream_factory();
13925 SSLConfig ssl_config; 13925 SSLConfig ssl_config;
13926 session->ssl_config_service()->GetSSLConfig(&ssl_config); 13926 session->ssl_config_service()->GetSSLConfig(&ssl_config);
13927 http_stream_factory->PreconnectStreams(1, ssl_request, ssl_config, 13927 http_stream_factory->PreconnectStreams(1, ssl_request, ssl_config,
13928 ssl_config); 13928 ssl_config);
13929 EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session.get())); 13929 EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session.get()));
13930 13930
(...skipping 20 matching lines...) Expand all
13951 ScopedVector<UploadElementReader> element_readers; 13951 ScopedVector<UploadElementReader> element_readers;
13952 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 13952 element_readers.push_back(new UploadBytesElementReader("foo", 3));
13953 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 13953 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
13954 13954
13955 HttpRequestInfo request; 13955 HttpRequestInfo request;
13956 request.method = "POST"; 13956 request.method = "POST";
13957 request.url = GURL("http://www.foo.com/"); 13957 request.url = GURL("http://www.foo.com/");
13958 request.upload_data_stream = &upload_data_stream; 13958 request.upload_data_stream = &upload_data_stream;
13959 request.load_flags = 0; 13959 request.load_flags = 0;
13960 13960
13961 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13961 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13962 scoped_ptr<HttpTransaction> trans( 13962 scoped_ptr<HttpTransaction> trans(
13963 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13963 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13964 // Send headers successfully, but get an error while sending the body. 13964 // Send headers successfully, but get an error while sending the body.
13965 MockWrite data_writes[] = { 13965 MockWrite data_writes[] = {
13966 MockWrite("POST / HTTP/1.1\r\n" 13966 MockWrite("POST / HTTP/1.1\r\n"
13967 "Host: www.foo.com\r\n" 13967 "Host: www.foo.com\r\n"
13968 "Connection: keep-alive\r\n" 13968 "Connection: keep-alive\r\n"
13969 "Content-Length: 3\r\n\r\n"), 13969 "Content-Length: 3\r\n\r\n"),
13970 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 13970 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
13971 }; 13971 };
(...skipping 24 matching lines...) Expand all
13996 std::string response_data; 13996 std::string response_data;
13997 rv = ReadTransaction(trans.get(), &response_data); 13997 rv = ReadTransaction(trans.get(), &response_data);
13998 EXPECT_EQ(OK, rv); 13998 EXPECT_EQ(OK, rv);
13999 EXPECT_EQ("hello world", response_data); 13999 EXPECT_EQ("hello world", response_data);
14000 } 14000 }
14001 14001
14002 // This test makes sure the retry logic doesn't trigger when reading an error 14002 // This test makes sure the retry logic doesn't trigger when reading an error
14003 // response from a server that rejected a POST with a CONNECTION_RESET. 14003 // response from a server that rejected a POST with a CONNECTION_RESET.
14004 TEST_P(HttpNetworkTransactionTest, 14004 TEST_P(HttpNetworkTransactionTest,
14005 PostReadsErrorResponseAfterResetOnReusedSocket) { 14005 PostReadsErrorResponseAfterResetOnReusedSocket) {
14006 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14006 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14007 MockWrite data_writes[] = { 14007 MockWrite data_writes[] = {
14008 MockWrite("GET / HTTP/1.1\r\n" 14008 MockWrite("GET / HTTP/1.1\r\n"
14009 "Host: www.foo.com\r\n" 14009 "Host: www.foo.com\r\n"
14010 "Connection: keep-alive\r\n\r\n"), 14010 "Connection: keep-alive\r\n\r\n"),
14011 MockWrite("POST / HTTP/1.1\r\n" 14011 MockWrite("POST / HTTP/1.1\r\n"
14012 "Host: www.foo.com\r\n" 14012 "Host: www.foo.com\r\n"
14013 "Connection: keep-alive\r\n" 14013 "Connection: keep-alive\r\n"
14014 "Content-Length: 3\r\n\r\n"), 14014 "Content-Length: 3\r\n\r\n"),
14015 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14015 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
14016 }; 14016 };
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
14090 ScopedVector<UploadElementReader> element_readers; 14090 ScopedVector<UploadElementReader> element_readers;
14091 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14091 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14092 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14092 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14093 14093
14094 HttpRequestInfo request; 14094 HttpRequestInfo request;
14095 request.method = "POST"; 14095 request.method = "POST";
14096 request.url = GURL("http://www.foo.com/"); 14096 request.url = GURL("http://www.foo.com/");
14097 request.upload_data_stream = &upload_data_stream; 14097 request.upload_data_stream = &upload_data_stream;
14098 request.load_flags = 0; 14098 request.load_flags = 0;
14099 14099
14100 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14100 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14101 scoped_ptr<HttpTransaction> trans( 14101 scoped_ptr<HttpTransaction> trans(
14102 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14102 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14103 // Send headers successfully, but get an error while sending the body. 14103 // Send headers successfully, but get an error while sending the body.
14104 MockWrite data_writes[] = { 14104 MockWrite data_writes[] = {
14105 MockWrite("POST / HTTP/1.1\r\n" 14105 MockWrite("POST / HTTP/1.1\r\n"
14106 "Host: www.foo.com\r\n" 14106 "Host: www.foo.com\r\n"
14107 "Connection: keep-alive\r\n" 14107 "Connection: keep-alive\r\n"
14108 "Content-Length: 3\r\n\r\n" 14108 "Content-Length: 3\r\n\r\n"
14109 "fo"), 14109 "fo"),
14110 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14110 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
14145 ScopedVector<UploadElementReader> element_readers; 14145 ScopedVector<UploadElementReader> element_readers;
14146 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14146 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14147 ChunkedUploadDataStream upload_data_stream(0); 14147 ChunkedUploadDataStream upload_data_stream(0);
14148 14148
14149 HttpRequestInfo request; 14149 HttpRequestInfo request;
14150 request.method = "POST"; 14150 request.method = "POST";
14151 request.url = GURL("http://www.foo.com/"); 14151 request.url = GURL("http://www.foo.com/");
14152 request.upload_data_stream = &upload_data_stream; 14152 request.upload_data_stream = &upload_data_stream;
14153 request.load_flags = 0; 14153 request.load_flags = 0;
14154 14154
14155 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14155 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14156 scoped_ptr<HttpTransaction> trans( 14156 scoped_ptr<HttpTransaction> trans(
14157 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14157 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14158 // Send headers successfully, but get an error while sending the body. 14158 // Send headers successfully, but get an error while sending the body.
14159 MockWrite data_writes[] = { 14159 MockWrite data_writes[] = {
14160 MockWrite("POST / HTTP/1.1\r\n" 14160 MockWrite("POST / HTTP/1.1\r\n"
14161 "Host: www.foo.com\r\n" 14161 "Host: www.foo.com\r\n"
14162 "Connection: keep-alive\r\n" 14162 "Connection: keep-alive\r\n"
14163 "Transfer-Encoding: chunked\r\n\r\n"), 14163 "Transfer-Encoding: chunked\r\n\r\n"),
14164 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14164 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
14165 }; 14165 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
14204 ScopedVector<UploadElementReader> element_readers; 14204 ScopedVector<UploadElementReader> element_readers;
14205 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14205 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14206 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14206 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14207 14207
14208 HttpRequestInfo request; 14208 HttpRequestInfo request;
14209 request.method = "POST"; 14209 request.method = "POST";
14210 request.url = GURL("http://www.foo.com/"); 14210 request.url = GURL("http://www.foo.com/");
14211 request.upload_data_stream = &upload_data_stream; 14211 request.upload_data_stream = &upload_data_stream;
14212 request.load_flags = 0; 14212 request.load_flags = 0;
14213 14213
14214 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14214 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14215 scoped_ptr<HttpTransaction> trans( 14215 scoped_ptr<HttpTransaction> trans(
14216 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14216 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14217 14217
14218 MockWrite data_writes[] = { 14218 MockWrite data_writes[] = {
14219 MockWrite("POST / HTTP/1.1\r\n" 14219 MockWrite("POST / HTTP/1.1\r\n"
14220 "Host: www.foo.com\r\n" 14220 "Host: www.foo.com\r\n"
14221 "Connection: keep-alive\r\n" 14221 "Connection: keep-alive\r\n"
14222 "Content-Length: 3\r\n\r\n"), 14222 "Content-Length: 3\r\n\r\n"),
14223 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14223 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
14224 }; 14224 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
14257 ScopedVector<UploadElementReader> element_readers; 14257 ScopedVector<UploadElementReader> element_readers;
14258 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14258 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14259 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14259 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14260 14260
14261 HttpRequestInfo request; 14261 HttpRequestInfo request;
14262 request.method = "POST"; 14262 request.method = "POST";
14263 request.url = GURL("http://www.foo.com/"); 14263 request.url = GURL("http://www.foo.com/");
14264 request.upload_data_stream = &upload_data_stream; 14264 request.upload_data_stream = &upload_data_stream;
14265 request.load_flags = 0; 14265 request.load_flags = 0;
14266 14266
14267 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14267 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14268 scoped_ptr<HttpTransaction> trans( 14268 scoped_ptr<HttpTransaction> trans(
14269 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14269 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14270 // Send headers successfully, but get an error while sending the body. 14270 // Send headers successfully, but get an error while sending the body.
14271 MockWrite data_writes[] = { 14271 MockWrite data_writes[] = {
14272 MockWrite("POST / HTTP/1.1\r\n" 14272 MockWrite("POST / HTTP/1.1\r\n"
14273 "Host: www.foo.com\r\n" 14273 "Host: www.foo.com\r\n"
14274 "Connection: keep-alive\r\n" 14274 "Connection: keep-alive\r\n"
14275 "Content-Length: 3\r\n\r\n"), 14275 "Content-Length: 3\r\n\r\n"),
14276 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14276 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
14277 }; 14277 };
(...skipping 21 matching lines...) Expand all
14299 ScopedVector<UploadElementReader> element_readers; 14299 ScopedVector<UploadElementReader> element_readers;
14300 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14300 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14301 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14301 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14302 14302
14303 HttpRequestInfo request; 14303 HttpRequestInfo request;
14304 request.method = "POST"; 14304 request.method = "POST";
14305 request.url = GURL("http://www.foo.com/"); 14305 request.url = GURL("http://www.foo.com/");
14306 request.upload_data_stream = &upload_data_stream; 14306 request.upload_data_stream = &upload_data_stream;
14307 request.load_flags = 0; 14307 request.load_flags = 0;
14308 14308
14309 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14309 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14310 scoped_ptr<HttpTransaction> trans( 14310 scoped_ptr<HttpTransaction> trans(
14311 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14311 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14312 // Send headers successfully, but get an error while sending the body. 14312 // Send headers successfully, but get an error while sending the body.
14313 MockWrite data_writes[] = { 14313 MockWrite data_writes[] = {
14314 MockWrite("POST / HTTP/1.1\r\n" 14314 MockWrite("POST / HTTP/1.1\r\n"
14315 "Host: www.foo.com\r\n" 14315 "Host: www.foo.com\r\n"
14316 "Connection: keep-alive\r\n" 14316 "Connection: keep-alive\r\n"
14317 "Content-Length: 3\r\n\r\n"), 14317 "Content-Length: 3\r\n\r\n"),
14318 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14318 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
14319 }; 14319 };
(...skipping 22 matching lines...) Expand all
14342 ScopedVector<UploadElementReader> element_readers; 14342 ScopedVector<UploadElementReader> element_readers;
14343 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14343 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14344 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14344 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14345 14345
14346 HttpRequestInfo request; 14346 HttpRequestInfo request;
14347 request.method = "POST"; 14347 request.method = "POST";
14348 request.url = GURL("http://www.foo.com/"); 14348 request.url = GURL("http://www.foo.com/");
14349 request.upload_data_stream = &upload_data_stream; 14349 request.upload_data_stream = &upload_data_stream;
14350 request.load_flags = 0; 14350 request.load_flags = 0;
14351 14351
14352 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14352 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14353 scoped_ptr<HttpTransaction> trans( 14353 scoped_ptr<HttpTransaction> trans(
14354 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14354 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14355 // Send headers successfully, but get an error while sending the body. 14355 // Send headers successfully, but get an error while sending the body.
14356 MockWrite data_writes[] = { 14356 MockWrite data_writes[] = {
14357 MockWrite("POST / HTTP/1.1\r\n" 14357 MockWrite("POST / HTTP/1.1\r\n"
14358 "Host: www.foo.com\r\n" 14358 "Host: www.foo.com\r\n"
14359 "Connection: keep-alive\r\n" 14359 "Connection: keep-alive\r\n"
14360 "Content-Length: 3\r\n\r\n"), 14360 "Content-Length: 3\r\n\r\n"),
14361 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14361 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
14362 }; 14362 };
(...skipping 19 matching lines...) Expand all
14382 ScopedVector<UploadElementReader> element_readers; 14382 ScopedVector<UploadElementReader> element_readers;
14383 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14383 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14384 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14384 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14385 14385
14386 HttpRequestInfo request; 14386 HttpRequestInfo request;
14387 request.method = "POST"; 14387 request.method = "POST";
14388 request.url = GURL("http://www.foo.com/"); 14388 request.url = GURL("http://www.foo.com/");
14389 request.upload_data_stream = &upload_data_stream; 14389 request.upload_data_stream = &upload_data_stream;
14390 request.load_flags = 0; 14390 request.load_flags = 0;
14391 14391
14392 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14392 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14393 scoped_ptr<HttpTransaction> trans( 14393 scoped_ptr<HttpTransaction> trans(
14394 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14394 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14395 // Send headers successfully, but get an error while sending the body. 14395 // Send headers successfully, but get an error while sending the body.
14396 MockWrite data_writes[] = { 14396 MockWrite data_writes[] = {
14397 MockWrite("POST / HTTP/1.1\r\n" 14397 MockWrite("POST / HTTP/1.1\r\n"
14398 "Host: www.foo.com\r\n" 14398 "Host: www.foo.com\r\n"
14399 "Connection: keep-alive\r\n" 14399 "Connection: keep-alive\r\n"
14400 "Content-Length: 3\r\n\r\n"), 14400 "Content-Length: 3\r\n\r\n"),
14401 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET), 14401 MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
14402 }; 14402 };
(...skipping 20 matching lines...) Expand all
14423 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWssTunnel) { 14423 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWssTunnel) {
14424 HttpRequestInfo request; 14424 HttpRequestInfo request;
14425 request.method = "GET"; 14425 request.method = "GET";
14426 request.url = GURL("wss://www.example.org/"); 14426 request.url = GURL("wss://www.example.org/");
14427 AddWebSocketHeaders(&request.extra_headers); 14427 AddWebSocketHeaders(&request.extra_headers);
14428 14428
14429 // Configure against proxy server "myproxy:70". 14429 // Configure against proxy server "myproxy:70".
14430 session_deps_.proxy_service.reset( 14430 session_deps_.proxy_service.reset(
14431 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 14431 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
14432 14432
14433 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14433 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14434 14434
14435 // Since a proxy is configured, try to establish a tunnel. 14435 // Since a proxy is configured, try to establish a tunnel.
14436 MockWrite data_writes[] = { 14436 MockWrite data_writes[] = {
14437 MockWrite( 14437 MockWrite(
14438 "CONNECT www.example.org:443 HTTP/1.1\r\n" 14438 "CONNECT www.example.org:443 HTTP/1.1\r\n"
14439 "Host: www.example.org\r\n" 14439 "Host: www.example.org\r\n"
14440 "Proxy-Connection: keep-alive\r\n\r\n"), 14440 "Proxy-Connection: keep-alive\r\n\r\n"),
14441 14441
14442 // After calling trans->RestartWithAuth(), this is the request we should 14442 // After calling trans->RestartWithAuth(), this is the request we should
14443 // be issuing -- the final header line contains the credentials. 14443 // be issuing -- the final header line contains the credentials.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
14530 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWsTunnel) { 14530 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWsTunnel) {
14531 HttpRequestInfo request; 14531 HttpRequestInfo request;
14532 request.method = "GET"; 14532 request.method = "GET";
14533 request.url = GURL("ws://www.example.org/"); 14533 request.url = GURL("ws://www.example.org/");
14534 AddWebSocketHeaders(&request.extra_headers); 14534 AddWebSocketHeaders(&request.extra_headers);
14535 14535
14536 // Configure against proxy server "myproxy:70". 14536 // Configure against proxy server "myproxy:70".
14537 session_deps_.proxy_service.reset( 14537 session_deps_.proxy_service.reset(
14538 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 14538 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
14539 14539
14540 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14540 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14541 14541
14542 MockWrite data_writes[] = { 14542 MockWrite data_writes[] = {
14543 // Try to establish a tunnel for the WebSocket connection, with 14543 // Try to establish a tunnel for the WebSocket connection, with
14544 // credentials. Because WebSockets have a separate set of socket pools, 14544 // credentials. Because WebSockets have a separate set of socket pools,
14545 // they cannot and will not use the same TCP/IP connection as the 14545 // they cannot and will not use the same TCP/IP connection as the
14546 // preflight HTTP request. 14546 // preflight HTTP request.
14547 MockWrite( 14547 MockWrite(
14548 "CONNECT www.example.org:80 HTTP/1.1\r\n" 14548 "CONNECT www.example.org:80 HTTP/1.1\r\n"
14549 "Host: www.example.org:80\r\n" 14549 "Host: www.example.org:80\r\n"
14550 "Proxy-Connection: keep-alive\r\n" 14550 "Proxy-Connection: keep-alive\r\n"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
14606 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesPost) { 14606 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesPost) {
14607 ScopedVector<UploadElementReader> element_readers; 14607 ScopedVector<UploadElementReader> element_readers;
14608 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14608 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14609 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14609 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14610 14610
14611 HttpRequestInfo request; 14611 HttpRequestInfo request;
14612 request.method = "POST"; 14612 request.method = "POST";
14613 request.url = GURL("http://www.foo.com/"); 14613 request.url = GURL("http://www.foo.com/");
14614 request.upload_data_stream = &upload_data_stream; 14614 request.upload_data_stream = &upload_data_stream;
14615 14615
14616 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14616 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14617 scoped_ptr<HttpTransaction> trans( 14617 scoped_ptr<HttpTransaction> trans(
14618 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14618 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14619 MockWrite data_writes[] = { 14619 MockWrite data_writes[] = {
14620 MockWrite("POST / HTTP/1.1\r\n" 14620 MockWrite("POST / HTTP/1.1\r\n"
14621 "Host: www.foo.com\r\n" 14621 "Host: www.foo.com\r\n"
14622 "Connection: keep-alive\r\n" 14622 "Connection: keep-alive\r\n"
14623 "Content-Length: 3\r\n\r\n"), 14623 "Content-Length: 3\r\n\r\n"),
14624 MockWrite("foo"), 14624 MockWrite("foo"),
14625 }; 14625 };
14626 14626
(...skipping 23 matching lines...) Expand all
14650 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesPost100Continue) { 14650 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesPost100Continue) {
14651 ScopedVector<UploadElementReader> element_readers; 14651 ScopedVector<UploadElementReader> element_readers;
14652 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14652 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14653 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 14653 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
14654 14654
14655 HttpRequestInfo request; 14655 HttpRequestInfo request;
14656 request.method = "POST"; 14656 request.method = "POST";
14657 request.url = GURL("http://www.foo.com/"); 14657 request.url = GURL("http://www.foo.com/");
14658 request.upload_data_stream = &upload_data_stream; 14658 request.upload_data_stream = &upload_data_stream;
14659 14659
14660 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14660 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14661 scoped_ptr<HttpTransaction> trans( 14661 scoped_ptr<HttpTransaction> trans(
14662 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14662 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14663 MockWrite data_writes[] = { 14663 MockWrite data_writes[] = {
14664 MockWrite("POST / HTTP/1.1\r\n" 14664 MockWrite("POST / HTTP/1.1\r\n"
14665 "Host: www.foo.com\r\n" 14665 "Host: www.foo.com\r\n"
14666 "Connection: keep-alive\r\n" 14666 "Connection: keep-alive\r\n"
14667 "Content-Length: 3\r\n\r\n"), 14667 "Content-Length: 3\r\n\r\n"),
14668 MockWrite("foo"), 14668 MockWrite("foo"),
14669 }; 14669 };
14670 14670
(...skipping 24 matching lines...) Expand all
14695 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesChunkedPost) { 14695 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesChunkedPost) {
14696 ScopedVector<UploadElementReader> element_readers; 14696 ScopedVector<UploadElementReader> element_readers;
14697 element_readers.push_back(new UploadBytesElementReader("foo", 3)); 14697 element_readers.push_back(new UploadBytesElementReader("foo", 3));
14698 ChunkedUploadDataStream upload_data_stream(0); 14698 ChunkedUploadDataStream upload_data_stream(0);
14699 14699
14700 HttpRequestInfo request; 14700 HttpRequestInfo request;
14701 request.method = "POST"; 14701 request.method = "POST";
14702 request.url = GURL("http://www.foo.com/"); 14702 request.url = GURL("http://www.foo.com/");
14703 request.upload_data_stream = &upload_data_stream; 14703 request.upload_data_stream = &upload_data_stream;
14704 14704
14705 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14705 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14706 scoped_ptr<HttpTransaction> trans( 14706 scoped_ptr<HttpTransaction> trans(
14707 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 14707 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
14708 // Send headers successfully, but get an error while sending the body. 14708 // Send headers successfully, but get an error while sending the body.
14709 MockWrite data_writes[] = { 14709 MockWrite data_writes[] = {
14710 MockWrite("POST / HTTP/1.1\r\n" 14710 MockWrite("POST / HTTP/1.1\r\n"
14711 "Host: www.foo.com\r\n" 14711 "Host: www.foo.com\r\n"
14712 "Connection: keep-alive\r\n" 14712 "Connection: keep-alive\r\n"
14713 "Transfer-Encoding: chunked\r\n\r\n"), 14713 "Transfer-Encoding: chunked\r\n\r\n"),
14714 MockWrite("1\r\nf\r\n"), MockWrite("2\r\noo\r\n"), MockWrite("0\r\n\r\n"), 14714 MockWrite("1\r\nf\r\n"), MockWrite("2\r\noo\r\n"), MockWrite("0\r\n\r\n"),
14715 }; 14715 };
(...skipping 22 matching lines...) Expand all
14738 std::string response_data; 14738 std::string response_data;
14739 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 14739 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data));
14740 14740
14741 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), 14741 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)),
14742 trans->GetTotalSentBytes()); 14742 trans->GetTotalSentBytes());
14743 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), 14743 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)),
14744 trans->GetTotalReceivedBytes()); 14744 trans->GetTotalReceivedBytes());
14745 } 14745 }
14746 14746
14747 } // namespace net 14747 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_ssl_unittest.cc ('k') | net/http/http_proxy_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698