OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // successfully established before the error. | 319 // successfully established before the error. |
320 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); | 320 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); |
321 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 321 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
322 | 322 |
323 if (out.rv != OK) | 323 if (out.rv != OK) |
324 return out; | 324 return out; |
325 | 325 |
326 const HttpResponseInfo* response = trans->GetResponseInfo(); | 326 const HttpResponseInfo* response = trans->GetResponseInfo(); |
327 // Can't use ASSERT_* inside helper functions like this, so | 327 // Can't use ASSERT_* inside helper functions like this, so |
328 // return an error. | 328 // return an error. |
329 if (response == NULL || response->headers == NULL) { | 329 if (response == NULL || response->headers.get() == NULL) { |
330 out.rv = ERR_UNEXPECTED; | 330 out.rv = ERR_UNEXPECTED; |
331 return out; | 331 return out; |
332 } | 332 } |
333 out.status_line = response->headers->GetStatusLine(); | 333 out.status_line = response->headers->GetStatusLine(); |
334 | 334 |
335 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 335 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
336 EXPECT_EQ(80, response->socket_address.port()); | 336 EXPECT_EQ(80, response->socket_address.port()); |
337 | 337 |
338 rv = ReadTransaction(trans.get(), &out.response_data); | 338 rv = ReadTransaction(trans.get(), &out.response_data); |
339 EXPECT_EQ(OK, rv); | 339 EXPECT_EQ(OK, rv); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 session_deps_.socket_factory->AddSocketDataProvider(&data); | 867 session_deps_.socket_factory->AddSocketDataProvider(&data); |
868 | 868 |
869 TestCompletionCallback callback; | 869 TestCompletionCallback callback; |
870 | 870 |
871 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 871 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
872 EXPECT_EQ(ERR_IO_PENDING, rv); | 872 EXPECT_EQ(ERR_IO_PENDING, rv); |
873 | 873 |
874 EXPECT_EQ(OK, callback.WaitForResult()); | 874 EXPECT_EQ(OK, callback.WaitForResult()); |
875 | 875 |
876 const HttpResponseInfo* response = trans->GetResponseInfo(); | 876 const HttpResponseInfo* response = trans->GetResponseInfo(); |
877 ASSERT_TRUE(response != NULL && response->headers != NULL); | 877 ASSERT_TRUE(response != NULL && response->headers.get() != NULL); |
878 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); | 878 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); |
879 std::string url; | 879 std::string url; |
880 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 880 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
881 EXPECT_EQ("http://good.com/", url); | 881 EXPECT_EQ("http://good.com/", url); |
882 } | 882 } |
883 | 883 |
884 // Checks that two distinct Location headers result in an error. | 884 // Checks that two distinct Location headers result in an error. |
885 TEST_F(HttpNetworkTransactionSpdy3Test, TwoDistinctLocationHeaders) { | 885 TEST_F(HttpNetworkTransactionSpdy3Test, TwoDistinctLocationHeaders) { |
886 MockRead data_reads[] = { | 886 MockRead data_reads[] = { |
887 MockRead("HTTP/1.1 302 Redirect\r\n"), | 887 MockRead("HTTP/1.1 302 Redirect\r\n"), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 931 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
932 EXPECT_EQ(ERR_IO_PENDING, rv); | 932 EXPECT_EQ(ERR_IO_PENDING, rv); |
933 | 933 |
934 rv = callback1.WaitForResult(); | 934 rv = callback1.WaitForResult(); |
935 EXPECT_EQ(OK, rv); | 935 EXPECT_EQ(OK, rv); |
936 | 936 |
937 const HttpResponseInfo* response = trans->GetResponseInfo(); | 937 const HttpResponseInfo* response = trans->GetResponseInfo(); |
938 ASSERT_TRUE(response != NULL); | 938 ASSERT_TRUE(response != NULL); |
939 | 939 |
940 // Check that the headers got parsed. | 940 // Check that the headers got parsed. |
941 EXPECT_TRUE(response->headers != NULL); | 941 EXPECT_TRUE(response->headers.get() != NULL); |
942 EXPECT_EQ(1234, response->headers->GetContentLength()); | 942 EXPECT_EQ(1234, response->headers->GetContentLength()); |
943 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); | 943 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); |
944 | 944 |
945 std::string server_header; | 945 std::string server_header; |
946 void* iter = NULL; | 946 void* iter = NULL; |
947 bool has_server_header = response->headers->EnumerateHeader( | 947 bool has_server_header = response->headers->EnumerateHeader( |
948 &iter, "Server", &server_header); | 948 &iter, "Server", &server_header); |
949 EXPECT_TRUE(has_server_header); | 949 EXPECT_TRUE(has_server_header); |
950 EXPECT_EQ("Blah", server_header); | 950 EXPECT_EQ("Blah", server_header); |
951 | 951 |
(...skipping 22 matching lines...) Expand all Loading... |
974 "hello", "world" | 974 "hello", "world" |
975 }; | 975 }; |
976 | 976 |
977 for (int i = 0; i < 2; ++i) { | 977 for (int i = 0; i < 2; ++i) { |
978 HttpRequestInfo request; | 978 HttpRequestInfo request; |
979 request.method = "GET"; | 979 request.method = "GET"; |
980 request.url = GURL("http://www.google.com/"); | 980 request.url = GURL("http://www.google.com/"); |
981 request.load_flags = 0; | 981 request.load_flags = 0; |
982 | 982 |
983 scoped_ptr<HttpTransaction> trans( | 983 scoped_ptr<HttpTransaction> trans( |
984 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 984 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
985 | 985 |
986 TestCompletionCallback callback; | 986 TestCompletionCallback callback; |
987 | 987 |
988 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 988 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
989 EXPECT_EQ(ERR_IO_PENDING, rv); | 989 EXPECT_EQ(ERR_IO_PENDING, rv); |
990 | 990 |
991 rv = callback.WaitForResult(); | 991 rv = callback.WaitForResult(); |
992 EXPECT_EQ(OK, rv); | 992 EXPECT_EQ(OK, rv); |
993 | 993 |
994 const HttpResponseInfo* response = trans->GetResponseInfo(); | 994 const HttpResponseInfo* response = trans->GetResponseInfo(); |
995 ASSERT_TRUE(response != NULL); | 995 ASSERT_TRUE(response != NULL); |
996 | 996 |
997 EXPECT_TRUE(response->headers != NULL); | 997 EXPECT_TRUE(response->headers.get() != NULL); |
998 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 998 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
999 | 999 |
1000 std::string response_data; | 1000 std::string response_data; |
1001 rv = ReadTransaction(trans.get(), &response_data); | 1001 rv = ReadTransaction(trans.get(), &response_data); |
1002 EXPECT_EQ(OK, rv); | 1002 EXPECT_EQ(OK, rv); |
1003 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1003 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1004 } | 1004 } |
1005 } | 1005 } |
1006 | 1006 |
1007 TEST_F(HttpNetworkTransactionSpdy3Test, Ignores100) { | 1007 TEST_F(HttpNetworkTransactionSpdy3Test, Ignores100) { |
(...skipping 24 matching lines...) Expand all Loading... |
1032 | 1032 |
1033 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1033 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1034 EXPECT_EQ(ERR_IO_PENDING, rv); | 1034 EXPECT_EQ(ERR_IO_PENDING, rv); |
1035 | 1035 |
1036 rv = callback.WaitForResult(); | 1036 rv = callback.WaitForResult(); |
1037 EXPECT_EQ(OK, rv); | 1037 EXPECT_EQ(OK, rv); |
1038 | 1038 |
1039 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1039 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1040 ASSERT_TRUE(response != NULL); | 1040 ASSERT_TRUE(response != NULL); |
1041 | 1041 |
1042 EXPECT_TRUE(response->headers != NULL); | 1042 EXPECT_TRUE(response->headers.get() != NULL); |
1043 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 1043 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
1044 | 1044 |
1045 std::string response_data; | 1045 std::string response_data; |
1046 rv = ReadTransaction(trans.get(), &response_data); | 1046 rv = ReadTransaction(trans.get(), &response_data); |
1047 EXPECT_EQ(OK, rv); | 1047 EXPECT_EQ(OK, rv); |
1048 EXPECT_EQ("hello world", response_data); | 1048 EXPECT_EQ("hello world", response_data); |
1049 } | 1049 } |
1050 | 1050 |
1051 // This test is almost the same as Ignores100 above, but the response contains | 1051 // This test is almost the same as Ignores100 above, but the response contains |
1052 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is | 1052 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is |
(...skipping 21 matching lines...) Expand all Loading... |
1074 | 1074 |
1075 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1075 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1076 EXPECT_EQ(ERR_IO_PENDING, rv); | 1076 EXPECT_EQ(ERR_IO_PENDING, rv); |
1077 | 1077 |
1078 rv = callback.WaitForResult(); | 1078 rv = callback.WaitForResult(); |
1079 EXPECT_EQ(OK, rv); | 1079 EXPECT_EQ(OK, rv); |
1080 | 1080 |
1081 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1081 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1082 ASSERT_TRUE(response != NULL); | 1082 ASSERT_TRUE(response != NULL); |
1083 | 1083 |
1084 EXPECT_TRUE(response->headers != NULL); | 1084 EXPECT_TRUE(response->headers.get() != NULL); |
1085 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1085 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1086 | 1086 |
1087 std::string response_data; | 1087 std::string response_data; |
1088 rv = ReadTransaction(trans.get(), &response_data); | 1088 rv = ReadTransaction(trans.get(), &response_data); |
1089 EXPECT_EQ(OK, rv); | 1089 EXPECT_EQ(OK, rv); |
1090 EXPECT_EQ("hello world", response_data); | 1090 EXPECT_EQ("hello world", response_data); |
1091 } | 1091 } |
1092 | 1092 |
1093 TEST_F(HttpNetworkTransactionSpdy3Test, Incomplete100ThenEOF) { | 1093 TEST_F(HttpNetworkTransactionSpdy3Test, Incomplete100ThenEOF) { |
1094 HttpRequestInfo request; | 1094 HttpRequestInfo request; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 | 1197 |
1198 const char* kExpectedResponseData[] = { | 1198 const char* kExpectedResponseData[] = { |
1199 "hello", "world" | 1199 "hello", "world" |
1200 }; | 1200 }; |
1201 | 1201 |
1202 uint32 first_socket_log_id = NetLog::Source::kInvalidId; | 1202 uint32 first_socket_log_id = NetLog::Source::kInvalidId; |
1203 for (int i = 0; i < 2; ++i) { | 1203 for (int i = 0; i < 2; ++i) { |
1204 TestCompletionCallback callback; | 1204 TestCompletionCallback callback; |
1205 | 1205 |
1206 scoped_ptr<HttpTransaction> trans( | 1206 scoped_ptr<HttpTransaction> trans( |
1207 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1207 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1208 | 1208 |
1209 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1209 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1210 EXPECT_EQ(ERR_IO_PENDING, rv); | 1210 EXPECT_EQ(ERR_IO_PENDING, rv); |
1211 | 1211 |
1212 rv = callback.WaitForResult(); | 1212 rv = callback.WaitForResult(); |
1213 EXPECT_EQ(OK, rv); | 1213 EXPECT_EQ(OK, rv); |
1214 | 1214 |
1215 LoadTimingInfo load_timing_info; | 1215 LoadTimingInfo load_timing_info; |
1216 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 1216 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
1217 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 1217 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
1218 if (i == 0) { | 1218 if (i == 0) { |
1219 first_socket_log_id = load_timing_info.socket_log_id; | 1219 first_socket_log_id = load_timing_info.socket_log_id; |
1220 } else { | 1220 } else { |
1221 // The second request should be using a new socket. | 1221 // The second request should be using a new socket. |
1222 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); | 1222 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); |
1223 } | 1223 } |
1224 | 1224 |
1225 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1225 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1226 ASSERT_TRUE(response != NULL); | 1226 ASSERT_TRUE(response != NULL); |
1227 | 1227 |
1228 EXPECT_TRUE(response->headers != NULL); | 1228 EXPECT_TRUE(response->headers.get() != NULL); |
1229 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1229 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1230 | 1230 |
1231 std::string response_data; | 1231 std::string response_data; |
1232 rv = ReadTransaction(trans.get(), &response_data); | 1232 rv = ReadTransaction(trans.get(), &response_data); |
1233 EXPECT_EQ(OK, rv); | 1233 EXPECT_EQ(OK, rv); |
1234 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1234 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1235 } | 1235 } |
1236 } | 1236 } |
1237 | 1237 |
1238 TEST_F(HttpNetworkTransactionSpdy3Test, | 1238 TEST_F(HttpNetworkTransactionSpdy3Test, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 // destructor in such situations. | 1308 // destructor in such situations. |
1309 // See http://crbug.com/154712 and http://crbug.com/156609. | 1309 // See http://crbug.com/154712 and http://crbug.com/156609. |
1310 TEST_F(HttpNetworkTransactionSpdy3Test, KeepAliveEarlyClose) { | 1310 TEST_F(HttpNetworkTransactionSpdy3Test, KeepAliveEarlyClose) { |
1311 HttpRequestInfo request; | 1311 HttpRequestInfo request; |
1312 request.method = "GET"; | 1312 request.method = "GET"; |
1313 request.url = GURL("http://www.google.com/"); | 1313 request.url = GURL("http://www.google.com/"); |
1314 request.load_flags = 0; | 1314 request.load_flags = 0; |
1315 | 1315 |
1316 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 1316 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
1317 scoped_ptr<HttpTransaction> trans( | 1317 scoped_ptr<HttpTransaction> trans( |
1318 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1318 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1319 | 1319 |
1320 MockRead data_reads[] = { | 1320 MockRead data_reads[] = { |
1321 MockRead("HTTP/1.0 200 OK\r\n"), | 1321 MockRead("HTTP/1.0 200 OK\r\n"), |
1322 MockRead("Connection: keep-alive\r\n"), | 1322 MockRead("Connection: keep-alive\r\n"), |
1323 MockRead("Content-Length: 100\r\n\r\n"), | 1323 MockRead("Content-Length: 100\r\n\r\n"), |
1324 MockRead("hello"), | 1324 MockRead("hello"), |
1325 MockRead(SYNCHRONOUS, 0), | 1325 MockRead(SYNCHRONOUS, 0), |
1326 }; | 1326 }; |
1327 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1327 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
1328 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1328 session_deps_.socket_factory->AddSocketDataProvider(&data); |
1329 | 1329 |
1330 TestCompletionCallback callback; | 1330 TestCompletionCallback callback; |
1331 | 1331 |
1332 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1332 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1333 EXPECT_EQ(ERR_IO_PENDING, rv); | 1333 EXPECT_EQ(ERR_IO_PENDING, rv); |
1334 | 1334 |
1335 rv = callback.WaitForResult(); | 1335 rv = callback.WaitForResult(); |
1336 EXPECT_EQ(OK, rv); | 1336 EXPECT_EQ(OK, rv); |
1337 | 1337 |
1338 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1338 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
1339 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1339 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1340 if (rv == ERR_IO_PENDING) | 1340 if (rv == ERR_IO_PENDING) |
1341 rv = callback.WaitForResult(); | 1341 rv = callback.WaitForResult(); |
1342 EXPECT_EQ(5, rv); | 1342 EXPECT_EQ(5, rv); |
1343 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1343 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1344 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1344 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
1345 | 1345 |
1346 trans.reset(); | 1346 trans.reset(); |
1347 base::MessageLoop::current()->RunUntilIdle(); | 1347 base::MessageLoop::current()->RunUntilIdle(); |
1348 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1348 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
1349 } | 1349 } |
1350 | 1350 |
1351 TEST_F(HttpNetworkTransactionSpdy3Test, KeepAliveEarlyClose2) { | 1351 TEST_F(HttpNetworkTransactionSpdy3Test, KeepAliveEarlyClose2) { |
1352 HttpRequestInfo request; | 1352 HttpRequestInfo request; |
1353 request.method = "GET"; | 1353 request.method = "GET"; |
1354 request.url = GURL("http://www.google.com/"); | 1354 request.url = GURL("http://www.google.com/"); |
1355 request.load_flags = 0; | 1355 request.load_flags = 0; |
1356 | 1356 |
1357 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 1357 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
1358 scoped_ptr<HttpTransaction> trans( | 1358 scoped_ptr<HttpTransaction> trans( |
1359 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1359 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1360 | 1360 |
1361 MockRead data_reads[] = { | 1361 MockRead data_reads[] = { |
1362 MockRead("HTTP/1.0 200 OK\r\n"), | 1362 MockRead("HTTP/1.0 200 OK\r\n"), |
1363 MockRead("Connection: keep-alive\r\n"), | 1363 MockRead("Connection: keep-alive\r\n"), |
1364 MockRead("Content-Length: 100\r\n\r\n"), | 1364 MockRead("Content-Length: 100\r\n\r\n"), |
1365 MockRead(SYNCHRONOUS, 0), | 1365 MockRead(SYNCHRONOUS, 0), |
1366 }; | 1366 }; |
1367 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1367 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
1368 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1368 session_deps_.socket_factory->AddSocketDataProvider(&data); |
1369 | 1369 |
1370 TestCompletionCallback callback; | 1370 TestCompletionCallback callback; |
1371 | 1371 |
1372 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1372 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1373 EXPECT_EQ(ERR_IO_PENDING, rv); | 1373 EXPECT_EQ(ERR_IO_PENDING, rv); |
1374 | 1374 |
1375 rv = callback.WaitForResult(); | 1375 rv = callback.WaitForResult(); |
1376 EXPECT_EQ(OK, rv); | 1376 EXPECT_EQ(OK, rv); |
1377 | 1377 |
1378 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1378 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
1379 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1379 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1380 if (rv == ERR_IO_PENDING) | 1380 if (rv == ERR_IO_PENDING) |
1381 rv = callback.WaitForResult(); | 1381 rv = callback.WaitForResult(); |
1382 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1382 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
1383 | 1383 |
1384 trans.reset(); | 1384 trans.reset(); |
1385 base::MessageLoop::current()->RunUntilIdle(); | 1385 base::MessageLoop::current()->RunUntilIdle(); |
1386 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1386 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
1387 } | 1387 } |
1388 | 1388 |
1389 // Test that we correctly reuse a keep-alive connection after not explicitly | 1389 // Test that we correctly reuse a keep-alive connection after not explicitly |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1428 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1429 | 1429 |
1430 const int kNumUnreadBodies = arraysize(data1_reads) - 2; | 1430 const int kNumUnreadBodies = arraysize(data1_reads) - 2; |
1431 std::string response_lines[kNumUnreadBodies]; | 1431 std::string response_lines[kNumUnreadBodies]; |
1432 | 1432 |
1433 uint32 first_socket_log_id = NetLog::Source::kInvalidId; | 1433 uint32 first_socket_log_id = NetLog::Source::kInvalidId; |
1434 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { | 1434 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { |
1435 TestCompletionCallback callback; | 1435 TestCompletionCallback callback; |
1436 | 1436 |
1437 scoped_ptr<HttpTransaction> trans( | 1437 scoped_ptr<HttpTransaction> trans( |
1438 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1438 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1439 | 1439 |
1440 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1440 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1441 EXPECT_EQ(ERR_IO_PENDING, rv); | 1441 EXPECT_EQ(ERR_IO_PENDING, rv); |
1442 | 1442 |
1443 rv = callback.WaitForResult(); | 1443 rv = callback.WaitForResult(); |
1444 EXPECT_EQ(OK, rv); | 1444 EXPECT_EQ(OK, rv); |
1445 | 1445 |
1446 LoadTimingInfo load_timing_info; | 1446 LoadTimingInfo load_timing_info; |
1447 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 1447 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
1448 if (i == 0) { | 1448 if (i == 0) { |
1449 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 1449 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
1450 first_socket_log_id = load_timing_info.socket_log_id; | 1450 first_socket_log_id = load_timing_info.socket_log_id; |
1451 } else { | 1451 } else { |
1452 TestLoadTimingReused(load_timing_info); | 1452 TestLoadTimingReused(load_timing_info); |
1453 EXPECT_EQ(first_socket_log_id, load_timing_info.socket_log_id); | 1453 EXPECT_EQ(first_socket_log_id, load_timing_info.socket_log_id); |
1454 } | 1454 } |
1455 | 1455 |
1456 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1456 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1457 ASSERT_TRUE(response != NULL); | 1457 ASSERT_TRUE(response != NULL); |
1458 | 1458 |
1459 ASSERT_TRUE(response->headers != NULL); | 1459 ASSERT_TRUE(response->headers.get() != NULL); |
1460 response_lines[i] = response->headers->GetStatusLine(); | 1460 response_lines[i] = response->headers->GetStatusLine(); |
1461 | 1461 |
1462 // We intentionally don't read the response bodies. | 1462 // We intentionally don't read the response bodies. |
1463 } | 1463 } |
1464 | 1464 |
1465 const char* const kStatusLines[] = { | 1465 const char* const kStatusLines[] = { |
1466 "HTTP/1.1 204 No Content", | 1466 "HTTP/1.1 204 No Content", |
1467 "HTTP/1.1 205 Reset Content", | 1467 "HTTP/1.1 205 Reset Content", |
1468 "HTTP/1.1 304 Not Modified", | 1468 "HTTP/1.1 304 Not Modified", |
1469 "HTTP/1.1 302 Found", | 1469 "HTTP/1.1 302 Found", |
1470 "HTTP/1.1 302 Found", | 1470 "HTTP/1.1 302 Found", |
1471 "HTTP/1.1 301 Moved Permanently", | 1471 "HTTP/1.1 301 Moved Permanently", |
1472 "HTTP/1.1 301 Moved Permanently", | 1472 "HTTP/1.1 301 Moved Permanently", |
1473 }; | 1473 }; |
1474 | 1474 |
1475 COMPILE_ASSERT(kNumUnreadBodies == arraysize(kStatusLines), | 1475 COMPILE_ASSERT(kNumUnreadBodies == arraysize(kStatusLines), |
1476 forgot_to_update_kStatusLines); | 1476 forgot_to_update_kStatusLines); |
1477 | 1477 |
1478 for (int i = 0; i < kNumUnreadBodies; ++i) | 1478 for (int i = 0; i < kNumUnreadBodies; ++i) |
1479 EXPECT_EQ(kStatusLines[i], response_lines[i]); | 1479 EXPECT_EQ(kStatusLines[i], response_lines[i]); |
1480 | 1480 |
1481 TestCompletionCallback callback; | 1481 TestCompletionCallback callback; |
1482 scoped_ptr<HttpTransaction> trans( | 1482 scoped_ptr<HttpTransaction> trans( |
1483 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1483 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1484 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1484 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1485 EXPECT_EQ(ERR_IO_PENDING, rv); | 1485 EXPECT_EQ(ERR_IO_PENDING, rv); |
1486 rv = callback.WaitForResult(); | 1486 rv = callback.WaitForResult(); |
1487 EXPECT_EQ(OK, rv); | 1487 EXPECT_EQ(OK, rv); |
1488 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1488 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1489 ASSERT_TRUE(response != NULL); | 1489 ASSERT_TRUE(response != NULL); |
1490 ASSERT_TRUE(response->headers != NULL); | 1490 ASSERT_TRUE(response->headers.get() != NULL); |
1491 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1491 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1492 std::string response_data; | 1492 std::string response_data; |
1493 rv = ReadTransaction(trans.get(), &response_data); | 1493 rv = ReadTransaction(trans.get(), &response_data); |
1494 EXPECT_EQ(OK, rv); | 1494 EXPECT_EQ(OK, rv); |
1495 EXPECT_EQ("hello", response_data); | 1495 EXPECT_EQ("hello", response_data); |
1496 } | 1496 } |
1497 | 1497 |
1498 // Test the request-challenge-retry sequence for basic auth. | 1498 // Test the request-challenge-retry sequence for basic auth. |
1499 // (basic auth is the easiest to mock, because it has no randomness). | 1499 // (basic auth is the easiest to mock, because it has no randomness). |
1500 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuth) { | 1500 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuth) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1681 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1682 data_writes1, arraysize(data_writes1)); | 1682 data_writes1, arraysize(data_writes1)); |
1683 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1683 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1684 NULL, 0); | 1684 NULL, 0); |
1685 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1685 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1686 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1686 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1687 | 1687 |
1688 TestCompletionCallback callback1; | 1688 TestCompletionCallback callback1; |
1689 | 1689 |
1690 scoped_ptr<HttpTransaction> trans( | 1690 scoped_ptr<HttpTransaction> trans( |
1691 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1691 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1692 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1692 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1693 EXPECT_EQ(ERR_IO_PENDING, rv); | 1693 EXPECT_EQ(ERR_IO_PENDING, rv); |
1694 | 1694 |
1695 rv = callback1.WaitForResult(); | 1695 rv = callback1.WaitForResult(); |
1696 EXPECT_EQ(OK, rv); | 1696 EXPECT_EQ(OK, rv); |
1697 | 1697 |
1698 LoadTimingInfo load_timing_info1; | 1698 LoadTimingInfo load_timing_info1; |
1699 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info1)); | 1699 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info1)); |
1700 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_DNS_TIMES); | 1700 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_DNS_TIMES); |
1701 | 1701 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1770 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1771 data_writes1, arraysize(data_writes1)); | 1771 data_writes1, arraysize(data_writes1)); |
1772 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1772 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1773 NULL, 0); | 1773 NULL, 0); |
1774 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1774 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1775 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1775 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1776 | 1776 |
1777 TestCompletionCallback callback1; | 1777 TestCompletionCallback callback1; |
1778 | 1778 |
1779 scoped_ptr<HttpTransaction> trans( | 1779 scoped_ptr<HttpTransaction> trans( |
1780 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1780 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1781 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1781 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1782 EXPECT_EQ(ERR_IO_PENDING, rv); | 1782 EXPECT_EQ(ERR_IO_PENDING, rv); |
1783 | 1783 |
1784 rv = callback1.WaitForResult(); | 1784 rv = callback1.WaitForResult(); |
1785 EXPECT_EQ(OK, rv); | 1785 EXPECT_EQ(OK, rv); |
1786 | 1786 |
1787 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1787 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1788 ASSERT_TRUE(response != NULL); | 1788 ASSERT_TRUE(response != NULL); |
1789 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1789 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1790 | 1790 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1854 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1855 data_writes1, arraysize(data_writes1)); | 1855 data_writes1, arraysize(data_writes1)); |
1856 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1856 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1857 NULL, 0); | 1857 NULL, 0); |
1858 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1858 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1859 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1859 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1860 | 1860 |
1861 TestCompletionCallback callback1; | 1861 TestCompletionCallback callback1; |
1862 | 1862 |
1863 scoped_ptr<HttpTransaction> trans( | 1863 scoped_ptr<HttpTransaction> trans( |
1864 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1864 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1865 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1865 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1866 EXPECT_EQ(ERR_IO_PENDING, rv); | 1866 EXPECT_EQ(ERR_IO_PENDING, rv); |
1867 | 1867 |
1868 rv = callback1.WaitForResult(); | 1868 rv = callback1.WaitForResult(); |
1869 EXPECT_EQ(OK, rv); | 1869 EXPECT_EQ(OK, rv); |
1870 | 1870 |
1871 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1871 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1872 ASSERT_TRUE(response != NULL); | 1872 ASSERT_TRUE(response != NULL); |
1873 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1873 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1874 | 1874 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1940 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1941 data_writes1, arraysize(data_writes1)); | 1941 data_writes1, arraysize(data_writes1)); |
1942 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1942 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1943 data_writes2, arraysize(data_writes2)); | 1943 data_writes2, arraysize(data_writes2)); |
1944 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1944 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1945 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1945 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1946 | 1946 |
1947 TestCompletionCallback callback1; | 1947 TestCompletionCallback callback1; |
1948 | 1948 |
1949 scoped_ptr<HttpTransaction> trans( | 1949 scoped_ptr<HttpTransaction> trans( |
1950 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1950 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1951 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1951 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1952 EXPECT_EQ(ERR_IO_PENDING, rv); | 1952 EXPECT_EQ(ERR_IO_PENDING, rv); |
1953 | 1953 |
1954 rv = callback1.WaitForResult(); | 1954 rv = callback1.WaitForResult(); |
1955 EXPECT_EQ(OK, rv); | 1955 EXPECT_EQ(OK, rv); |
1956 | 1956 |
1957 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1957 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1958 ASSERT_TRUE(response != NULL); | 1958 ASSERT_TRUE(response != NULL); |
1959 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1959 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1960 | 1960 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 | 2025 |
2026 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2026 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2027 data_writes1, arraysize(data_writes1)); | 2027 data_writes1, arraysize(data_writes1)); |
2028 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2028 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2029 SSLSocketDataProvider ssl(ASYNC, OK); | 2029 SSLSocketDataProvider ssl(ASYNC, OK); |
2030 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2030 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2031 | 2031 |
2032 TestCompletionCallback callback1; | 2032 TestCompletionCallback callback1; |
2033 | 2033 |
2034 scoped_ptr<HttpTransaction> trans( | 2034 scoped_ptr<HttpTransaction> trans( |
2035 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2035 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2036 | 2036 |
2037 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2037 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2038 EXPECT_EQ(ERR_IO_PENDING, rv); | 2038 EXPECT_EQ(ERR_IO_PENDING, rv); |
2039 | 2039 |
2040 rv = callback1.WaitForResult(); | 2040 rv = callback1.WaitForResult(); |
2041 EXPECT_EQ(OK, rv); | 2041 EXPECT_EQ(OK, rv); |
2042 CapturingNetLog::CapturedEntryList entries; | 2042 CapturingNetLog::CapturedEntryList entries; |
2043 log.GetEntries(&entries); | 2043 log.GetEntries(&entries); |
2044 size_t pos = ExpectLogContainsSomewhere( | 2044 size_t pos = ExpectLogContainsSomewhere( |
2045 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2045 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
2046 NetLog::PHASE_NONE); | 2046 NetLog::PHASE_NONE); |
2047 ExpectLogContainsSomewhere( | 2047 ExpectLogContainsSomewhere( |
2048 entries, pos, | 2048 entries, pos, |
2049 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2049 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
2050 NetLog::PHASE_NONE); | 2050 NetLog::PHASE_NONE); |
2051 | 2051 |
2052 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2052 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2053 ASSERT_TRUE(response != NULL); | 2053 ASSERT_TRUE(response != NULL); |
2054 ASSERT_FALSE(response->headers == NULL); | 2054 ASSERT_FALSE(response->headers.get() == NULL); |
2055 EXPECT_EQ(407, response->headers->response_code()); | 2055 EXPECT_EQ(407, response->headers->response_code()); |
2056 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2056 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2057 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2057 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2058 | 2058 |
2059 LoadTimingInfo load_timing_info; | 2059 LoadTimingInfo load_timing_info; |
2060 // CONNECT requests and responses are handled at the connect job level, so | 2060 // CONNECT requests and responses are handled at the connect job level, so |
2061 // the transaction does not yet have a connection. | 2061 // the transaction does not yet have a connection. |
2062 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); | 2062 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); |
2063 | 2063 |
2064 TestCompletionCallback callback2; | 2064 TestCompletionCallback callback2; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2099 // when the no authentication data flag is set. | 2099 // when the no authentication data flag is set. |
2100 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 2100 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
2101 | 2101 |
2102 // Configure against proxy server "myproxy:70". | 2102 // Configure against proxy server "myproxy:70". |
2103 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); | 2103 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); |
2104 CapturingBoundNetLog log; | 2104 CapturingBoundNetLog log; |
2105 session_deps_.net_log = log.bound().net_log(); | 2105 session_deps_.net_log = log.bound().net_log(); |
2106 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2106 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2107 | 2107 |
2108 scoped_ptr<HttpTransaction> trans( | 2108 scoped_ptr<HttpTransaction> trans( |
2109 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2109 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2110 | 2110 |
2111 // Since we have proxy, should try to establish tunnel. | 2111 // Since we have proxy, should try to establish tunnel. |
2112 MockWrite data_writes1[] = { | 2112 MockWrite data_writes1[] = { |
2113 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2113 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
2114 "Host: www.google.com\r\n" | 2114 "Host: www.google.com\r\n" |
2115 "Proxy-Connection: keep-alive\r\n\r\n"), | 2115 "Proxy-Connection: keep-alive\r\n\r\n"), |
2116 | 2116 |
2117 // After calling trans->RestartWithAuth(), this is the request we should | 2117 // After calling trans->RestartWithAuth(), this is the request we should |
2118 // be issuing -- the final header line contains the credentials. | 2118 // be issuing -- the final header line contains the credentials. |
2119 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2119 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 size_t pos = ExpectLogContainsSomewhere( | 2155 size_t pos = ExpectLogContainsSomewhere( |
2156 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2156 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
2157 NetLog::PHASE_NONE); | 2157 NetLog::PHASE_NONE); |
2158 ExpectLogContainsSomewhere( | 2158 ExpectLogContainsSomewhere( |
2159 entries, pos, | 2159 entries, pos, |
2160 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2160 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
2161 NetLog::PHASE_NONE); | 2161 NetLog::PHASE_NONE); |
2162 | 2162 |
2163 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2163 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2164 ASSERT_TRUE(response != NULL); | 2164 ASSERT_TRUE(response != NULL); |
2165 ASSERT_FALSE(response->headers == NULL); | 2165 ASSERT_FALSE(response->headers.get() == NULL); |
2166 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2166 EXPECT_TRUE(response->headers->IsKeepAlive()); |
2167 EXPECT_EQ(407, response->headers->response_code()); | 2167 EXPECT_EQ(407, response->headers->response_code()); |
2168 EXPECT_EQ(10, response->headers->GetContentLength()); | 2168 EXPECT_EQ(10, response->headers->GetContentLength()); |
2169 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2169 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2170 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2170 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2171 | 2171 |
2172 TestCompletionCallback callback2; | 2172 TestCompletionCallback callback2; |
2173 | 2173 |
2174 // Wrong password (should be "bar"). | 2174 // Wrong password (should be "bar"). |
2175 rv = trans->RestartWithAuth( | 2175 rv = trans->RestartWithAuth( |
2176 AuthCredentials(kFoo, kBaz), callback2.callback()); | 2176 AuthCredentials(kFoo, kBaz), callback2.callback()); |
2177 EXPECT_EQ(ERR_IO_PENDING, rv); | 2177 EXPECT_EQ(ERR_IO_PENDING, rv); |
2178 | 2178 |
2179 rv = callback2.WaitForResult(); | 2179 rv = callback2.WaitForResult(); |
2180 EXPECT_EQ(OK, rv); | 2180 EXPECT_EQ(OK, rv); |
2181 | 2181 |
2182 response = trans->GetResponseInfo(); | 2182 response = trans->GetResponseInfo(); |
2183 ASSERT_TRUE(response != NULL); | 2183 ASSERT_TRUE(response != NULL); |
2184 ASSERT_FALSE(response->headers == NULL); | 2184 ASSERT_FALSE(response->headers.get() == NULL); |
2185 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2185 EXPECT_TRUE(response->headers->IsKeepAlive()); |
2186 EXPECT_EQ(407, response->headers->response_code()); | 2186 EXPECT_EQ(407, response->headers->response_code()); |
2187 EXPECT_EQ(10, response->headers->GetContentLength()); | 2187 EXPECT_EQ(10, response->headers->GetContentLength()); |
2188 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2188 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2189 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2189 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2190 | 2190 |
2191 // Flush the idle socket before the NetLog and HttpNetworkTransaction go | 2191 // Flush the idle socket before the NetLog and HttpNetworkTransaction go |
2192 // out of scope. | 2192 // out of scope. |
2193 session->CloseAllConnections(); | 2193 session->CloseAllConnections(); |
2194 } | 2194 } |
2195 | 2195 |
2196 // Test that we don't read the response body when we fail to establish a tunnel, | 2196 // Test that we don't read the response body when we fail to establish a tunnel, |
2197 // even if the user cancels the proxy's auth attempt. | 2197 // even if the user cancels the proxy's auth attempt. |
2198 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyCancelTunnel) { | 2198 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyCancelTunnel) { |
2199 HttpRequestInfo request; | 2199 HttpRequestInfo request; |
2200 request.method = "GET"; | 2200 request.method = "GET"; |
2201 request.url = GURL("https://www.google.com/"); | 2201 request.url = GURL("https://www.google.com/"); |
2202 request.load_flags = 0; | 2202 request.load_flags = 0; |
2203 | 2203 |
2204 // Configure against proxy server "myproxy:70". | 2204 // Configure against proxy server "myproxy:70". |
2205 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); | 2205 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); |
2206 | 2206 |
2207 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2207 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2208 | 2208 |
2209 scoped_ptr<HttpTransaction> trans( | 2209 scoped_ptr<HttpTransaction> trans( |
2210 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2210 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2211 | 2211 |
2212 // Since we have proxy, should try to establish tunnel. | 2212 // Since we have proxy, should try to establish tunnel. |
2213 MockWrite data_writes[] = { | 2213 MockWrite data_writes[] = { |
2214 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2214 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
2215 "Host: www.google.com\r\n" | 2215 "Host: www.google.com\r\n" |
2216 "Proxy-Connection: keep-alive\r\n\r\n"), | 2216 "Proxy-Connection: keep-alive\r\n\r\n"), |
2217 }; | 2217 }; |
2218 | 2218 |
2219 // The proxy responds to the connect with a 407. | 2219 // The proxy responds to the connect with a 407. |
2220 MockRead data_reads[] = { | 2220 MockRead data_reads[] = { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 | 2332 |
2333 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2333 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2334 data_writes1, arraysize(data_writes1)); | 2334 data_writes1, arraysize(data_writes1)); |
2335 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2335 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2336 SSLSocketDataProvider ssl(ASYNC, OK); | 2336 SSLSocketDataProvider ssl(ASYNC, OK); |
2337 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2337 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2338 | 2338 |
2339 TestCompletionCallback callback1; | 2339 TestCompletionCallback callback1; |
2340 | 2340 |
2341 scoped_ptr<HttpTransaction> trans( | 2341 scoped_ptr<HttpTransaction> trans( |
2342 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2342 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2343 | 2343 |
2344 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2344 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2345 EXPECT_EQ(ERR_IO_PENDING, rv); | 2345 EXPECT_EQ(ERR_IO_PENDING, rv); |
2346 | 2346 |
2347 rv = callback1.WaitForResult(); | 2347 rv = callback1.WaitForResult(); |
2348 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2348 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
2349 CapturingNetLog::CapturedEntryList entries; | 2349 CapturingNetLog::CapturedEntryList entries; |
2350 log.GetEntries(&entries); | 2350 log.GetEntries(&entries); |
2351 size_t pos = ExpectLogContainsSomewhere( | 2351 size_t pos = ExpectLogContainsSomewhere( |
2352 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2352 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 }; | 2404 }; |
2405 | 2405 |
2406 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2406 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2407 data_writes1, arraysize(data_writes1)); | 2407 data_writes1, arraysize(data_writes1)); |
2408 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2408 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2409 SSLSocketDataProvider ssl(ASYNC, OK); | 2409 SSLSocketDataProvider ssl(ASYNC, OK); |
2410 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2410 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2411 | 2411 |
2412 TestCompletionCallback callback1; | 2412 TestCompletionCallback callback1; |
2413 scoped_ptr<HttpTransaction> trans1( | 2413 scoped_ptr<HttpTransaction> trans1( |
2414 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2414 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2415 | 2415 |
2416 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 2416 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
2417 EXPECT_EQ(ERR_IO_PENDING, rv); | 2417 EXPECT_EQ(ERR_IO_PENDING, rv); |
2418 | 2418 |
2419 rv = callback1.WaitForResult(); | 2419 rv = callback1.WaitForResult(); |
2420 EXPECT_EQ(OK, rv); | 2420 EXPECT_EQ(OK, rv); |
2421 | 2421 |
2422 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 2422 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
2423 ASSERT_TRUE(response1 != NULL); | 2423 ASSERT_TRUE(response1 != NULL); |
2424 ASSERT_TRUE(response1->headers != NULL); | 2424 ASSERT_TRUE(response1->headers.get() != NULL); |
2425 EXPECT_EQ(1, response1->headers->GetContentLength()); | 2425 EXPECT_EQ(1, response1->headers->GetContentLength()); |
2426 | 2426 |
2427 LoadTimingInfo load_timing_info1; | 2427 LoadTimingInfo load_timing_info1; |
2428 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 2428 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
2429 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); | 2429 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); |
2430 | 2430 |
2431 trans1.reset(); | 2431 trans1.reset(); |
2432 | 2432 |
2433 TestCompletionCallback callback2; | 2433 TestCompletionCallback callback2; |
2434 scoped_ptr<HttpTransaction> trans2( | 2434 scoped_ptr<HttpTransaction> trans2( |
2435 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2435 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2436 | 2436 |
2437 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 2437 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
2438 EXPECT_EQ(ERR_IO_PENDING, rv); | 2438 EXPECT_EQ(ERR_IO_PENDING, rv); |
2439 | 2439 |
2440 rv = callback2.WaitForResult(); | 2440 rv = callback2.WaitForResult(); |
2441 EXPECT_EQ(OK, rv); | 2441 EXPECT_EQ(OK, rv); |
2442 | 2442 |
2443 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 2443 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
2444 ASSERT_TRUE(response2 != NULL); | 2444 ASSERT_TRUE(response2 != NULL); |
2445 ASSERT_TRUE(response2->headers != NULL); | 2445 ASSERT_TRUE(response2->headers.get() != NULL); |
2446 EXPECT_EQ(2, response2->headers->GetContentLength()); | 2446 EXPECT_EQ(2, response2->headers->GetContentLength()); |
2447 | 2447 |
2448 LoadTimingInfo load_timing_info2; | 2448 LoadTimingInfo load_timing_info2; |
2449 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 2449 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
2450 TestLoadTimingReused(load_timing_info2); | 2450 TestLoadTimingReused(load_timing_info2); |
2451 | 2451 |
2452 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 2452 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
2453 | 2453 |
2454 trans2.reset(); | 2454 trans2.reset(); |
2455 session->CloseAllConnections(); | 2455 session->CloseAllConnections(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 }; | 2502 }; |
2503 | 2503 |
2504 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2504 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2505 data_writes1, arraysize(data_writes1)); | 2505 data_writes1, arraysize(data_writes1)); |
2506 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2506 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2507 SSLSocketDataProvider ssl(ASYNC, OK); | 2507 SSLSocketDataProvider ssl(ASYNC, OK); |
2508 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2508 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2509 | 2509 |
2510 TestCompletionCallback callback1; | 2510 TestCompletionCallback callback1; |
2511 scoped_ptr<HttpTransaction> trans1( | 2511 scoped_ptr<HttpTransaction> trans1( |
2512 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2512 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2513 | 2513 |
2514 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 2514 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
2515 EXPECT_EQ(ERR_IO_PENDING, rv); | 2515 EXPECT_EQ(ERR_IO_PENDING, rv); |
2516 | 2516 |
2517 rv = callback1.WaitForResult(); | 2517 rv = callback1.WaitForResult(); |
2518 EXPECT_EQ(OK, rv); | 2518 EXPECT_EQ(OK, rv); |
2519 | 2519 |
2520 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 2520 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
2521 ASSERT_TRUE(response1 != NULL); | 2521 ASSERT_TRUE(response1 != NULL); |
2522 ASSERT_TRUE(response1->headers != NULL); | 2522 ASSERT_TRUE(response1->headers.get() != NULL); |
2523 EXPECT_EQ(1, response1->headers->GetContentLength()); | 2523 EXPECT_EQ(1, response1->headers->GetContentLength()); |
2524 | 2524 |
2525 LoadTimingInfo load_timing_info1; | 2525 LoadTimingInfo load_timing_info1; |
2526 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 2526 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
2527 TestLoadTimingNotReusedWithPac(load_timing_info1, | 2527 TestLoadTimingNotReusedWithPac(load_timing_info1, |
2528 CONNECT_TIMING_HAS_SSL_TIMES); | 2528 CONNECT_TIMING_HAS_SSL_TIMES); |
2529 | 2529 |
2530 trans1.reset(); | 2530 trans1.reset(); |
2531 | 2531 |
2532 TestCompletionCallback callback2; | 2532 TestCompletionCallback callback2; |
2533 scoped_ptr<HttpTransaction> trans2( | 2533 scoped_ptr<HttpTransaction> trans2( |
2534 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2534 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2535 | 2535 |
2536 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 2536 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
2537 EXPECT_EQ(ERR_IO_PENDING, rv); | 2537 EXPECT_EQ(ERR_IO_PENDING, rv); |
2538 | 2538 |
2539 rv = callback2.WaitForResult(); | 2539 rv = callback2.WaitForResult(); |
2540 EXPECT_EQ(OK, rv); | 2540 EXPECT_EQ(OK, rv); |
2541 | 2541 |
2542 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 2542 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
2543 ASSERT_TRUE(response2 != NULL); | 2543 ASSERT_TRUE(response2 != NULL); |
2544 ASSERT_TRUE(response2->headers != NULL); | 2544 ASSERT_TRUE(response2->headers.get() != NULL); |
2545 EXPECT_EQ(2, response2->headers->GetContentLength()); | 2545 EXPECT_EQ(2, response2->headers->GetContentLength()); |
2546 | 2546 |
2547 LoadTimingInfo load_timing_info2; | 2547 LoadTimingInfo load_timing_info2; |
2548 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 2548 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
2549 TestLoadTimingReusedWithPac(load_timing_info2); | 2549 TestLoadTimingReusedWithPac(load_timing_info2); |
2550 | 2550 |
2551 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 2551 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
2552 | 2552 |
2553 trans2.reset(); | 2553 trans2.reset(); |
2554 session->CloseAllConnections(); | 2554 session->CloseAllConnections(); |
(...skipping 28 matching lines...) Expand all Loading... |
2583 | 2583 |
2584 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2584 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2585 data_writes1, arraysize(data_writes1)); | 2585 data_writes1, arraysize(data_writes1)); |
2586 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2586 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2587 SSLSocketDataProvider ssl(ASYNC, OK); | 2587 SSLSocketDataProvider ssl(ASYNC, OK); |
2588 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2588 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2589 | 2589 |
2590 TestCompletionCallback callback1; | 2590 TestCompletionCallback callback1; |
2591 | 2591 |
2592 scoped_ptr<HttpTransaction> trans( | 2592 scoped_ptr<HttpTransaction> trans( |
2593 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2593 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2594 | 2594 |
2595 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2595 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2596 EXPECT_EQ(ERR_IO_PENDING, rv); | 2596 EXPECT_EQ(ERR_IO_PENDING, rv); |
2597 | 2597 |
2598 rv = callback1.WaitForResult(); | 2598 rv = callback1.WaitForResult(); |
2599 EXPECT_EQ(OK, rv); | 2599 EXPECT_EQ(OK, rv); |
2600 | 2600 |
2601 LoadTimingInfo load_timing_info; | 2601 LoadTimingInfo load_timing_info; |
2602 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2602 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2603 TestLoadTimingNotReused(load_timing_info, | 2603 TestLoadTimingNotReused(load_timing_info, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2648 spdy_writes, arraysize(spdy_writes)); | 2648 spdy_writes, arraysize(spdy_writes)); |
2649 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 2649 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
2650 | 2650 |
2651 SSLSocketDataProvider ssl(ASYNC, OK); | 2651 SSLSocketDataProvider ssl(ASYNC, OK); |
2652 ssl.SetNextProto(kProtoSPDY3); | 2652 ssl.SetNextProto(kProtoSPDY3); |
2653 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2653 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2654 | 2654 |
2655 TestCompletionCallback callback1; | 2655 TestCompletionCallback callback1; |
2656 | 2656 |
2657 scoped_ptr<HttpTransaction> trans( | 2657 scoped_ptr<HttpTransaction> trans( |
2658 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2658 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2659 | 2659 |
2660 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2660 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2661 EXPECT_EQ(ERR_IO_PENDING, rv); | 2661 EXPECT_EQ(ERR_IO_PENDING, rv); |
2662 | 2662 |
2663 rv = callback1.WaitForResult(); | 2663 rv = callback1.WaitForResult(); |
2664 EXPECT_EQ(OK, rv); | 2664 EXPECT_EQ(OK, rv); |
2665 | 2665 |
2666 LoadTimingInfo load_timing_info; | 2666 LoadTimingInfo load_timing_info; |
2667 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2667 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2668 TestLoadTimingNotReused(load_timing_info, | 2668 TestLoadTimingNotReused(load_timing_info, |
2669 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 2669 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
2670 | 2670 |
2671 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2671 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2672 ASSERT_TRUE(response != NULL); | 2672 ASSERT_TRUE(response != NULL); |
2673 ASSERT_TRUE(response->headers != NULL); | 2673 ASSERT_TRUE(response->headers.get() != NULL); |
2674 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2674 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2675 | 2675 |
2676 std::string response_data; | 2676 std::string response_data; |
2677 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2677 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2678 EXPECT_EQ(kUploadData, response_data); | 2678 EXPECT_EQ(kUploadData, response_data); |
2679 } | 2679 } |
2680 | 2680 |
2681 // Test a SPDY get through an HTTPS Proxy. | 2681 // Test a SPDY get through an HTTPS Proxy. |
2682 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyGetWithProxyAuth) { | 2682 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyGetWithProxyAuth) { |
2683 HttpRequestInfo request; | 2683 HttpRequestInfo request; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 spdy_writes, arraysize(spdy_writes)); | 2736 spdy_writes, arraysize(spdy_writes)); |
2737 session_deps_.socket_factory->AddSocketDataProvider(&data); | 2737 session_deps_.socket_factory->AddSocketDataProvider(&data); |
2738 | 2738 |
2739 SSLSocketDataProvider ssl(ASYNC, OK); | 2739 SSLSocketDataProvider ssl(ASYNC, OK); |
2740 ssl.SetNextProto(kProtoSPDY3); | 2740 ssl.SetNextProto(kProtoSPDY3); |
2741 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2741 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2742 | 2742 |
2743 TestCompletionCallback callback1; | 2743 TestCompletionCallback callback1; |
2744 | 2744 |
2745 scoped_ptr<HttpTransaction> trans( | 2745 scoped_ptr<HttpTransaction> trans( |
2746 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2746 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2747 | 2747 |
2748 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2748 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2749 EXPECT_EQ(ERR_IO_PENDING, rv); | 2749 EXPECT_EQ(ERR_IO_PENDING, rv); |
2750 | 2750 |
2751 rv = callback1.WaitForResult(); | 2751 rv = callback1.WaitForResult(); |
2752 EXPECT_EQ(OK, rv); | 2752 EXPECT_EQ(OK, rv); |
2753 | 2753 |
2754 const HttpResponseInfo* const response = trans->GetResponseInfo(); | 2754 const HttpResponseInfo* const response = trans->GetResponseInfo(); |
2755 | 2755 |
2756 ASSERT_TRUE(response != NULL); | 2756 ASSERT_TRUE(response != NULL); |
2757 ASSERT_TRUE(response->headers != NULL); | 2757 ASSERT_TRUE(response->headers.get() != NULL); |
2758 EXPECT_EQ(407, response->headers->response_code()); | 2758 EXPECT_EQ(407, response->headers->response_code()); |
2759 EXPECT_TRUE(response->was_fetched_via_spdy); | 2759 EXPECT_TRUE(response->was_fetched_via_spdy); |
2760 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2760 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2761 | 2761 |
2762 TestCompletionCallback callback2; | 2762 TestCompletionCallback callback2; |
2763 | 2763 |
2764 rv = trans->RestartWithAuth( | 2764 rv = trans->RestartWithAuth( |
2765 AuthCredentials(kFoo, kBar), callback2.callback()); | 2765 AuthCredentials(kFoo, kBar), callback2.callback()); |
2766 EXPECT_EQ(ERR_IO_PENDING, rv); | 2766 EXPECT_EQ(ERR_IO_PENDING, rv); |
2767 | 2767 |
2768 rv = callback2.WaitForResult(); | 2768 rv = callback2.WaitForResult(); |
2769 EXPECT_EQ(OK, rv); | 2769 EXPECT_EQ(OK, rv); |
2770 | 2770 |
2771 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 2771 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
2772 | 2772 |
2773 ASSERT_TRUE(response_restart != NULL); | 2773 ASSERT_TRUE(response_restart != NULL); |
2774 ASSERT_TRUE(response_restart->headers != NULL); | 2774 ASSERT_TRUE(response_restart->headers.get() != NULL); |
2775 EXPECT_EQ(200, response_restart->headers->response_code()); | 2775 EXPECT_EQ(200, response_restart->headers->response_code()); |
2776 // The password prompt info should not be set. | 2776 // The password prompt info should not be set. |
2777 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 2777 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
2778 } | 2778 } |
2779 | 2779 |
2780 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. | 2780 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. |
2781 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectHttps) { | 2781 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectHttps) { |
2782 HttpRequestInfo request; | 2782 HttpRequestInfo request; |
2783 request.method = "GET"; | 2783 request.method = "GET"; |
2784 request.url = GURL("https://www.google.com/"); | 2784 request.url = GURL("https://www.google.com/"); |
2785 request.load_flags = 0; | 2785 request.load_flags = 0; |
2786 | 2786 |
2787 // Configure against https proxy server "proxy:70". | 2787 // Configure against https proxy server "proxy:70". |
2788 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 2788 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
2789 "https://proxy:70")); | 2789 "https://proxy:70")); |
2790 CapturingBoundNetLog log; | 2790 CapturingBoundNetLog log; |
2791 session_deps_.net_log = log.bound().net_log(); | 2791 session_deps_.net_log = log.bound().net_log(); |
2792 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2792 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2793 | 2793 |
2794 scoped_ptr<HttpTransaction> trans( | 2794 scoped_ptr<HttpTransaction> trans( |
2795 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2795 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2796 | 2796 |
2797 // CONNECT to www.google.com:443 via SPDY | 2797 // CONNECT to www.google.com:443 via SPDY |
2798 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); | 2798 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); |
2799 // fetch https://www.google.com/ via HTTP | 2799 // fetch https://www.google.com/ via HTTP |
2800 | 2800 |
2801 const char get[] = "GET / HTTP/1.1\r\n" | 2801 const char get[] = "GET / HTTP/1.1\r\n" |
2802 "Host: www.google.com\r\n" | 2802 "Host: www.google.com\r\n" |
2803 "Connection: keep-alive\r\n\r\n"; | 2803 "Connection: keep-alive\r\n\r\n"; |
2804 scoped_ptr<SpdyFrame> wrapped_get( | 2804 scoped_ptr<SpdyFrame> wrapped_get( |
2805 ConstructSpdyBodyFrame(1, get, strlen(get), false)); | 2805 ConstructSpdyBodyFrame(1, get, strlen(get), false)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2847 | 2847 |
2848 rv = callback1.WaitForResult(); | 2848 rv = callback1.WaitForResult(); |
2849 EXPECT_EQ(OK, rv); | 2849 EXPECT_EQ(OK, rv); |
2850 | 2850 |
2851 LoadTimingInfo load_timing_info; | 2851 LoadTimingInfo load_timing_info; |
2852 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2852 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2853 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 2853 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
2854 | 2854 |
2855 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2855 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2856 ASSERT_TRUE(response != NULL); | 2856 ASSERT_TRUE(response != NULL); |
2857 ASSERT_TRUE(response->headers != NULL); | 2857 ASSERT_TRUE(response->headers.get() != NULL); |
2858 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2858 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2859 | 2859 |
2860 std::string response_data; | 2860 std::string response_data; |
2861 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2861 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2862 EXPECT_EQ("1234567890", response_data); | 2862 EXPECT_EQ("1234567890", response_data); |
2863 } | 2863 } |
2864 | 2864 |
2865 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. | 2865 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. |
2866 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectSpdy) { | 2866 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectSpdy) { |
2867 HttpRequestInfo request; | 2867 HttpRequestInfo request; |
2868 request.method = "GET"; | 2868 request.method = "GET"; |
2869 request.url = GURL("https://www.google.com/"); | 2869 request.url = GURL("https://www.google.com/"); |
2870 request.load_flags = 0; | 2870 request.load_flags = 0; |
2871 | 2871 |
2872 // Configure against https proxy server "proxy:70". | 2872 // Configure against https proxy server "proxy:70". |
2873 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 2873 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
2874 "https://proxy:70")); | 2874 "https://proxy:70")); |
2875 CapturingBoundNetLog log; | 2875 CapturingBoundNetLog log; |
2876 session_deps_.net_log = log.bound().net_log(); | 2876 session_deps_.net_log = log.bound().net_log(); |
2877 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2877 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2878 | 2878 |
2879 scoped_ptr<HttpTransaction> trans( | 2879 scoped_ptr<HttpTransaction> trans( |
2880 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2880 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2881 | 2881 |
2882 // CONNECT to www.google.com:443 via SPDY | 2882 // CONNECT to www.google.com:443 via SPDY |
2883 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); | 2883 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); |
2884 // fetch https://www.google.com/ via SPDY | 2884 // fetch https://www.google.com/ via SPDY |
2885 const char* const kMyUrl = "https://www.google.com/"; | 2885 const char* const kMyUrl = "https://www.google.com/"; |
2886 scoped_ptr<SpdyFrame> get( | 2886 scoped_ptr<SpdyFrame> get( |
2887 spdy_util_.ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); | 2887 spdy_util_.ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); |
2888 scoped_ptr<SpdyFrame> wrapped_get(ConstructWrappedSpdyFrame(get, 1)); | 2888 scoped_ptr<SpdyFrame> wrapped_get(ConstructWrappedSpdyFrame(get, 1)); |
2889 scoped_ptr<SpdyFrame> conn_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2889 scoped_ptr<SpdyFrame> conn_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
2890 scoped_ptr<SpdyFrame> get_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2890 scoped_ptr<SpdyFrame> get_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2931 | 2931 |
2932 rv = callback1.WaitForResult(); | 2932 rv = callback1.WaitForResult(); |
2933 EXPECT_EQ(OK, rv); | 2933 EXPECT_EQ(OK, rv); |
2934 | 2934 |
2935 LoadTimingInfo load_timing_info; | 2935 LoadTimingInfo load_timing_info; |
2936 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2936 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2937 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 2937 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
2938 | 2938 |
2939 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2939 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2940 ASSERT_TRUE(response != NULL); | 2940 ASSERT_TRUE(response != NULL); |
2941 ASSERT_TRUE(response->headers != NULL); | 2941 ASSERT_TRUE(response->headers.get() != NULL); |
2942 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2942 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2943 | 2943 |
2944 std::string response_data; | 2944 std::string response_data; |
2945 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2945 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2946 EXPECT_EQ(kUploadData, response_data); | 2946 EXPECT_EQ(kUploadData, response_data); |
2947 } | 2947 } |
2948 | 2948 |
2949 // Test a SPDY CONNECT failure through an HTTPS Proxy. | 2949 // Test a SPDY CONNECT failure through an HTTPS Proxy. |
2950 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectFailure) { | 2950 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectFailure) { |
2951 HttpRequestInfo request; | 2951 HttpRequestInfo request; |
2952 request.method = "GET"; | 2952 request.method = "GET"; |
2953 request.url = GURL("https://www.google.com/"); | 2953 request.url = GURL("https://www.google.com/"); |
2954 request.load_flags = 0; | 2954 request.load_flags = 0; |
2955 | 2955 |
2956 // Configure against https proxy server "proxy:70". | 2956 // Configure against https proxy server "proxy:70". |
2957 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 2957 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
2958 "https://proxy:70")); | 2958 "https://proxy:70")); |
2959 CapturingBoundNetLog log; | 2959 CapturingBoundNetLog log; |
2960 session_deps_.net_log = log.bound().net_log(); | 2960 session_deps_.net_log = log.bound().net_log(); |
2961 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2961 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2962 | 2962 |
2963 scoped_ptr<HttpTransaction> trans( | 2963 scoped_ptr<HttpTransaction> trans( |
2964 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2964 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2965 | 2965 |
2966 // CONNECT to www.google.com:443 via SPDY | 2966 // CONNECT to www.google.com:443 via SPDY |
2967 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); | 2967 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); |
2968 scoped_ptr<SpdyFrame> get( | 2968 scoped_ptr<SpdyFrame> get( |
2969 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 2969 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
2970 | 2970 |
2971 MockWrite spdy_writes[] = { | 2971 MockWrite spdy_writes[] = { |
2972 CreateMockWrite(*connect, 1), | 2972 CreateMockWrite(*connect, 1), |
2973 CreateMockWrite(*get, 3), | 2973 CreateMockWrite(*get, 3), |
2974 }; | 2974 }; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3106 ssl2.protocol_negotiated = kProtoUnknown; | 3106 ssl2.protocol_negotiated = kProtoUnknown; |
3107 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); | 3107 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); |
3108 SSLSocketDataProvider ssl3(ASYNC, OK); | 3108 SSLSocketDataProvider ssl3(ASYNC, OK); |
3109 ssl3.was_npn_negotiated = false; | 3109 ssl3.was_npn_negotiated = false; |
3110 ssl3.protocol_negotiated = kProtoUnknown; | 3110 ssl3.protocol_negotiated = kProtoUnknown; |
3111 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl3); | 3111 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl3); |
3112 | 3112 |
3113 TestCompletionCallback callback; | 3113 TestCompletionCallback callback; |
3114 | 3114 |
3115 scoped_ptr<HttpTransaction> trans( | 3115 scoped_ptr<HttpTransaction> trans( |
3116 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3116 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3117 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 3117 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
3118 EXPECT_EQ(ERR_IO_PENDING, rv); | 3118 EXPECT_EQ(ERR_IO_PENDING, rv); |
3119 // The first connect and request, each of their responses, and the body. | 3119 // The first connect and request, each of their responses, and the body. |
3120 spdy_data.RunFor(5); | 3120 spdy_data.RunFor(5); |
3121 | 3121 |
3122 rv = callback.WaitForResult(); | 3122 rv = callback.WaitForResult(); |
3123 EXPECT_EQ(OK, rv); | 3123 EXPECT_EQ(OK, rv); |
3124 | 3124 |
3125 LoadTimingInfo load_timing_info; | 3125 LoadTimingInfo load_timing_info; |
3126 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3126 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3127 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 3127 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
3128 | 3128 |
3129 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3129 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3130 ASSERT_TRUE(response != NULL); | 3130 ASSERT_TRUE(response != NULL); |
3131 ASSERT_TRUE(response->headers != NULL); | 3131 ASSERT_TRUE(response->headers.get() != NULL); |
3132 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3132 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
3133 | 3133 |
3134 std::string response_data; | 3134 std::string response_data; |
3135 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); | 3135 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
3136 EXPECT_EQ(1, trans->Read(buf, 256, callback.callback())); | 3136 EXPECT_EQ(1, trans->Read(buf.get(), 256, callback.callback())); |
3137 | 3137 |
3138 scoped_ptr<HttpTransaction> trans2( | 3138 scoped_ptr<HttpTransaction> trans2( |
3139 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3139 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3140 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 3140 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
3141 EXPECT_EQ(ERR_IO_PENDING, rv); | 3141 EXPECT_EQ(ERR_IO_PENDING, rv); |
3142 | 3142 |
3143 // The second connect and request, each of their responses, and the body. | 3143 // The second connect and request, each of their responses, and the body. |
3144 spdy_data.RunFor(5); | 3144 spdy_data.RunFor(5); |
3145 rv = callback.WaitForResult(); | 3145 rv = callback.WaitForResult(); |
3146 EXPECT_EQ(OK, rv); | 3146 EXPECT_EQ(OK, rv); |
3147 | 3147 |
3148 LoadTimingInfo load_timing_info2; | 3148 LoadTimingInfo load_timing_info2; |
3149 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 3149 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
3150 // Even though the SPDY connection is reused, a new tunnelled connection has | 3150 // Even though the SPDY connection is reused, a new tunnelled connection has |
3151 // to be created, so the socket's load timing looks like a fresh connection. | 3151 // to be created, so the socket's load timing looks like a fresh connection. |
3152 TestLoadTimingNotReused(load_timing_info2, CONNECT_TIMING_HAS_SSL_TIMES); | 3152 TestLoadTimingNotReused(load_timing_info2, CONNECT_TIMING_HAS_SSL_TIMES); |
3153 | 3153 |
3154 // The requests should have different IDs, since they each are using their own | 3154 // The requests should have different IDs, since they each are using their own |
3155 // separate stream. | 3155 // separate stream. |
3156 EXPECT_NE(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); | 3156 EXPECT_NE(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); |
3157 | 3157 |
3158 EXPECT_EQ(2, trans2->Read(buf, 256, callback.callback())); | 3158 EXPECT_EQ(2, trans2->Read(buf.get(), 256, callback.callback())); |
3159 } | 3159 } |
3160 | 3160 |
3161 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY | 3161 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY |
3162 // HTTPS Proxy to the same server. | 3162 // HTTPS Proxy to the same server. |
3163 TEST_F(HttpNetworkTransactionSpdy3Test, | 3163 TEST_F(HttpNetworkTransactionSpdy3Test, |
3164 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) { | 3164 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) { |
3165 // Configure against https proxy server "proxy:70". | 3165 // Configure against https proxy server "proxy:70". |
3166 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 3166 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
3167 "https://proxy:70")); | 3167 "https://proxy:70")); |
3168 CapturingBoundNetLog log; | 3168 CapturingBoundNetLog log; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 ssl.SetNextProto(kProtoSPDY3); | 3235 ssl.SetNextProto(kProtoSPDY3); |
3236 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | 3236 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); |
3237 SSLSocketDataProvider ssl2(ASYNC, OK); | 3237 SSLSocketDataProvider ssl2(ASYNC, OK); |
3238 ssl2.was_npn_negotiated = false; | 3238 ssl2.was_npn_negotiated = false; |
3239 ssl2.protocol_negotiated = kProtoUnknown; | 3239 ssl2.protocol_negotiated = kProtoUnknown; |
3240 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); | 3240 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); |
3241 | 3241 |
3242 TestCompletionCallback callback; | 3242 TestCompletionCallback callback; |
3243 | 3243 |
3244 scoped_ptr<HttpTransaction> trans( | 3244 scoped_ptr<HttpTransaction> trans( |
3245 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3245 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3246 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 3246 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
3247 EXPECT_EQ(ERR_IO_PENDING, rv); | 3247 EXPECT_EQ(ERR_IO_PENDING, rv); |
3248 // The first connect and request, each of their responses, and the body. | 3248 // The first connect and request, each of their responses, and the body. |
3249 spdy_data.RunFor(5); | 3249 spdy_data.RunFor(5); |
3250 | 3250 |
3251 rv = callback.WaitForResult(); | 3251 rv = callback.WaitForResult(); |
3252 EXPECT_EQ(OK, rv); | 3252 EXPECT_EQ(OK, rv); |
3253 | 3253 |
3254 LoadTimingInfo load_timing_info; | 3254 LoadTimingInfo load_timing_info; |
3255 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3255 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3256 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 3256 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
3257 | 3257 |
3258 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3258 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3259 ASSERT_TRUE(response != NULL); | 3259 ASSERT_TRUE(response != NULL); |
3260 ASSERT_TRUE(response->headers != NULL); | 3260 ASSERT_TRUE(response->headers.get() != NULL); |
3261 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3261 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
3262 | 3262 |
3263 std::string response_data; | 3263 std::string response_data; |
3264 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); | 3264 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
3265 EXPECT_EQ(1, trans->Read(buf, 256, callback.callback())); | 3265 EXPECT_EQ(1, trans->Read(buf.get(), 256, callback.callback())); |
3266 // Delete the first request, so the second one can reuse the socket. | 3266 // Delete the first request, so the second one can reuse the socket. |
3267 trans.reset(); | 3267 trans.reset(); |
3268 | 3268 |
3269 scoped_ptr<HttpTransaction> trans2( | 3269 scoped_ptr<HttpTransaction> trans2( |
3270 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3270 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3271 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 3271 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
3272 EXPECT_EQ(ERR_IO_PENDING, rv); | 3272 EXPECT_EQ(ERR_IO_PENDING, rv); |
3273 | 3273 |
3274 // The second request, response, and body. There should not be a second | 3274 // The second request, response, and body. There should not be a second |
3275 // connect. | 3275 // connect. |
3276 spdy_data.RunFor(3); | 3276 spdy_data.RunFor(3); |
3277 rv = callback.WaitForResult(); | 3277 rv = callback.WaitForResult(); |
3278 EXPECT_EQ(OK, rv); | 3278 EXPECT_EQ(OK, rv); |
3279 | 3279 |
3280 LoadTimingInfo load_timing_info2; | 3280 LoadTimingInfo load_timing_info2; |
3281 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 3281 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
3282 TestLoadTimingReused(load_timing_info2); | 3282 TestLoadTimingReused(load_timing_info2); |
3283 | 3283 |
3284 // The requests should have the same ID. | 3284 // The requests should have the same ID. |
3285 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); | 3285 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); |
3286 | 3286 |
3287 EXPECT_EQ(2, trans2->Read(buf, 256, callback.callback())); | 3287 EXPECT_EQ(2, trans2->Read(buf.get(), 256, callback.callback())); |
3288 } | 3288 } |
3289 | 3289 |
3290 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS | 3290 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS |
3291 // Proxy to different servers. | 3291 // Proxy to different servers. |
3292 TEST_F(HttpNetworkTransactionSpdy3Test, | 3292 TEST_F(HttpNetworkTransactionSpdy3Test, |
3293 HttpsProxySpdyLoadTimingTwoHttpRequests) { | 3293 HttpsProxySpdyLoadTimingTwoHttpRequests) { |
3294 const char* const url1 = "http://www.google.com/"; | 3294 const char* const url1 = "http://www.google.com/"; |
3295 const char* const url2 = "http://news.google.com/"; | 3295 const char* const url2 = "http://news.google.com/"; |
3296 | 3296 |
3297 // Configure against https proxy server "proxy:70". | 3297 // Configure against https proxy server "proxy:70". |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3341 spdy_writes, arraysize(spdy_writes)); | 3341 spdy_writes, arraysize(spdy_writes)); |
3342 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&spdy_data); | 3342 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&spdy_data); |
3343 | 3343 |
3344 SSLSocketDataProvider ssl(ASYNC, OK); | 3344 SSLSocketDataProvider ssl(ASYNC, OK); |
3345 ssl.SetNextProto(kProtoSPDY3); | 3345 ssl.SetNextProto(kProtoSPDY3); |
3346 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | 3346 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); |
3347 | 3347 |
3348 TestCompletionCallback callback; | 3348 TestCompletionCallback callback; |
3349 | 3349 |
3350 scoped_ptr<HttpTransaction> trans( | 3350 scoped_ptr<HttpTransaction> trans( |
3351 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3351 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3352 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 3352 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
3353 EXPECT_EQ(ERR_IO_PENDING, rv); | 3353 EXPECT_EQ(ERR_IO_PENDING, rv); |
3354 spdy_data.RunFor(2); | 3354 spdy_data.RunFor(2); |
3355 | 3355 |
3356 rv = callback.WaitForResult(); | 3356 rv = callback.WaitForResult(); |
3357 EXPECT_EQ(OK, rv); | 3357 EXPECT_EQ(OK, rv); |
3358 | 3358 |
3359 LoadTimingInfo load_timing_info; | 3359 LoadTimingInfo load_timing_info; |
3360 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3360 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3361 TestLoadTimingNotReused(load_timing_info, | 3361 TestLoadTimingNotReused(load_timing_info, |
3362 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 3362 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
3363 | 3363 |
3364 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3364 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3365 ASSERT_TRUE(response != NULL); | 3365 ASSERT_TRUE(response != NULL); |
3366 ASSERT_TRUE(response->headers != NULL); | 3366 ASSERT_TRUE(response->headers.get() != NULL); |
3367 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3367 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
3368 | 3368 |
3369 std::string response_data; | 3369 std::string response_data; |
3370 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); | 3370 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
3371 EXPECT_EQ(ERR_IO_PENDING, trans->Read(buf, 256, callback.callback())); | 3371 EXPECT_EQ(ERR_IO_PENDING, trans->Read(buf.get(), 256, callback.callback())); |
3372 spdy_data.RunFor(1); | 3372 spdy_data.RunFor(1); |
3373 EXPECT_EQ(1, callback.WaitForResult()); | 3373 EXPECT_EQ(1, callback.WaitForResult()); |
3374 // Delete the first request, so the second one can reuse the socket. | 3374 // Delete the first request, so the second one can reuse the socket. |
3375 trans.reset(); | 3375 trans.reset(); |
3376 | 3376 |
3377 scoped_ptr<HttpTransaction> trans2( | 3377 scoped_ptr<HttpTransaction> trans2( |
3378 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3378 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3379 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 3379 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
3380 EXPECT_EQ(ERR_IO_PENDING, rv); | 3380 EXPECT_EQ(ERR_IO_PENDING, rv); |
3381 | 3381 |
3382 spdy_data.RunFor(2); | 3382 spdy_data.RunFor(2); |
3383 rv = callback.WaitForResult(); | 3383 rv = callback.WaitForResult(); |
3384 EXPECT_EQ(OK, rv); | 3384 EXPECT_EQ(OK, rv); |
3385 | 3385 |
3386 LoadTimingInfo load_timing_info2; | 3386 LoadTimingInfo load_timing_info2; |
3387 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 3387 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
3388 TestLoadTimingReused(load_timing_info2); | 3388 TestLoadTimingReused(load_timing_info2); |
3389 | 3389 |
3390 // The requests should have the same ID. | 3390 // The requests should have the same ID. |
3391 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); | 3391 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); |
3392 | 3392 |
3393 EXPECT_EQ(ERR_IO_PENDING, trans2->Read(buf, 256, callback.callback())); | 3393 EXPECT_EQ(ERR_IO_PENDING, trans2->Read(buf.get(), 256, callback.callback())); |
3394 spdy_data.RunFor(1); | 3394 spdy_data.RunFor(1); |
3395 EXPECT_EQ(2, callback.WaitForResult()); | 3395 EXPECT_EQ(2, callback.WaitForResult()); |
3396 } | 3396 } |
3397 | 3397 |
3398 // Test the challenge-response-retry sequence through an HTTPS Proxy | 3398 // Test the challenge-response-retry sequence through an HTTPS Proxy |
3399 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxyAuthRetry) { | 3399 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxyAuthRetry) { |
3400 HttpRequestInfo request; | 3400 HttpRequestInfo request; |
3401 request.method = "GET"; | 3401 request.method = "GET"; |
3402 request.url = GURL("http://www.google.com/"); | 3402 request.url = GURL("http://www.google.com/"); |
3403 // when the no authentication data flag is set. | 3403 // when the no authentication data flag is set. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3441 | 3441 |
3442 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3442 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
3443 data_writes1, arraysize(data_writes1)); | 3443 data_writes1, arraysize(data_writes1)); |
3444 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 3444 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
3445 SSLSocketDataProvider ssl(ASYNC, OK); | 3445 SSLSocketDataProvider ssl(ASYNC, OK); |
3446 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 3446 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
3447 | 3447 |
3448 TestCompletionCallback callback1; | 3448 TestCompletionCallback callback1; |
3449 | 3449 |
3450 scoped_ptr<HttpTransaction> trans( | 3450 scoped_ptr<HttpTransaction> trans( |
3451 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3451 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3452 | 3452 |
3453 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 3453 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
3454 EXPECT_EQ(ERR_IO_PENDING, rv); | 3454 EXPECT_EQ(ERR_IO_PENDING, rv); |
3455 | 3455 |
3456 rv = callback1.WaitForResult(); | 3456 rv = callback1.WaitForResult(); |
3457 EXPECT_EQ(OK, rv); | 3457 EXPECT_EQ(OK, rv); |
3458 | 3458 |
3459 LoadTimingInfo load_timing_info; | 3459 LoadTimingInfo load_timing_info; |
3460 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3460 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3461 TestLoadTimingNotReused(load_timing_info, | 3461 TestLoadTimingNotReused(load_timing_info, |
3462 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 3462 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
3463 | 3463 |
3464 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3464 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3465 ASSERT_TRUE(response != NULL); | 3465 ASSERT_TRUE(response != NULL); |
3466 ASSERT_FALSE(response->headers == NULL); | 3466 ASSERT_FALSE(response->headers.get() == NULL); |
3467 EXPECT_EQ(407, response->headers->response_code()); | 3467 EXPECT_EQ(407, response->headers->response_code()); |
3468 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 3468 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
3469 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 3469 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
3470 | 3470 |
3471 TestCompletionCallback callback2; | 3471 TestCompletionCallback callback2; |
3472 | 3472 |
3473 rv = trans->RestartWithAuth( | 3473 rv = trans->RestartWithAuth( |
3474 AuthCredentials(kFoo, kBar), callback2.callback()); | 3474 AuthCredentials(kFoo, kBar), callback2.callback()); |
3475 EXPECT_EQ(ERR_IO_PENDING, rv); | 3475 EXPECT_EQ(ERR_IO_PENDING, rv); |
3476 | 3476 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3520 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 3520 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
3521 }; | 3521 }; |
3522 | 3522 |
3523 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 3523 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
3524 data_writes, arraysize(data_writes)); | 3524 data_writes, arraysize(data_writes)); |
3525 session_deps_.socket_factory->AddSocketDataProvider(&data); | 3525 session_deps_.socket_factory->AddSocketDataProvider(&data); |
3526 | 3526 |
3527 TestCompletionCallback callback; | 3527 TestCompletionCallback callback; |
3528 | 3528 |
3529 scoped_ptr<HttpTransaction> trans( | 3529 scoped_ptr<HttpTransaction> trans( |
3530 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3530 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3531 | 3531 |
3532 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3532 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
3533 EXPECT_EQ(ERR_IO_PENDING, rv); | 3533 EXPECT_EQ(ERR_IO_PENDING, rv); |
3534 | 3534 |
3535 rv = callback.WaitForResult(); | 3535 rv = callback.WaitForResult(); |
3536 EXPECT_EQ(expected_status, rv); | 3536 EXPECT_EQ(expected_status, rv); |
3537 } | 3537 } |
3538 | 3538 |
3539 void HttpNetworkTransactionSpdy3Test::ConnectStatusHelper( | 3539 void HttpNetworkTransactionSpdy3Test::ConnectStatusHelper( |
3540 const MockRead& status) { | 3540 const MockRead& status) { |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3916 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
3917 data_writes1, arraysize(data_writes1)); | 3917 data_writes1, arraysize(data_writes1)); |
3918 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3918 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
3919 data_writes2, arraysize(data_writes2)); | 3919 data_writes2, arraysize(data_writes2)); |
3920 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 3920 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
3921 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 3921 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
3922 | 3922 |
3923 TestCompletionCallback callback1; | 3923 TestCompletionCallback callback1; |
3924 | 3924 |
3925 scoped_ptr<HttpTransaction> trans( | 3925 scoped_ptr<HttpTransaction> trans( |
3926 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3926 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3927 | 3927 |
3928 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 3928 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
3929 EXPECT_EQ(ERR_IO_PENDING, rv); | 3929 EXPECT_EQ(ERR_IO_PENDING, rv); |
3930 | 3930 |
3931 rv = callback1.WaitForResult(); | 3931 rv = callback1.WaitForResult(); |
3932 EXPECT_EQ(OK, rv); | 3932 EXPECT_EQ(OK, rv); |
3933 | 3933 |
3934 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3934 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3935 | 3935 |
3936 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3936 const HttpResponseInfo* response = trans->GetResponseInfo(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 data_writes2, arraysize(data_writes2)); | 4096 data_writes2, arraysize(data_writes2)); |
4097 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 4097 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
4098 data_writes3, arraysize(data_writes3)); | 4098 data_writes3, arraysize(data_writes3)); |
4099 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 4099 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
4100 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 4100 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
4101 session_deps_.socket_factory->AddSocketDataProvider(&data3); | 4101 session_deps_.socket_factory->AddSocketDataProvider(&data3); |
4102 | 4102 |
4103 TestCompletionCallback callback1; | 4103 TestCompletionCallback callback1; |
4104 | 4104 |
4105 scoped_ptr<HttpTransaction> trans( | 4105 scoped_ptr<HttpTransaction> trans( |
4106 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4106 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4107 | 4107 |
4108 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4108 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
4109 EXPECT_EQ(ERR_IO_PENDING, rv); | 4109 EXPECT_EQ(ERR_IO_PENDING, rv); |
4110 | 4110 |
4111 rv = callback1.WaitForResult(); | 4111 rv = callback1.WaitForResult(); |
4112 EXPECT_EQ(OK, rv); | 4112 EXPECT_EQ(OK, rv); |
4113 | 4113 |
4114 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 4114 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
4115 | 4115 |
4116 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4116 const HttpResponseInfo* response = trans->GetResponseInfo(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4213 request.method = "GET"; | 4213 request.method = "GET"; |
4214 request.url = GURL("https://www.google.com/"); | 4214 request.url = GURL("https://www.google.com/"); |
4215 request.load_flags = 0; | 4215 request.load_flags = 0; |
4216 | 4216 |
4217 // Configure against proxy server "myproxy:70". | 4217 // Configure against proxy server "myproxy:70". |
4218 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); | 4218 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); |
4219 | 4219 |
4220 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4220 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4221 | 4221 |
4222 scoped_ptr<HttpTransaction> trans( | 4222 scoped_ptr<HttpTransaction> trans( |
4223 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4223 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4224 | 4224 |
4225 // Since we have proxy, should try to establish tunnel. | 4225 // Since we have proxy, should try to establish tunnel. |
4226 MockWrite data_writes1[] = { | 4226 MockWrite data_writes1[] = { |
4227 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4227 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
4228 "Host: www.google.com\r\n" | 4228 "Host: www.google.com\r\n" |
4229 "Proxy-Connection: keep-alive\r\n\r\n"), | 4229 "Proxy-Connection: keep-alive\r\n\r\n"), |
4230 }; | 4230 }; |
4231 | 4231 |
4232 // The proxy responds to the connect with a 404, using a persistent | 4232 // The proxy responds to the connect with a 404, using a persistent |
4233 // connection. Usually a proxy would return 501 (not implemented), | 4233 // connection. Usually a proxy would return 501 (not implemented), |
(...skipping 18 matching lines...) Expand all Loading... |
4252 | 4252 |
4253 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4253 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4254 EXPECT_TRUE(response == NULL); | 4254 EXPECT_TRUE(response == NULL); |
4255 | 4255 |
4256 // Empty the current queue. This is necessary because idle sockets are | 4256 // Empty the current queue. This is necessary because idle sockets are |
4257 // added to the connection pool asynchronously with a PostTask. | 4257 // added to the connection pool asynchronously with a PostTask. |
4258 base::MessageLoop::current()->RunUntilIdle(); | 4258 base::MessageLoop::current()->RunUntilIdle(); |
4259 | 4259 |
4260 // We now check to make sure the TCPClientSocket was not added back to | 4260 // We now check to make sure the TCPClientSocket was not added back to |
4261 // the pool. | 4261 // the pool. |
4262 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4262 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4263 trans.reset(); | 4263 trans.reset(); |
4264 base::MessageLoop::current()->RunUntilIdle(); | 4264 base::MessageLoop::current()->RunUntilIdle(); |
4265 // Make sure that the socket didn't get recycled after calling the destructor. | 4265 // Make sure that the socket didn't get recycled after calling the destructor. |
4266 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4266 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4267 } | 4267 } |
4268 | 4268 |
4269 // Make sure that we recycle a socket after reading all of the response body. | 4269 // Make sure that we recycle a socket after reading all of the response body. |
4270 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleSocket) { | 4270 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleSocket) { |
4271 HttpRequestInfo request; | 4271 HttpRequestInfo request; |
4272 request.method = "GET"; | 4272 request.method = "GET"; |
4273 request.url = GURL("http://www.google.com/"); | 4273 request.url = GURL("http://www.google.com/"); |
4274 request.load_flags = 0; | 4274 request.load_flags = 0; |
4275 | 4275 |
4276 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4276 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4277 | 4277 |
4278 scoped_ptr<HttpTransaction> trans( | 4278 scoped_ptr<HttpTransaction> trans( |
4279 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4279 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4280 | 4280 |
4281 MockRead data_reads[] = { | 4281 MockRead data_reads[] = { |
4282 // A part of the response body is received with the response headers. | 4282 // A part of the response body is received with the response headers. |
4283 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), | 4283 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), |
4284 // The rest of the response body is received in two parts. | 4284 // The rest of the response body is received in two parts. |
4285 MockRead("lo"), | 4285 MockRead("lo"), |
4286 MockRead(" world"), | 4286 MockRead(" world"), |
4287 MockRead("junk"), // Should not be read!! | 4287 MockRead("junk"), // Should not be read!! |
4288 MockRead(SYNCHRONOUS, OK), | 4288 MockRead(SYNCHRONOUS, OK), |
4289 }; | 4289 }; |
4290 | 4290 |
4291 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 4291 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
4292 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4292 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4293 | 4293 |
4294 TestCompletionCallback callback; | 4294 TestCompletionCallback callback; |
4295 | 4295 |
4296 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4296 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4297 EXPECT_EQ(ERR_IO_PENDING, rv); | 4297 EXPECT_EQ(ERR_IO_PENDING, rv); |
4298 | 4298 |
4299 rv = callback.WaitForResult(); | 4299 rv = callback.WaitForResult(); |
4300 EXPECT_EQ(OK, rv); | 4300 EXPECT_EQ(OK, rv); |
4301 | 4301 |
4302 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4302 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4303 ASSERT_TRUE(response != NULL); | 4303 ASSERT_TRUE(response != NULL); |
4304 | 4304 |
4305 EXPECT_TRUE(response->headers != NULL); | 4305 EXPECT_TRUE(response->headers.get() != NULL); |
4306 std::string status_line = response->headers->GetStatusLine(); | 4306 std::string status_line = response->headers->GetStatusLine(); |
4307 EXPECT_EQ("HTTP/1.1 200 OK", status_line); | 4307 EXPECT_EQ("HTTP/1.1 200 OK", status_line); |
4308 | 4308 |
4309 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4309 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4310 | 4310 |
4311 std::string response_data; | 4311 std::string response_data; |
4312 rv = ReadTransaction(trans.get(), &response_data); | 4312 rv = ReadTransaction(trans.get(), &response_data); |
4313 EXPECT_EQ(OK, rv); | 4313 EXPECT_EQ(OK, rv); |
4314 EXPECT_EQ("hello world", response_data); | 4314 EXPECT_EQ("hello world", response_data); |
4315 | 4315 |
4316 // Empty the current queue. This is necessary because idle sockets are | 4316 // Empty the current queue. This is necessary because idle sockets are |
4317 // added to the connection pool asynchronously with a PostTask. | 4317 // added to the connection pool asynchronously with a PostTask. |
4318 base::MessageLoop::current()->RunUntilIdle(); | 4318 base::MessageLoop::current()->RunUntilIdle(); |
4319 | 4319 |
4320 // We now check to make sure the socket was added back to the pool. | 4320 // We now check to make sure the socket was added back to the pool. |
4321 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); | 4321 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
4322 } | 4322 } |
4323 | 4323 |
4324 // Make sure that we recycle a SSL socket after reading all of the response | 4324 // Make sure that we recycle a SSL socket after reading all of the response |
4325 // body. | 4325 // body. |
4326 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleSSLSocket) { | 4326 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleSSLSocket) { |
4327 HttpRequestInfo request; | 4327 HttpRequestInfo request; |
4328 request.method = "GET"; | 4328 request.method = "GET"; |
4329 request.url = GURL("https://www.google.com/"); | 4329 request.url = GURL("https://www.google.com/"); |
4330 request.load_flags = 0; | 4330 request.load_flags = 0; |
4331 | 4331 |
(...skipping 14 matching lines...) Expand all Loading... |
4346 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 4346 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
4347 | 4347 |
4348 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4348 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
4349 data_writes, arraysize(data_writes)); | 4349 data_writes, arraysize(data_writes)); |
4350 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4350 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4351 | 4351 |
4352 TestCompletionCallback callback; | 4352 TestCompletionCallback callback; |
4353 | 4353 |
4354 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4354 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4355 scoped_ptr<HttpTransaction> trans( | 4355 scoped_ptr<HttpTransaction> trans( |
4356 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4356 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4357 | 4357 |
4358 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4358 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4359 | 4359 |
4360 EXPECT_EQ(ERR_IO_PENDING, rv); | 4360 EXPECT_EQ(ERR_IO_PENDING, rv); |
4361 EXPECT_EQ(OK, callback.WaitForResult()); | 4361 EXPECT_EQ(OK, callback.WaitForResult()); |
4362 | 4362 |
4363 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4363 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4364 ASSERT_TRUE(response != NULL); | 4364 ASSERT_TRUE(response != NULL); |
4365 ASSERT_TRUE(response->headers != NULL); | 4365 ASSERT_TRUE(response->headers.get() != NULL); |
4366 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4366 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4367 | 4367 |
4368 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4368 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4369 | 4369 |
4370 std::string response_data; | 4370 std::string response_data; |
4371 rv = ReadTransaction(trans.get(), &response_data); | 4371 rv = ReadTransaction(trans.get(), &response_data); |
4372 EXPECT_EQ(OK, rv); | 4372 EXPECT_EQ(OK, rv); |
4373 EXPECT_EQ("hello world", response_data); | 4373 EXPECT_EQ("hello world", response_data); |
4374 | 4374 |
4375 // Empty the current queue. This is necessary because idle sockets are | 4375 // Empty the current queue. This is necessary because idle sockets are |
4376 // added to the connection pool asynchronously with a PostTask. | 4376 // added to the connection pool asynchronously with a PostTask. |
4377 base::MessageLoop::current()->RunUntilIdle(); | 4377 base::MessageLoop::current()->RunUntilIdle(); |
4378 | 4378 |
4379 // We now check to make sure the socket was added back to the pool. | 4379 // We now check to make sure the socket was added back to the pool. |
4380 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); | 4380 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
4381 } | 4381 } |
4382 | 4382 |
4383 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it | 4383 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it |
4384 // from the pool and make sure that we recover okay. | 4384 // from the pool and make sure that we recover okay. |
4385 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleDeadSSLSocket) { | 4385 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleDeadSSLSocket) { |
4386 HttpRequestInfo request; | 4386 HttpRequestInfo request; |
4387 request.method = "GET"; | 4387 request.method = "GET"; |
4388 request.url = GURL("https://www.google.com/"); | 4388 request.url = GURL("https://www.google.com/"); |
4389 request.load_flags = 0; | 4389 request.load_flags = 0; |
4390 | 4390 |
(...skipping 23 matching lines...) Expand all Loading... |
4414 data_writes, arraysize(data_writes)); | 4414 data_writes, arraysize(data_writes)); |
4415 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), | 4415 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), |
4416 data_writes, arraysize(data_writes)); | 4416 data_writes, arraysize(data_writes)); |
4417 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4417 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4418 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 4418 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
4419 | 4419 |
4420 TestCompletionCallback callback; | 4420 TestCompletionCallback callback; |
4421 | 4421 |
4422 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4422 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4423 scoped_ptr<HttpTransaction> trans( | 4423 scoped_ptr<HttpTransaction> trans( |
4424 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4424 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4425 | 4425 |
4426 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4426 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4427 | 4427 |
4428 EXPECT_EQ(ERR_IO_PENDING, rv); | 4428 EXPECT_EQ(ERR_IO_PENDING, rv); |
4429 EXPECT_EQ(OK, callback.WaitForResult()); | 4429 EXPECT_EQ(OK, callback.WaitForResult()); |
4430 | 4430 |
4431 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4431 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4432 ASSERT_TRUE(response != NULL); | 4432 ASSERT_TRUE(response != NULL); |
4433 ASSERT_TRUE(response->headers != NULL); | 4433 ASSERT_TRUE(response->headers.get() != NULL); |
4434 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4434 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4435 | 4435 |
4436 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4436 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4437 | 4437 |
4438 std::string response_data; | 4438 std::string response_data; |
4439 rv = ReadTransaction(trans.get(), &response_data); | 4439 rv = ReadTransaction(trans.get(), &response_data); |
4440 EXPECT_EQ(OK, rv); | 4440 EXPECT_EQ(OK, rv); |
4441 EXPECT_EQ("hello world", response_data); | 4441 EXPECT_EQ("hello world", response_data); |
4442 | 4442 |
4443 // Empty the current queue. This is necessary because idle sockets are | 4443 // Empty the current queue. This is necessary because idle sockets are |
4444 // added to the connection pool asynchronously with a PostTask. | 4444 // added to the connection pool asynchronously with a PostTask. |
4445 base::MessageLoop::current()->RunUntilIdle(); | 4445 base::MessageLoop::current()->RunUntilIdle(); |
4446 | 4446 |
4447 // We now check to make sure the socket was added back to the pool. | 4447 // We now check to make sure the socket was added back to the pool. |
4448 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); | 4448 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
4449 | 4449 |
4450 // Now start the second transaction, which should reuse the previous socket. | 4450 // Now start the second transaction, which should reuse the previous socket. |
4451 | 4451 |
4452 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4452 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4453 | 4453 |
4454 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4454 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4455 | 4455 |
4456 EXPECT_EQ(ERR_IO_PENDING, rv); | 4456 EXPECT_EQ(ERR_IO_PENDING, rv); |
4457 EXPECT_EQ(OK, callback.WaitForResult()); | 4457 EXPECT_EQ(OK, callback.WaitForResult()); |
4458 | 4458 |
4459 response = trans->GetResponseInfo(); | 4459 response = trans->GetResponseInfo(); |
4460 ASSERT_TRUE(response != NULL); | 4460 ASSERT_TRUE(response != NULL); |
4461 ASSERT_TRUE(response->headers != NULL); | 4461 ASSERT_TRUE(response->headers.get() != NULL); |
4462 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4462 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4463 | 4463 |
4464 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4464 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4465 | 4465 |
4466 rv = ReadTransaction(trans.get(), &response_data); | 4466 rv = ReadTransaction(trans.get(), &response_data); |
4467 EXPECT_EQ(OK, rv); | 4467 EXPECT_EQ(OK, rv); |
4468 EXPECT_EQ("hello world", response_data); | 4468 EXPECT_EQ("hello world", response_data); |
4469 | 4469 |
4470 // Empty the current queue. This is necessary because idle sockets are | 4470 // Empty the current queue. This is necessary because idle sockets are |
4471 // added to the connection pool asynchronously with a PostTask. | 4471 // added to the connection pool asynchronously with a PostTask. |
4472 base::MessageLoop::current()->RunUntilIdle(); | 4472 base::MessageLoop::current()->RunUntilIdle(); |
4473 | 4473 |
4474 // We now check to make sure the socket was added back to the pool. | 4474 // We now check to make sure the socket was added back to the pool. |
4475 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); | 4475 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
4476 } | 4476 } |
4477 | 4477 |
4478 // Make sure that we recycle a socket after a zero-length response. | 4478 // Make sure that we recycle a socket after a zero-length response. |
4479 // http://crbug.com/9880 | 4479 // http://crbug.com/9880 |
4480 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleSocketAfterZeroContentLength) { | 4480 TEST_F(HttpNetworkTransactionSpdy3Test, RecycleSocketAfterZeroContentLength) { |
4481 HttpRequestInfo request; | 4481 HttpRequestInfo request; |
4482 request.method = "GET"; | 4482 request.method = "GET"; |
4483 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" | 4483 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" |
4484 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" | 4484 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" |
4485 "e=17259,18167,19592,19773,19981,20133,20173,20233&" | 4485 "e=17259,18167,19592,19773,19981,20133,20173,20233&" |
4486 "rt=prt.2642,ol.2649,xjs.2951"); | 4486 "rt=prt.2642,ol.2649,xjs.2951"); |
4487 request.load_flags = 0; | 4487 request.load_flags = 0; |
4488 | 4488 |
4489 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4489 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4490 | 4490 |
4491 scoped_ptr<HttpTransaction> trans( | 4491 scoped_ptr<HttpTransaction> trans( |
4492 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4492 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4493 | 4493 |
4494 MockRead data_reads[] = { | 4494 MockRead data_reads[] = { |
4495 MockRead("HTTP/1.1 204 No Content\r\n" | 4495 MockRead("HTTP/1.1 204 No Content\r\n" |
4496 "Content-Length: 0\r\n" | 4496 "Content-Length: 0\r\n" |
4497 "Content-Type: text/html\r\n\r\n"), | 4497 "Content-Type: text/html\r\n\r\n"), |
4498 MockRead("junk"), // Should not be read!! | 4498 MockRead("junk"), // Should not be read!! |
4499 MockRead(SYNCHRONOUS, OK), | 4499 MockRead(SYNCHRONOUS, OK), |
4500 }; | 4500 }; |
4501 | 4501 |
4502 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 4502 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
4503 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4503 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4504 | 4504 |
4505 TestCompletionCallback callback; | 4505 TestCompletionCallback callback; |
4506 | 4506 |
4507 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4507 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4508 EXPECT_EQ(ERR_IO_PENDING, rv); | 4508 EXPECT_EQ(ERR_IO_PENDING, rv); |
4509 | 4509 |
4510 rv = callback.WaitForResult(); | 4510 rv = callback.WaitForResult(); |
4511 EXPECT_EQ(OK, rv); | 4511 EXPECT_EQ(OK, rv); |
4512 | 4512 |
4513 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4513 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4514 ASSERT_TRUE(response != NULL); | 4514 ASSERT_TRUE(response != NULL); |
4515 | 4515 |
4516 EXPECT_TRUE(response->headers != NULL); | 4516 EXPECT_TRUE(response->headers.get() != NULL); |
4517 std::string status_line = response->headers->GetStatusLine(); | 4517 std::string status_line = response->headers->GetStatusLine(); |
4518 EXPECT_EQ("HTTP/1.1 204 No Content", status_line); | 4518 EXPECT_EQ("HTTP/1.1 204 No Content", status_line); |
4519 | 4519 |
4520 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4520 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4521 | 4521 |
4522 std::string response_data; | 4522 std::string response_data; |
4523 rv = ReadTransaction(trans.get(), &response_data); | 4523 rv = ReadTransaction(trans.get(), &response_data); |
4524 EXPECT_EQ(OK, rv); | 4524 EXPECT_EQ(OK, rv); |
4525 EXPECT_EQ("", response_data); | 4525 EXPECT_EQ("", response_data); |
4526 | 4526 |
4527 // Empty the current queue. This is necessary because idle sockets are | 4527 // Empty the current queue. This is necessary because idle sockets are |
4528 // added to the connection pool asynchronously with a PostTask. | 4528 // added to the connection pool asynchronously with a PostTask. |
4529 base::MessageLoop::current()->RunUntilIdle(); | 4529 base::MessageLoop::current()->RunUntilIdle(); |
4530 | 4530 |
4531 // We now check to make sure the socket was added back to the pool. | 4531 // We now check to make sure the socket was added back to the pool. |
4532 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); | 4532 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
4533 } | 4533 } |
4534 | 4534 |
4535 TEST_F(HttpNetworkTransactionSpdy3Test, ResendRequestOnWriteBodyError) { | 4535 TEST_F(HttpNetworkTransactionSpdy3Test, ResendRequestOnWriteBodyError) { |
4536 ScopedVector<UploadElementReader> element_readers; | 4536 ScopedVector<UploadElementReader> element_readers; |
4537 element_readers.push_back(new UploadBytesElementReader("foo", 3)); | 4537 element_readers.push_back(new UploadBytesElementReader("foo", 3)); |
4538 UploadDataStream upload_data_stream(&element_readers, 0); | 4538 UploadDataStream upload_data_stream(&element_readers, 0); |
4539 | 4539 |
4540 HttpRequestInfo request[2]; | 4540 HttpRequestInfo request[2]; |
4541 // Transaction 1: a GET request that succeeds. The socket is recycled | 4541 // Transaction 1: a GET request that succeeds. The socket is recycled |
4542 // after use. | 4542 // after use. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4591 | 4591 |
4592 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 4592 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
4593 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 4593 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
4594 | 4594 |
4595 const char* kExpectedResponseData[] = { | 4595 const char* kExpectedResponseData[] = { |
4596 "hello world", "welcome" | 4596 "hello world", "welcome" |
4597 }; | 4597 }; |
4598 | 4598 |
4599 for (int i = 0; i < 2; ++i) { | 4599 for (int i = 0; i < 2; ++i) { |
4600 scoped_ptr<HttpTransaction> trans( | 4600 scoped_ptr<HttpTransaction> trans( |
4601 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4601 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4602 | 4602 |
4603 TestCompletionCallback callback; | 4603 TestCompletionCallback callback; |
4604 | 4604 |
4605 int rv = trans->Start(&request[i], callback.callback(), BoundNetLog()); | 4605 int rv = trans->Start(&request[i], callback.callback(), BoundNetLog()); |
4606 EXPECT_EQ(ERR_IO_PENDING, rv); | 4606 EXPECT_EQ(ERR_IO_PENDING, rv); |
4607 | 4607 |
4608 rv = callback.WaitForResult(); | 4608 rv = callback.WaitForResult(); |
4609 EXPECT_EQ(OK, rv); | 4609 EXPECT_EQ(OK, rv); |
4610 | 4610 |
4611 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4611 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4612 ASSERT_TRUE(response != NULL); | 4612 ASSERT_TRUE(response != NULL); |
4613 | 4613 |
4614 EXPECT_TRUE(response->headers != NULL); | 4614 EXPECT_TRUE(response->headers.get() != NULL); |
4615 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4615 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4616 | 4616 |
4617 std::string response_data; | 4617 std::string response_data; |
4618 rv = ReadTransaction(trans.get(), &response_data); | 4618 rv = ReadTransaction(trans.get(), &response_data); |
4619 EXPECT_EQ(OK, rv); | 4619 EXPECT_EQ(OK, rv); |
4620 EXPECT_EQ(kExpectedResponseData[i], response_data); | 4620 EXPECT_EQ(kExpectedResponseData[i], response_data); |
4621 } | 4621 } |
4622 } | 4622 } |
4623 | 4623 |
4624 // Test the request-challenge-retry sequence for basic auth when there is | 4624 // Test the request-challenge-retry sequence for basic auth when there is |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4814 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4814 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4815 | 4815 |
4816 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 4816 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
4817 { | 4817 { |
4818 HttpRequestInfo request; | 4818 HttpRequestInfo request; |
4819 request.method = "GET"; | 4819 request.method = "GET"; |
4820 request.url = GURL("http://www.google.com/x/y/z"); | 4820 request.url = GURL("http://www.google.com/x/y/z"); |
4821 request.load_flags = 0; | 4821 request.load_flags = 0; |
4822 | 4822 |
4823 scoped_ptr<HttpTransaction> trans( | 4823 scoped_ptr<HttpTransaction> trans( |
4824 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4824 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4825 | 4825 |
4826 MockWrite data_writes1[] = { | 4826 MockWrite data_writes1[] = { |
4827 MockWrite("GET /x/y/z HTTP/1.1\r\n" | 4827 MockWrite("GET /x/y/z HTTP/1.1\r\n" |
4828 "Host: www.google.com\r\n" | 4828 "Host: www.google.com\r\n" |
4829 "Connection: keep-alive\r\n\r\n"), | 4829 "Connection: keep-alive\r\n\r\n"), |
4830 }; | 4830 }; |
4831 | 4831 |
4832 MockRead data_reads1[] = { | 4832 MockRead data_reads1[] = { |
4833 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 4833 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
4834 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 4834 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4890 // Transaction 2: authenticate (foo2, bar2) on MyRealm2 | 4890 // Transaction 2: authenticate (foo2, bar2) on MyRealm2 |
4891 { | 4891 { |
4892 HttpRequestInfo request; | 4892 HttpRequestInfo request; |
4893 request.method = "GET"; | 4893 request.method = "GET"; |
4894 // Note that Transaction 1 was at /x/y/z, so this is in the same | 4894 // Note that Transaction 1 was at /x/y/z, so this is in the same |
4895 // protection space as MyRealm1. | 4895 // protection space as MyRealm1. |
4896 request.url = GURL("http://www.google.com/x/y/a/b"); | 4896 request.url = GURL("http://www.google.com/x/y/a/b"); |
4897 request.load_flags = 0; | 4897 request.load_flags = 0; |
4898 | 4898 |
4899 scoped_ptr<HttpTransaction> trans( | 4899 scoped_ptr<HttpTransaction> trans( |
4900 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4900 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4901 | 4901 |
4902 MockWrite data_writes1[] = { | 4902 MockWrite data_writes1[] = { |
4903 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" | 4903 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" |
4904 "Host: www.google.com\r\n" | 4904 "Host: www.google.com\r\n" |
4905 "Connection: keep-alive\r\n" | 4905 "Connection: keep-alive\r\n" |
4906 // Send preemptive authorization for MyRealm1 | 4906 // Send preemptive authorization for MyRealm1 |
4907 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 4907 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
4908 }; | 4908 }; |
4909 | 4909 |
4910 // The server didn't like the preemptive authorization, and | 4910 // The server didn't like the preemptive authorization, and |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4974 | 4974 |
4975 // Transaction 3: Resend a request in MyRealm's protection space -- | 4975 // Transaction 3: Resend a request in MyRealm's protection space -- |
4976 // succeed with preemptive authorization. | 4976 // succeed with preemptive authorization. |
4977 { | 4977 { |
4978 HttpRequestInfo request; | 4978 HttpRequestInfo request; |
4979 request.method = "GET"; | 4979 request.method = "GET"; |
4980 request.url = GURL("http://www.google.com/x/y/z2"); | 4980 request.url = GURL("http://www.google.com/x/y/z2"); |
4981 request.load_flags = 0; | 4981 request.load_flags = 0; |
4982 | 4982 |
4983 scoped_ptr<HttpTransaction> trans( | 4983 scoped_ptr<HttpTransaction> trans( |
4984 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4984 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4985 | 4985 |
4986 MockWrite data_writes1[] = { | 4986 MockWrite data_writes1[] = { |
4987 MockWrite("GET /x/y/z2 HTTP/1.1\r\n" | 4987 MockWrite("GET /x/y/z2 HTTP/1.1\r\n" |
4988 "Host: www.google.com\r\n" | 4988 "Host: www.google.com\r\n" |
4989 "Connection: keep-alive\r\n" | 4989 "Connection: keep-alive\r\n" |
4990 // The authorization for MyRealm1 gets sent preemptively | 4990 // The authorization for MyRealm1 gets sent preemptively |
4991 // (since the url is in the same protection space) | 4991 // (since the url is in the same protection space) |
4992 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 4992 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
4993 }; | 4993 }; |
4994 | 4994 |
(...skipping 27 matching lines...) Expand all Loading... |
5022 | 5022 |
5023 // Transaction 4: request another URL in MyRealm (however the | 5023 // Transaction 4: request another URL in MyRealm (however the |
5024 // url is not known to belong to the protection space, so no pre-auth). | 5024 // url is not known to belong to the protection space, so no pre-auth). |
5025 { | 5025 { |
5026 HttpRequestInfo request; | 5026 HttpRequestInfo request; |
5027 request.method = "GET"; | 5027 request.method = "GET"; |
5028 request.url = GURL("http://www.google.com/x/1"); | 5028 request.url = GURL("http://www.google.com/x/1"); |
5029 request.load_flags = 0; | 5029 request.load_flags = 0; |
5030 | 5030 |
5031 scoped_ptr<HttpTransaction> trans( | 5031 scoped_ptr<HttpTransaction> trans( |
5032 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5032 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5033 | 5033 |
5034 MockWrite data_writes1[] = { | 5034 MockWrite data_writes1[] = { |
5035 MockWrite("GET /x/1 HTTP/1.1\r\n" | 5035 MockWrite("GET /x/1 HTTP/1.1\r\n" |
5036 "Host: www.google.com\r\n" | 5036 "Host: www.google.com\r\n" |
5037 "Connection: keep-alive\r\n\r\n"), | 5037 "Connection: keep-alive\r\n\r\n"), |
5038 }; | 5038 }; |
5039 | 5039 |
5040 MockRead data_reads1[] = { | 5040 MockRead data_reads1[] = { |
5041 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 5041 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
5042 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 5042 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5092 | 5092 |
5093 // Transaction 5: request a URL in MyRealm, but the server rejects the | 5093 // Transaction 5: request a URL in MyRealm, but the server rejects the |
5094 // cached identity. Should invalidate and re-prompt. | 5094 // cached identity. Should invalidate and re-prompt. |
5095 { | 5095 { |
5096 HttpRequestInfo request; | 5096 HttpRequestInfo request; |
5097 request.method = "GET"; | 5097 request.method = "GET"; |
5098 request.url = GURL("http://www.google.com/p/q/t"); | 5098 request.url = GURL("http://www.google.com/p/q/t"); |
5099 request.load_flags = 0; | 5099 request.load_flags = 0; |
5100 | 5100 |
5101 scoped_ptr<HttpTransaction> trans( | 5101 scoped_ptr<HttpTransaction> trans( |
5102 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5102 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5103 | 5103 |
5104 MockWrite data_writes1[] = { | 5104 MockWrite data_writes1[] = { |
5105 MockWrite("GET /p/q/t HTTP/1.1\r\n" | 5105 MockWrite("GET /p/q/t HTTP/1.1\r\n" |
5106 "Host: www.google.com\r\n" | 5106 "Host: www.google.com\r\n" |
5107 "Connection: keep-alive\r\n\r\n"), | 5107 "Connection: keep-alive\r\n\r\n"), |
5108 }; | 5108 }; |
5109 | 5109 |
5110 MockRead data_reads1[] = { | 5110 MockRead data_reads1[] = { |
5111 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 5111 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
5112 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 5112 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5204 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 5204 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
5205 | 5205 |
5206 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 5206 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
5207 { | 5207 { |
5208 HttpRequestInfo request; | 5208 HttpRequestInfo request; |
5209 request.method = "GET"; | 5209 request.method = "GET"; |
5210 request.url = GURL("http://www.google.com/x/y/z"); | 5210 request.url = GURL("http://www.google.com/x/y/z"); |
5211 request.load_flags = 0; | 5211 request.load_flags = 0; |
5212 | 5212 |
5213 scoped_ptr<HttpTransaction> trans( | 5213 scoped_ptr<HttpTransaction> trans( |
5214 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5214 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5215 | 5215 |
5216 MockWrite data_writes1[] = { | 5216 MockWrite data_writes1[] = { |
5217 MockWrite("GET /x/y/z HTTP/1.1\r\n" | 5217 MockWrite("GET /x/y/z HTTP/1.1\r\n" |
5218 "Host: www.google.com\r\n" | 5218 "Host: www.google.com\r\n" |
5219 "Connection: keep-alive\r\n\r\n"), | 5219 "Connection: keep-alive\r\n\r\n"), |
5220 }; | 5220 }; |
5221 | 5221 |
5222 MockRead data_reads1[] = { | 5222 MockRead data_reads1[] = { |
5223 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 5223 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
5224 MockRead("WWW-Authenticate: Digest realm=\"digestive\", nonce=\"OU812\", " | 5224 MockRead("WWW-Authenticate: Digest realm=\"digestive\", nonce=\"OU812\", " |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5283 // "nc" value of 2 (as compared to 1 in the first use. | 5283 // "nc" value of 2 (as compared to 1 in the first use. |
5284 { | 5284 { |
5285 HttpRequestInfo request; | 5285 HttpRequestInfo request; |
5286 request.method = "GET"; | 5286 request.method = "GET"; |
5287 // Note that Transaction 1 was at /x/y/z, so this is in the same | 5287 // Note that Transaction 1 was at /x/y/z, so this is in the same |
5288 // protection space as digest. | 5288 // protection space as digest. |
5289 request.url = GURL("http://www.google.com/x/y/a/b"); | 5289 request.url = GURL("http://www.google.com/x/y/a/b"); |
5290 request.load_flags = 0; | 5290 request.load_flags = 0; |
5291 | 5291 |
5292 scoped_ptr<HttpTransaction> trans( | 5292 scoped_ptr<HttpTransaction> trans( |
5293 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5293 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5294 | 5294 |
5295 MockWrite data_writes1[] = { | 5295 MockWrite data_writes1[] = { |
5296 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" | 5296 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" |
5297 "Host: www.google.com\r\n" | 5297 "Host: www.google.com\r\n" |
5298 "Connection: keep-alive\r\n" | 5298 "Connection: keep-alive\r\n" |
5299 "Authorization: Digest username=\"foo\", realm=\"digestive\", " | 5299 "Authorization: Digest username=\"foo\", realm=\"digestive\", " |
5300 "nonce=\"OU812\", uri=\"/x/y/a/b\", algorithm=MD5, " | 5300 "nonce=\"OU812\", uri=\"/x/y/a/b\", algorithm=MD5, " |
5301 "response=\"d6f9a2c07d1c5df7b89379dca1269b35\", qop=auth, " | 5301 "response=\"d6f9a2c07d1c5df7b89379dca1269b35\", qop=auth, " |
5302 "nc=00000002, cnonce=\"0123456789abcdef\"\r\n\r\n"), | 5302 "nc=00000002, cnonce=\"0123456789abcdef\"\r\n\r\n"), |
5303 }; | 5303 }; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5346 response->response_time = base::Time::Now(); | 5346 response->response_time = base::Time::Now(); |
5347 response->was_cached = true; // (Wouldn't ever actually be true...) | 5347 response->was_cached = true; // (Wouldn't ever actually be true...) |
5348 | 5348 |
5349 { // Setup state for response_.vary_data | 5349 { // Setup state for response_.vary_data |
5350 HttpRequestInfo request; | 5350 HttpRequestInfo request; |
5351 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); | 5351 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); |
5352 std::replace(temp.begin(), temp.end(), '\n', '\0'); | 5352 std::replace(temp.begin(), temp.end(), '\n', '\0'); |
5353 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); | 5353 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); |
5354 request.extra_headers.SetHeader("Foo", "1"); | 5354 request.extra_headers.SetHeader("Foo", "1"); |
5355 request.extra_headers.SetHeader("bar", "23"); | 5355 request.extra_headers.SetHeader("bar", "23"); |
5356 EXPECT_TRUE(response->vary_data.Init(request, *headers)); | 5356 EXPECT_TRUE(response->vary_data.Init(request, *headers.get())); |
5357 } | 5357 } |
5358 | 5358 |
5359 // Cause the above state to be reset. | 5359 // Cause the above state to be reset. |
5360 trans->ResetStateForRestart(); | 5360 trans->ResetStateForRestart(); |
5361 | 5361 |
5362 // Verify that the state that needed to be reset, has been reset. | 5362 // Verify that the state that needed to be reset, has been reset. |
5363 EXPECT_TRUE(trans->read_buf_.get() == NULL); | 5363 EXPECT_TRUE(trans->read_buf_.get() == NULL); |
5364 EXPECT_EQ(0, trans->read_buf_len_); | 5364 EXPECT_EQ(0, trans->read_buf_len_); |
5365 EXPECT_TRUE(trans->request_headers_.IsEmpty()); | 5365 EXPECT_TRUE(trans->request_headers_.IsEmpty()); |
5366 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 5366 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5896 SSLSocketDataProvider proxy(ASYNC, OK); | 5896 SSLSocketDataProvider proxy(ASYNC, OK); |
5897 proxy.SetNextProto(kProtoSPDY3); | 5897 proxy.SetNextProto(kProtoSPDY3); |
5898 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); | 5898 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); |
5899 // Vanilla SSL to the server | 5899 // Vanilla SSL to the server |
5900 SSLSocketDataProvider server(ASYNC, OK); | 5900 SSLSocketDataProvider server(ASYNC, OK); |
5901 session_deps_.socket_factory->AddSSLSocketDataProvider(&server); | 5901 session_deps_.socket_factory->AddSSLSocketDataProvider(&server); |
5902 | 5902 |
5903 TestCompletionCallback callback1; | 5903 TestCompletionCallback callback1; |
5904 | 5904 |
5905 scoped_ptr<HttpTransaction> trans( | 5905 scoped_ptr<HttpTransaction> trans( |
5906 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5906 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5907 | 5907 |
5908 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 5908 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
5909 EXPECT_EQ(ERR_IO_PENDING, rv); | 5909 EXPECT_EQ(ERR_IO_PENDING, rv); |
5910 | 5910 |
5911 rv = callback1.WaitForResult(); | 5911 rv = callback1.WaitForResult(); |
5912 EXPECT_EQ(OK, rv); | 5912 EXPECT_EQ(OK, rv); |
5913 CapturingNetLog::CapturedEntryList entries; | 5913 CapturingNetLog::CapturedEntryList entries; |
5914 log.GetEntries(&entries); | 5914 log.GetEntries(&entries); |
5915 size_t pos = ExpectLogContainsSomewhere( | 5915 size_t pos = ExpectLogContainsSomewhere( |
5916 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 5916 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
5917 NetLog::PHASE_NONE); | 5917 NetLog::PHASE_NONE); |
5918 ExpectLogContainsSomewhere( | 5918 ExpectLogContainsSomewhere( |
5919 entries, pos, | 5919 entries, pos, |
5920 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 5920 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
5921 NetLog::PHASE_NONE); | 5921 NetLog::PHASE_NONE); |
5922 | 5922 |
5923 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5923 const HttpResponseInfo* response = trans->GetResponseInfo(); |
5924 ASSERT_TRUE(response != NULL); | 5924 ASSERT_TRUE(response != NULL); |
5925 ASSERT_FALSE(response->headers == NULL); | 5925 ASSERT_FALSE(response->headers.get() == NULL); |
5926 EXPECT_EQ(407, response->headers->response_code()); | 5926 EXPECT_EQ(407, response->headers->response_code()); |
5927 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 5927 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
5928 EXPECT_TRUE(response->auth_challenge.get() != NULL); | 5928 EXPECT_TRUE(response->auth_challenge.get() != NULL); |
5929 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 5929 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
5930 | 5930 |
5931 TestCompletionCallback callback2; | 5931 TestCompletionCallback callback2; |
5932 | 5932 |
5933 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), | 5933 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), |
5934 callback2.callback()); | 5934 callback2.callback()); |
5935 EXPECT_EQ(ERR_IO_PENDING, rv); | 5935 EXPECT_EQ(ERR_IO_PENDING, rv); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6017 OrderedSocketData spdy_data( | 6017 OrderedSocketData spdy_data( |
6018 spdy_reads, arraysize(spdy_reads), | 6018 spdy_reads, arraysize(spdy_reads), |
6019 spdy_writes, arraysize(spdy_writes)); | 6019 spdy_writes, arraysize(spdy_writes)); |
6020 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 6020 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
6021 // Negotiate SPDY to the proxy | 6021 // Negotiate SPDY to the proxy |
6022 SSLSocketDataProvider proxy(ASYNC, OK); | 6022 SSLSocketDataProvider proxy(ASYNC, OK); |
6023 proxy.SetNextProto(kProtoSPDY3); | 6023 proxy.SetNextProto(kProtoSPDY3); |
6024 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); | 6024 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); |
6025 | 6025 |
6026 scoped_ptr<HttpTransaction> trans( | 6026 scoped_ptr<HttpTransaction> trans( |
6027 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 6027 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
6028 TestCompletionCallback callback; | 6028 TestCompletionCallback callback; |
6029 int rv = trans->Start(&request, callback.callback(), log.bound()); | 6029 int rv = trans->Start(&request, callback.callback(), log.bound()); |
6030 EXPECT_EQ(ERR_IO_PENDING, rv); | 6030 EXPECT_EQ(ERR_IO_PENDING, rv); |
6031 | 6031 |
6032 rv = callback.WaitForResult(); | 6032 rv = callback.WaitForResult(); |
6033 EXPECT_EQ(OK, rv); | 6033 EXPECT_EQ(OK, rv); |
6034 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6034 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6035 | 6035 |
6036 scoped_ptr<HttpTransaction> push_trans( | 6036 scoped_ptr<HttpTransaction> push_trans( |
6037 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 6037 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
6038 rv = push_trans->Start(&push_request, callback.callback(), log.bound()); | 6038 rv = push_trans->Start(&push_request, callback.callback(), log.bound()); |
6039 EXPECT_EQ(ERR_IO_PENDING, rv); | 6039 EXPECT_EQ(ERR_IO_PENDING, rv); |
6040 | 6040 |
6041 rv = callback.WaitForResult(); | 6041 rv = callback.WaitForResult(); |
6042 EXPECT_EQ(OK, rv); | 6042 EXPECT_EQ(OK, rv); |
6043 const HttpResponseInfo* push_response = push_trans->GetResponseInfo(); | 6043 const HttpResponseInfo* push_response = push_trans->GetResponseInfo(); |
6044 | 6044 |
6045 ASSERT_TRUE(response != NULL); | 6045 ASSERT_TRUE(response != NULL); |
6046 EXPECT_TRUE(response->headers->IsKeepAlive()); | 6046 EXPECT_TRUE(response->headers->IsKeepAlive()); |
6047 | 6047 |
6048 EXPECT_EQ(200, response->headers->response_code()); | 6048 EXPECT_EQ(200, response->headers->response_code()); |
6049 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 6049 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
6050 | 6050 |
6051 std::string response_data; | 6051 std::string response_data; |
6052 rv = ReadTransaction(trans.get(), &response_data); | 6052 rv = ReadTransaction(trans.get(), &response_data); |
6053 EXPECT_EQ(OK, rv); | 6053 EXPECT_EQ(OK, rv); |
6054 EXPECT_EQ("hello!", response_data); | 6054 EXPECT_EQ("hello!", response_data); |
6055 | 6055 |
6056 LoadTimingInfo load_timing_info; | 6056 LoadTimingInfo load_timing_info; |
6057 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 6057 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
6058 TestLoadTimingNotReusedWithPac(load_timing_info, | 6058 TestLoadTimingNotReusedWithPac(load_timing_info, |
6059 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 6059 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
6060 | 6060 |
6061 // Verify the pushed stream. | 6061 // Verify the pushed stream. |
6062 EXPECT_TRUE(push_response->headers != NULL); | 6062 EXPECT_TRUE(push_response->headers.get() != NULL); |
6063 EXPECT_EQ(200, push_response->headers->response_code()); | 6063 EXPECT_EQ(200, push_response->headers->response_code()); |
6064 | 6064 |
6065 rv = ReadTransaction(push_trans.get(), &response_data); | 6065 rv = ReadTransaction(push_trans.get(), &response_data); |
6066 EXPECT_EQ(OK, rv); | 6066 EXPECT_EQ(OK, rv); |
6067 EXPECT_EQ("pushed", response_data); | 6067 EXPECT_EQ("pushed", response_data); |
6068 | 6068 |
6069 LoadTimingInfo push_load_timing_info; | 6069 LoadTimingInfo push_load_timing_info; |
6070 EXPECT_TRUE(push_trans->GetLoadTimingInfo(&push_load_timing_info)); | 6070 EXPECT_TRUE(push_trans->GetLoadTimingInfo(&push_load_timing_info)); |
6071 TestLoadTimingReusedWithPac(push_load_timing_info); | 6071 TestLoadTimingReusedWithPac(push_load_timing_info); |
6072 // The transactions should share a socket ID, despite being for different | 6072 // The transactions should share a socket ID, despite being for different |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6131 OrderedSocketData spdy_data( | 6131 OrderedSocketData spdy_data( |
6132 spdy_reads, arraysize(spdy_reads), | 6132 spdy_reads, arraysize(spdy_reads), |
6133 spdy_writes, arraysize(spdy_writes)); | 6133 spdy_writes, arraysize(spdy_writes)); |
6134 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 6134 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
6135 // Negotiate SPDY to the proxy | 6135 // Negotiate SPDY to the proxy |
6136 SSLSocketDataProvider proxy(ASYNC, OK); | 6136 SSLSocketDataProvider proxy(ASYNC, OK); |
6137 proxy.SetNextProto(kProtoSPDY3); | 6137 proxy.SetNextProto(kProtoSPDY3); |
6138 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); | 6138 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); |
6139 | 6139 |
6140 scoped_ptr<HttpTransaction> trans( | 6140 scoped_ptr<HttpTransaction> trans( |
6141 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 6141 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
6142 TestCompletionCallback callback; | 6142 TestCompletionCallback callback; |
6143 int rv = trans->Start(&request, callback.callback(), log.bound()); | 6143 int rv = trans->Start(&request, callback.callback(), log.bound()); |
6144 EXPECT_EQ(ERR_IO_PENDING, rv); | 6144 EXPECT_EQ(ERR_IO_PENDING, rv); |
6145 | 6145 |
6146 rv = callback.WaitForResult(); | 6146 rv = callback.WaitForResult(); |
6147 EXPECT_EQ(OK, rv); | 6147 EXPECT_EQ(OK, rv); |
6148 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6148 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6149 | 6149 |
6150 ASSERT_TRUE(response != NULL); | 6150 ASSERT_TRUE(response != NULL); |
6151 EXPECT_TRUE(response->headers->IsKeepAlive()); | 6151 EXPECT_TRUE(response->headers->IsKeepAlive()); |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6991 | 6991 |
6992 int GroupNameTransactionHelper( | 6992 int GroupNameTransactionHelper( |
6993 const std::string& url, | 6993 const std::string& url, |
6994 const scoped_refptr<HttpNetworkSession>& session) { | 6994 const scoped_refptr<HttpNetworkSession>& session) { |
6995 HttpRequestInfo request; | 6995 HttpRequestInfo request; |
6996 request.method = "GET"; | 6996 request.method = "GET"; |
6997 request.url = GURL(url); | 6997 request.url = GURL(url); |
6998 request.load_flags = 0; | 6998 request.load_flags = 0; |
6999 | 6999 |
7000 scoped_ptr<HttpTransaction> trans( | 7000 scoped_ptr<HttpTransaction> trans( |
7001 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7001 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7002 | 7002 |
7003 TestCompletionCallback callback; | 7003 TestCompletionCallback callback; |
7004 | 7004 |
7005 // We do not complete this request, the dtor will clean the transaction up. | 7005 // We do not complete this request, the dtor will clean the transaction up. |
7006 return trans->Start(&request, callback.callback(), BoundNetLog()); | 7006 return trans->Start(&request, callback.callback(), BoundNetLog()); |
7007 } | 7007 } |
7008 | 7008 |
7009 } // namespace | 7009 } // namespace |
7010 | 7010 |
7011 TEST_F(HttpNetworkTransactionSpdy3Test, GroupNameForDirectConnections) { | 7011 TEST_F(HttpNetworkTransactionSpdy3Test, GroupNameForDirectConnections) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7193 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 7193 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
7194 new CaptureGroupNameSSLSocketPool(NULL, NULL); | 7194 new CaptureGroupNameSSLSocketPool(NULL, NULL); |
7195 | 7195 |
7196 MockClientSocketPoolManager* mock_pool_manager = | 7196 MockClientSocketPoolManager* mock_pool_manager = |
7197 new MockClientSocketPoolManager; | 7197 new MockClientSocketPoolManager; |
7198 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool); | 7198 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool); |
7199 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); | 7199 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); |
7200 peer.SetClientSocketPoolManager(mock_pool_manager); | 7200 peer.SetClientSocketPoolManager(mock_pool_manager); |
7201 | 7201 |
7202 scoped_ptr<HttpTransaction> trans( | 7202 scoped_ptr<HttpTransaction> trans( |
7203 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7203 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7204 | 7204 |
7205 EXPECT_EQ(ERR_IO_PENDING, | 7205 EXPECT_EQ(ERR_IO_PENDING, |
7206 GroupNameTransactionHelper(tests[i].url, session)); | 7206 GroupNameTransactionHelper(tests[i].url, session)); |
7207 if (tests[i].ssl) | 7207 if (tests[i].ssl) |
7208 EXPECT_EQ(tests[i].expected_group_name, | 7208 EXPECT_EQ(tests[i].expected_group_name, |
7209 ssl_conn_pool->last_group_name_received()); | 7209 ssl_conn_pool->last_group_name_received()); |
7210 else | 7210 else |
7211 EXPECT_EQ(tests[i].expected_group_name, | 7211 EXPECT_EQ(tests[i].expected_group_name, |
7212 socks_conn_pool->last_group_name_received()); | 7212 socks_conn_pool->last_group_name_received()); |
7213 } | 7213 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7361 | 7361 |
7362 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7362 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7363 EXPECT_EQ(ERR_IO_PENDING, rv); | 7363 EXPECT_EQ(ERR_IO_PENDING, rv); |
7364 | 7364 |
7365 rv = callback.WaitForResult(); | 7365 rv = callback.WaitForResult(); |
7366 EXPECT_EQ(OK, rv); | 7366 EXPECT_EQ(OK, rv); |
7367 | 7367 |
7368 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7368 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7369 ASSERT_TRUE(response != NULL); | 7369 ASSERT_TRUE(response != NULL); |
7370 | 7370 |
7371 EXPECT_TRUE(response->headers != NULL); | 7371 EXPECT_TRUE(response->headers.get() != NULL); |
7372 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7372 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7373 | 7373 |
7374 std::string response_data; | 7374 std::string response_data; |
7375 rv = ReadTransaction(trans.get(), &response_data); | 7375 rv = ReadTransaction(trans.get(), &response_data); |
7376 EXPECT_EQ(OK, rv); | 7376 EXPECT_EQ(OK, rv); |
7377 EXPECT_EQ("", response_data); | 7377 EXPECT_EQ("", response_data); |
7378 } | 7378 } |
7379 | 7379 |
7380 // Make sure that a dropped connection while draining the body for auth | 7380 // Make sure that a dropped connection while draining the body for auth |
7381 // restart does the right thing. | 7381 // restart does the right thing. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7423 MockRead(SYNCHRONOUS, OK), | 7423 MockRead(SYNCHRONOUS, OK), |
7424 }; | 7424 }; |
7425 | 7425 |
7426 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 7426 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
7427 data_writes2, arraysize(data_writes2)); | 7427 data_writes2, arraysize(data_writes2)); |
7428 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 7428 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
7429 | 7429 |
7430 TestCompletionCallback callback1; | 7430 TestCompletionCallback callback1; |
7431 | 7431 |
7432 scoped_ptr<HttpTransaction> trans( | 7432 scoped_ptr<HttpTransaction> trans( |
7433 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7433 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7434 | 7434 |
7435 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 7435 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
7436 EXPECT_EQ(ERR_IO_PENDING, rv); | 7436 EXPECT_EQ(ERR_IO_PENDING, rv); |
7437 | 7437 |
7438 rv = callback1.WaitForResult(); | 7438 rv = callback1.WaitForResult(); |
7439 EXPECT_EQ(OK, rv); | 7439 EXPECT_EQ(OK, rv); |
7440 | 7440 |
7441 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7441 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7442 ASSERT_TRUE(response != NULL); | 7442 ASSERT_TRUE(response != NULL); |
7443 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 7443 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7513 TestCompletionCallback callback; | 7513 TestCompletionCallback callback; |
7514 | 7514 |
7515 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7515 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7516 EXPECT_EQ(ERR_IO_PENDING, rv); | 7516 EXPECT_EQ(ERR_IO_PENDING, rv); |
7517 | 7517 |
7518 EXPECT_EQ(OK, callback.WaitForResult()); | 7518 EXPECT_EQ(OK, callback.WaitForResult()); |
7519 | 7519 |
7520 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7520 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7521 ASSERT_TRUE(response != NULL); | 7521 ASSERT_TRUE(response != NULL); |
7522 | 7522 |
7523 EXPECT_TRUE(response->headers != NULL); | 7523 EXPECT_TRUE(response->headers.get() != NULL); |
7524 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7524 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7525 | 7525 |
7526 std::string response_data; | 7526 std::string response_data; |
7527 rv = ReadTransaction(trans.get(), &response_data); | 7527 rv = ReadTransaction(trans.get(), &response_data); |
7528 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 7528 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
7529 } | 7529 } |
7530 | 7530 |
7531 TEST_F(HttpNetworkTransactionSpdy3Test, UploadFileSmallerThanLength) { | 7531 TEST_F(HttpNetworkTransactionSpdy3Test, UploadFileSmallerThanLength) { |
7532 base::FilePath temp_file_path; | 7532 base::FilePath temp_file_path; |
7533 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 7533 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
(...skipping 29 matching lines...) Expand all Loading... |
7563 | 7563 |
7564 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7564 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7565 EXPECT_EQ(ERR_IO_PENDING, rv); | 7565 EXPECT_EQ(ERR_IO_PENDING, rv); |
7566 | 7566 |
7567 rv = callback.WaitForResult(); | 7567 rv = callback.WaitForResult(); |
7568 EXPECT_EQ(OK, rv); | 7568 EXPECT_EQ(OK, rv); |
7569 | 7569 |
7570 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7570 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7571 ASSERT_TRUE(response != NULL); | 7571 ASSERT_TRUE(response != NULL); |
7572 | 7572 |
7573 EXPECT_TRUE(response->headers != NULL); | 7573 EXPECT_TRUE(response->headers.get() != NULL); |
7574 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7574 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7575 | 7575 |
7576 std::string response_data; | 7576 std::string response_data; |
7577 rv = ReadTransaction(trans.get(), &response_data); | 7577 rv = ReadTransaction(trans.get(), &response_data); |
7578 EXPECT_EQ(OK, rv); | 7578 EXPECT_EQ(OK, rv); |
7579 EXPECT_EQ("hello world", response_data); | 7579 EXPECT_EQ("hello world", response_data); |
7580 | 7580 |
7581 file_util::Delete(temp_file_path, false); | 7581 file_util::Delete(temp_file_path, false); |
7582 } | 7582 } |
7583 | 7583 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7625 TestCompletionCallback callback; | 7625 TestCompletionCallback callback; |
7626 | 7626 |
7627 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7627 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7628 EXPECT_EQ(ERR_IO_PENDING, rv); | 7628 EXPECT_EQ(ERR_IO_PENDING, rv); |
7629 | 7629 |
7630 rv = callback.WaitForResult(); | 7630 rv = callback.WaitForResult(); |
7631 EXPECT_EQ(OK, rv); | 7631 EXPECT_EQ(OK, rv); |
7632 | 7632 |
7633 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7633 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7634 ASSERT_TRUE(response != NULL); | 7634 ASSERT_TRUE(response != NULL); |
7635 EXPECT_TRUE(response->headers != NULL); | 7635 EXPECT_TRUE(response->headers.get() != NULL); |
7636 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7636 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7637 | 7637 |
7638 file_util::Delete(temp_file, false); | 7638 file_util::Delete(temp_file, false); |
7639 } | 7639 } |
7640 | 7640 |
7641 TEST_F(HttpNetworkTransactionSpdy3Test, UnreadableUploadFileAfterAuthRestart) { | 7641 TEST_F(HttpNetworkTransactionSpdy3Test, UnreadableUploadFileAfterAuthRestart) { |
7642 base::FilePath temp_file; | 7642 base::FilePath temp_file; |
7643 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7643 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
7644 std::string temp_file_contents("Unreadable file."); | 7644 std::string temp_file_contents("Unreadable file."); |
7645 std::string unreadable_contents(temp_file_contents.length(), '\0'); | 7645 std::string unreadable_contents(temp_file_contents.length(), '\0'); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7694 TestCompletionCallback callback1; | 7694 TestCompletionCallback callback1; |
7695 | 7695 |
7696 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 7696 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
7697 EXPECT_EQ(ERR_IO_PENDING, rv); | 7697 EXPECT_EQ(ERR_IO_PENDING, rv); |
7698 | 7698 |
7699 rv = callback1.WaitForResult(); | 7699 rv = callback1.WaitForResult(); |
7700 EXPECT_EQ(OK, rv); | 7700 EXPECT_EQ(OK, rv); |
7701 | 7701 |
7702 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7702 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7703 ASSERT_TRUE(response != NULL); | 7703 ASSERT_TRUE(response != NULL); |
7704 ASSERT_TRUE(response->headers != NULL); | 7704 ASSERT_TRUE(response->headers.get() != NULL); |
7705 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); | 7705 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); |
7706 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 7706 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
7707 | 7707 |
7708 // Now make the file unreadable and try again. | 7708 // Now make the file unreadable and try again. |
7709 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 7709 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
7710 | 7710 |
7711 TestCompletionCallback callback2; | 7711 TestCompletionCallback callback2; |
7712 | 7712 |
7713 rv = trans->RestartWithAuth( | 7713 rv = trans->RestartWithAuth( |
7714 AuthCredentials(kFoo, kBar), callback2.callback()); | 7714 AuthCredentials(kFoo, kBar), callback2.callback()); |
7715 EXPECT_EQ(ERR_IO_PENDING, rv); | 7715 EXPECT_EQ(ERR_IO_PENDING, rv); |
7716 | 7716 |
7717 rv = callback2.WaitForResult(); | 7717 rv = callback2.WaitForResult(); |
7718 EXPECT_EQ(OK, rv); | 7718 EXPECT_EQ(OK, rv); |
7719 | 7719 |
7720 response = trans->GetResponseInfo(); | 7720 response = trans->GetResponseInfo(); |
7721 ASSERT_TRUE(response != NULL); | 7721 ASSERT_TRUE(response != NULL); |
7722 EXPECT_TRUE(response->headers != NULL); | 7722 EXPECT_TRUE(response->headers.get() != NULL); |
7723 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7723 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
7724 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7724 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7725 | 7725 |
7726 file_util::Delete(temp_file, false); | 7726 file_util::Delete(temp_file, false); |
7727 } | 7727 } |
7728 | 7728 |
7729 // Tests that changes to Auth realms are treated like auth rejections. | 7729 // Tests that changes to Auth realms are treated like auth rejections. |
7730 TEST_F(HttpNetworkTransactionSpdy3Test, ChangeAuthRealms) { | 7730 TEST_F(HttpNetworkTransactionSpdy3Test, ChangeAuthRealms) { |
7731 | 7731 |
7732 HttpRequestInfo request; | 7732 HttpRequestInfo request; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7897 request.load_flags = 0; | 7897 request.load_flags = 0; |
7898 | 7898 |
7899 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 7899 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
7900 | 7900 |
7901 session_deps_.socket_factory->AddSocketDataProvider(&data); | 7901 session_deps_.socket_factory->AddSocketDataProvider(&data); |
7902 | 7902 |
7903 TestCompletionCallback callback; | 7903 TestCompletionCallback callback; |
7904 | 7904 |
7905 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 7905 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
7906 scoped_ptr<HttpTransaction> trans( | 7906 scoped_ptr<HttpTransaction> trans( |
7907 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7907 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7908 | 7908 |
7909 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7909 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7910 EXPECT_EQ(ERR_IO_PENDING, rv); | 7910 EXPECT_EQ(ERR_IO_PENDING, rv); |
7911 | 7911 |
7912 HostPortPair http_host_port_pair("www.google.com", 80); | 7912 HostPortPair http_host_port_pair("www.google.com", 80); |
7913 const HttpServerProperties& http_server_properties = | 7913 const HttpServerProperties& http_server_properties = |
7914 *session->http_server_properties(); | 7914 *session->http_server_properties(); |
7915 EXPECT_FALSE( | 7915 EXPECT_FALSE( |
7916 http_server_properties.HasAlternateProtocol(http_host_port_pair)); | 7916 http_server_properties.HasAlternateProtocol(http_host_port_pair)); |
7917 | 7917 |
7918 EXPECT_EQ(OK, callback.WaitForResult()); | 7918 EXPECT_EQ(OK, callback.WaitForResult()); |
7919 | 7919 |
7920 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7920 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7921 ASSERT_TRUE(response != NULL); | 7921 ASSERT_TRUE(response != NULL); |
7922 ASSERT_TRUE(response->headers != NULL); | 7922 ASSERT_TRUE(response->headers.get() != NULL); |
7923 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7923 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7924 EXPECT_FALSE(response->was_fetched_via_spdy); | 7924 EXPECT_FALSE(response->was_fetched_via_spdy); |
7925 EXPECT_FALSE(response->was_npn_negotiated); | 7925 EXPECT_FALSE(response->was_npn_negotiated); |
7926 | 7926 |
7927 std::string response_data; | 7927 std::string response_data; |
7928 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7928 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
7929 EXPECT_EQ("hello world", response_data); | 7929 EXPECT_EQ("hello world", response_data); |
7930 | 7930 |
7931 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); | 7931 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); |
7932 const PortAlternateProtocolPair alternate = | 7932 const PortAlternateProtocolPair alternate = |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7967 HttpServerProperties* http_server_properties = | 7967 HttpServerProperties* http_server_properties = |
7968 session->http_server_properties(); | 7968 session->http_server_properties(); |
7969 // Port must be < 1024, or the header will be ignored (since initial port was | 7969 // Port must be < 1024, or the header will be ignored (since initial port was |
7970 // port 80 (another restricted port). | 7970 // port 80 (another restricted port). |
7971 http_server_properties->SetAlternateProtocol( | 7971 http_server_properties->SetAlternateProtocol( |
7972 HostPortPair::FromURL(request.url), | 7972 HostPortPair::FromURL(request.url), |
7973 666 /* port is ignored by MockConnect anyway */, | 7973 666 /* port is ignored by MockConnect anyway */, |
7974 NPN_SPDY_3); | 7974 NPN_SPDY_3); |
7975 | 7975 |
7976 scoped_ptr<HttpTransaction> trans( | 7976 scoped_ptr<HttpTransaction> trans( |
7977 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7977 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7978 TestCompletionCallback callback; | 7978 TestCompletionCallback callback; |
7979 | 7979 |
7980 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7980 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7981 EXPECT_EQ(ERR_IO_PENDING, rv); | 7981 EXPECT_EQ(ERR_IO_PENDING, rv); |
7982 EXPECT_EQ(OK, callback.WaitForResult()); | 7982 EXPECT_EQ(OK, callback.WaitForResult()); |
7983 | 7983 |
7984 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7984 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7985 ASSERT_TRUE(response != NULL); | 7985 ASSERT_TRUE(response != NULL); |
7986 ASSERT_TRUE(response->headers != NULL); | 7986 ASSERT_TRUE(response->headers.get() != NULL); |
7987 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7987 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7988 | 7988 |
7989 std::string response_data; | 7989 std::string response_data; |
7990 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7990 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
7991 EXPECT_EQ("hello world", response_data); | 7991 EXPECT_EQ("hello world", response_data); |
7992 | 7992 |
7993 ASSERT_TRUE(http_server_properties->HasAlternateProtocol( | 7993 ASSERT_TRUE(http_server_properties->HasAlternateProtocol( |
7994 HostPortPair::FromURL(request.url))); | 7994 HostPortPair::FromURL(request.url))); |
7995 const PortAlternateProtocolPair alternate = | 7995 const PortAlternateProtocolPair alternate = |
7996 http_server_properties->GetAlternateProtocol( | 7996 http_server_properties->GetAlternateProtocol( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8029 | 8029 |
8030 HttpServerProperties* http_server_properties = | 8030 HttpServerProperties* http_server_properties = |
8031 session->http_server_properties(); | 8031 session->http_server_properties(); |
8032 const int kUnrestrictedAlternatePort = 1024; | 8032 const int kUnrestrictedAlternatePort = 1024; |
8033 http_server_properties->SetAlternateProtocol( | 8033 http_server_properties->SetAlternateProtocol( |
8034 HostPortPair::FromURL(restricted_port_request.url), | 8034 HostPortPair::FromURL(restricted_port_request.url), |
8035 kUnrestrictedAlternatePort, | 8035 kUnrestrictedAlternatePort, |
8036 NPN_SPDY_3); | 8036 NPN_SPDY_3); |
8037 | 8037 |
8038 scoped_ptr<HttpTransaction> trans( | 8038 scoped_ptr<HttpTransaction> trans( |
8039 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8039 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8040 TestCompletionCallback callback; | 8040 TestCompletionCallback callback; |
8041 | 8041 |
8042 int rv = trans->Start( | 8042 int rv = trans->Start( |
8043 &restricted_port_request, callback.callback(), BoundNetLog()); | 8043 &restricted_port_request, callback.callback(), BoundNetLog()); |
8044 EXPECT_EQ(ERR_IO_PENDING, rv); | 8044 EXPECT_EQ(ERR_IO_PENDING, rv); |
8045 // Invalid change to unrestricted port should fail. | 8045 // Invalid change to unrestricted port should fail. |
8046 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); | 8046 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); |
8047 } | 8047 } |
8048 | 8048 |
8049 TEST_F(HttpNetworkTransactionSpdy3Test, | 8049 TEST_F(HttpNetworkTransactionSpdy3Test, |
(...skipping 29 matching lines...) Expand all Loading... |
8079 | 8079 |
8080 HttpServerProperties* http_server_properties = | 8080 HttpServerProperties* http_server_properties = |
8081 session->http_server_properties(); | 8081 session->http_server_properties(); |
8082 const int kUnrestrictedAlternatePort = 1024; | 8082 const int kUnrestrictedAlternatePort = 1024; |
8083 http_server_properties->SetAlternateProtocol( | 8083 http_server_properties->SetAlternateProtocol( |
8084 HostPortPair::FromURL(restricted_port_request.url), | 8084 HostPortPair::FromURL(restricted_port_request.url), |
8085 kUnrestrictedAlternatePort, | 8085 kUnrestrictedAlternatePort, |
8086 NPN_SPDY_3); | 8086 NPN_SPDY_3); |
8087 | 8087 |
8088 scoped_ptr<HttpTransaction> trans( | 8088 scoped_ptr<HttpTransaction> trans( |
8089 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8089 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8090 TestCompletionCallback callback; | 8090 TestCompletionCallback callback; |
8091 | 8091 |
8092 EXPECT_EQ(ERR_IO_PENDING, trans->Start( | 8092 EXPECT_EQ(ERR_IO_PENDING, trans->Start( |
8093 &restricted_port_request, callback.callback(), BoundNetLog())); | 8093 &restricted_port_request, callback.callback(), BoundNetLog())); |
8094 // Change to unrestricted port should succeed. | 8094 // Change to unrestricted port should succeed. |
8095 EXPECT_EQ(OK, callback.WaitForResult()); | 8095 EXPECT_EQ(OK, callback.WaitForResult()); |
8096 } | 8096 } |
8097 | 8097 |
8098 TEST_F(HttpNetworkTransactionSpdy3Test, | 8098 TEST_F(HttpNetworkTransactionSpdy3Test, |
8099 AlternateProtocolPortRestrictedAllowed) { | 8099 AlternateProtocolPortRestrictedAllowed) { |
(...skipping 26 matching lines...) Expand all Loading... |
8126 | 8126 |
8127 HttpServerProperties* http_server_properties = | 8127 HttpServerProperties* http_server_properties = |
8128 session->http_server_properties(); | 8128 session->http_server_properties(); |
8129 const int kRestrictedAlternatePort = 80; | 8129 const int kRestrictedAlternatePort = 80; |
8130 http_server_properties->SetAlternateProtocol( | 8130 http_server_properties->SetAlternateProtocol( |
8131 HostPortPair::FromURL(restricted_port_request.url), | 8131 HostPortPair::FromURL(restricted_port_request.url), |
8132 kRestrictedAlternatePort, | 8132 kRestrictedAlternatePort, |
8133 NPN_SPDY_3); | 8133 NPN_SPDY_3); |
8134 | 8134 |
8135 scoped_ptr<HttpTransaction> trans( | 8135 scoped_ptr<HttpTransaction> trans( |
8136 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8136 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8137 TestCompletionCallback callback; | 8137 TestCompletionCallback callback; |
8138 | 8138 |
8139 int rv = trans->Start( | 8139 int rv = trans->Start( |
8140 &restricted_port_request, callback.callback(), BoundNetLog()); | 8140 &restricted_port_request, callback.callback(), BoundNetLog()); |
8141 EXPECT_EQ(ERR_IO_PENDING, rv); | 8141 EXPECT_EQ(ERR_IO_PENDING, rv); |
8142 // Valid change to restricted port should pass. | 8142 // Valid change to restricted port should pass. |
8143 EXPECT_EQ(OK, callback.WaitForResult()); | 8143 EXPECT_EQ(OK, callback.WaitForResult()); |
8144 } | 8144 } |
8145 | 8145 |
8146 TEST_F(HttpNetworkTransactionSpdy3Test, | 8146 TEST_F(HttpNetworkTransactionSpdy3Test, |
(...skipping 27 matching lines...) Expand all Loading... |
8174 | 8174 |
8175 HttpServerProperties* http_server_properties = | 8175 HttpServerProperties* http_server_properties = |
8176 session->http_server_properties(); | 8176 session->http_server_properties(); |
8177 const int kRestrictedAlternatePort = 80; | 8177 const int kRestrictedAlternatePort = 80; |
8178 http_server_properties->SetAlternateProtocol( | 8178 http_server_properties->SetAlternateProtocol( |
8179 HostPortPair::FromURL(unrestricted_port_request.url), | 8179 HostPortPair::FromURL(unrestricted_port_request.url), |
8180 kRestrictedAlternatePort, | 8180 kRestrictedAlternatePort, |
8181 NPN_SPDY_3); | 8181 NPN_SPDY_3); |
8182 | 8182 |
8183 scoped_ptr<HttpTransaction> trans( | 8183 scoped_ptr<HttpTransaction> trans( |
8184 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8184 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8185 TestCompletionCallback callback; | 8185 TestCompletionCallback callback; |
8186 | 8186 |
8187 int rv = trans->Start( | 8187 int rv = trans->Start( |
8188 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 8188 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
8189 EXPECT_EQ(ERR_IO_PENDING, rv); | 8189 EXPECT_EQ(ERR_IO_PENDING, rv); |
8190 // Valid change to restricted port should pass. | 8190 // Valid change to restricted port should pass. |
8191 EXPECT_EQ(OK, callback.WaitForResult()); | 8191 EXPECT_EQ(OK, callback.WaitForResult()); |
8192 } | 8192 } |
8193 | 8193 |
8194 TEST_F(HttpNetworkTransactionSpdy3Test, | 8194 TEST_F(HttpNetworkTransactionSpdy3Test, |
(...skipping 27 matching lines...) Expand all Loading... |
8222 | 8222 |
8223 HttpServerProperties* http_server_properties = | 8223 HttpServerProperties* http_server_properties = |
8224 session->http_server_properties(); | 8224 session->http_server_properties(); |
8225 const int kUnrestrictedAlternatePort = 1024; | 8225 const int kUnrestrictedAlternatePort = 1024; |
8226 http_server_properties->SetAlternateProtocol( | 8226 http_server_properties->SetAlternateProtocol( |
8227 HostPortPair::FromURL(unrestricted_port_request.url), | 8227 HostPortPair::FromURL(unrestricted_port_request.url), |
8228 kUnrestrictedAlternatePort, | 8228 kUnrestrictedAlternatePort, |
8229 NPN_SPDY_3); | 8229 NPN_SPDY_3); |
8230 | 8230 |
8231 scoped_ptr<HttpTransaction> trans( | 8231 scoped_ptr<HttpTransaction> trans( |
8232 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8232 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8233 TestCompletionCallback callback; | 8233 TestCompletionCallback callback; |
8234 | 8234 |
8235 int rv = trans->Start( | 8235 int rv = trans->Start( |
8236 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 8236 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
8237 EXPECT_EQ(ERR_IO_PENDING, rv); | 8237 EXPECT_EQ(ERR_IO_PENDING, rv); |
8238 // Valid change to an unrestricted port should pass. | 8238 // Valid change to an unrestricted port should pass. |
8239 EXPECT_EQ(OK, callback.WaitForResult()); | 8239 EXPECT_EQ(OK, callback.WaitForResult()); |
8240 } | 8240 } |
8241 | 8241 |
8242 TEST_F(HttpNetworkTransactionSpdy3Test, AlternateProtocolUnsafeBlocked) { | 8242 TEST_F(HttpNetworkTransactionSpdy3Test, AlternateProtocolUnsafeBlocked) { |
(...skipping 22 matching lines...) Expand all Loading... |
8265 | 8265 |
8266 HttpServerProperties* http_server_properties = | 8266 HttpServerProperties* http_server_properties = |
8267 session->http_server_properties(); | 8267 session->http_server_properties(); |
8268 const int kUnsafePort = 7; | 8268 const int kUnsafePort = 7; |
8269 http_server_properties->SetAlternateProtocol( | 8269 http_server_properties->SetAlternateProtocol( |
8270 HostPortPair::FromURL(request.url), | 8270 HostPortPair::FromURL(request.url), |
8271 kUnsafePort, | 8271 kUnsafePort, |
8272 NPN_SPDY_3); | 8272 NPN_SPDY_3); |
8273 | 8273 |
8274 scoped_ptr<HttpTransaction> trans( | 8274 scoped_ptr<HttpTransaction> trans( |
8275 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8275 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8276 TestCompletionCallback callback; | 8276 TestCompletionCallback callback; |
8277 | 8277 |
8278 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8278 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8279 EXPECT_EQ(ERR_IO_PENDING, rv); | 8279 EXPECT_EQ(ERR_IO_PENDING, rv); |
8280 // The HTTP request should succeed. | 8280 // The HTTP request should succeed. |
8281 EXPECT_EQ(OK, callback.WaitForResult()); | 8281 EXPECT_EQ(OK, callback.WaitForResult()); |
8282 | 8282 |
8283 // Disable alternate protocol before the asserts. | 8283 // Disable alternate protocol before the asserts. |
8284 HttpStreamFactory::set_use_alternate_protocols(false); | 8284 HttpStreamFactory::set_use_alternate_protocols(false); |
8285 | 8285 |
8286 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8286 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8287 ASSERT_TRUE(response != NULL); | 8287 ASSERT_TRUE(response != NULL); |
8288 ASSERT_TRUE(response->headers != NULL); | 8288 ASSERT_TRUE(response->headers.get() != NULL); |
8289 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8289 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8290 | 8290 |
8291 std::string response_data; | 8291 std::string response_data; |
8292 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8292 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8293 EXPECT_EQ("hello world", response_data); | 8293 EXPECT_EQ("hello world", response_data); |
8294 } | 8294 } |
8295 | 8295 |
8296 TEST_F(HttpNetworkTransactionSpdy3Test, UseAlternateProtocolForNpnSpdy) { | 8296 TEST_F(HttpNetworkTransactionSpdy3Test, UseAlternateProtocolForNpnSpdy) { |
8297 HttpStreamFactory::set_use_alternate_protocols(true); | 8297 HttpStreamFactory::set_use_alternate_protocols(true); |
8298 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 8298 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8341 NULL, 0, NULL, 0); | 8341 NULL, 0, NULL, 0); |
8342 hanging_non_alternate_protocol_socket.set_connect_data( | 8342 hanging_non_alternate_protocol_socket.set_connect_data( |
8343 never_finishing_connect); | 8343 never_finishing_connect); |
8344 session_deps_.socket_factory->AddSocketDataProvider( | 8344 session_deps_.socket_factory->AddSocketDataProvider( |
8345 &hanging_non_alternate_protocol_socket); | 8345 &hanging_non_alternate_protocol_socket); |
8346 | 8346 |
8347 TestCompletionCallback callback; | 8347 TestCompletionCallback callback; |
8348 | 8348 |
8349 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8349 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8350 scoped_ptr<HttpTransaction> trans( | 8350 scoped_ptr<HttpTransaction> trans( |
8351 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8351 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8352 | 8352 |
8353 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8353 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8354 EXPECT_EQ(ERR_IO_PENDING, rv); | 8354 EXPECT_EQ(ERR_IO_PENDING, rv); |
8355 EXPECT_EQ(OK, callback.WaitForResult()); | 8355 EXPECT_EQ(OK, callback.WaitForResult()); |
8356 | 8356 |
8357 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8357 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8358 ASSERT_TRUE(response != NULL); | 8358 ASSERT_TRUE(response != NULL); |
8359 ASSERT_TRUE(response->headers != NULL); | 8359 ASSERT_TRUE(response->headers.get() != NULL); |
8360 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8360 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8361 | 8361 |
8362 std::string response_data; | 8362 std::string response_data; |
8363 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8363 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8364 EXPECT_EQ("hello world", response_data); | 8364 EXPECT_EQ("hello world", response_data); |
8365 | 8365 |
8366 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8366 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8367 | 8367 |
8368 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8368 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8369 EXPECT_EQ(ERR_IO_PENDING, rv); | 8369 EXPECT_EQ(ERR_IO_PENDING, rv); |
8370 EXPECT_EQ(OK, callback.WaitForResult()); | 8370 EXPECT_EQ(OK, callback.WaitForResult()); |
8371 | 8371 |
8372 response = trans->GetResponseInfo(); | 8372 response = trans->GetResponseInfo(); |
8373 ASSERT_TRUE(response != NULL); | 8373 ASSERT_TRUE(response != NULL); |
8374 ASSERT_TRUE(response->headers != NULL); | 8374 ASSERT_TRUE(response->headers.get() != NULL); |
8375 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8375 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8376 EXPECT_TRUE(response->was_fetched_via_spdy); | 8376 EXPECT_TRUE(response->was_fetched_via_spdy); |
8377 EXPECT_TRUE(response->was_npn_negotiated); | 8377 EXPECT_TRUE(response->was_npn_negotiated); |
8378 | 8378 |
8379 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8379 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8380 EXPECT_EQ("hello!", response_data); | 8380 EXPECT_EQ("hello!", response_data); |
8381 } | 8381 } |
8382 | 8382 |
8383 TEST_F(HttpNetworkTransactionSpdy3Test, AlternateProtocolWithSpdyLateBinding) { | 8383 TEST_F(HttpNetworkTransactionSpdy3Test, AlternateProtocolWithSpdyLateBinding) { |
8384 HttpStreamFactory::set_use_alternate_protocols(true); | 8384 HttpStreamFactory::set_use_alternate_protocols(true); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8440 spdy_reads, arraysize(spdy_reads), | 8440 spdy_reads, arraysize(spdy_reads), |
8441 spdy_writes, arraysize(spdy_writes)); | 8441 spdy_writes, arraysize(spdy_writes)); |
8442 // Socket 4 is the successful Alternate-Protocol for transaction 3. | 8442 // Socket 4 is the successful Alternate-Protocol for transaction 3. |
8443 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 8443 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
8444 | 8444 |
8445 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. | 8445 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. |
8446 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket); | 8446 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket); |
8447 | 8447 |
8448 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8448 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8449 TestCompletionCallback callback1; | 8449 TestCompletionCallback callback1; |
8450 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 8450 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
8451 | 8451 |
8452 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); | 8452 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); |
8453 EXPECT_EQ(ERR_IO_PENDING, rv); | 8453 EXPECT_EQ(ERR_IO_PENDING, rv); |
8454 EXPECT_EQ(OK, callback1.WaitForResult()); | 8454 EXPECT_EQ(OK, callback1.WaitForResult()); |
8455 | 8455 |
8456 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 8456 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
8457 ASSERT_TRUE(response != NULL); | 8457 ASSERT_TRUE(response != NULL); |
8458 ASSERT_TRUE(response->headers != NULL); | 8458 ASSERT_TRUE(response->headers.get() != NULL); |
8459 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8459 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8460 | 8460 |
8461 std::string response_data; | 8461 std::string response_data; |
8462 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 8462 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
8463 EXPECT_EQ("hello world", response_data); | 8463 EXPECT_EQ("hello world", response_data); |
8464 | 8464 |
8465 TestCompletionCallback callback2; | 8465 TestCompletionCallback callback2; |
8466 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 8466 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
8467 rv = trans2.Start(&request, callback2.callback(), BoundNetLog()); | 8467 rv = trans2.Start(&request, callback2.callback(), BoundNetLog()); |
8468 EXPECT_EQ(ERR_IO_PENDING, rv); | 8468 EXPECT_EQ(ERR_IO_PENDING, rv); |
8469 | 8469 |
8470 TestCompletionCallback callback3; | 8470 TestCompletionCallback callback3; |
8471 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, session); | 8471 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, session.get()); |
8472 rv = trans3.Start(&request, callback3.callback(), BoundNetLog()); | 8472 rv = trans3.Start(&request, callback3.callback(), BoundNetLog()); |
8473 EXPECT_EQ(ERR_IO_PENDING, rv); | 8473 EXPECT_EQ(ERR_IO_PENDING, rv); |
8474 | 8474 |
8475 EXPECT_EQ(OK, callback2.WaitForResult()); | 8475 EXPECT_EQ(OK, callback2.WaitForResult()); |
8476 EXPECT_EQ(OK, callback3.WaitForResult()); | 8476 EXPECT_EQ(OK, callback3.WaitForResult()); |
8477 | 8477 |
8478 response = trans2.GetResponseInfo(); | 8478 response = trans2.GetResponseInfo(); |
8479 ASSERT_TRUE(response != NULL); | 8479 ASSERT_TRUE(response != NULL); |
8480 ASSERT_TRUE(response->headers != NULL); | 8480 ASSERT_TRUE(response->headers.get() != NULL); |
8481 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8481 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8482 EXPECT_TRUE(response->was_fetched_via_spdy); | 8482 EXPECT_TRUE(response->was_fetched_via_spdy); |
8483 EXPECT_TRUE(response->was_npn_negotiated); | 8483 EXPECT_TRUE(response->was_npn_negotiated); |
8484 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 8484 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
8485 EXPECT_EQ("hello!", response_data); | 8485 EXPECT_EQ("hello!", response_data); |
8486 | 8486 |
8487 response = trans3.GetResponseInfo(); | 8487 response = trans3.GetResponseInfo(); |
8488 ASSERT_TRUE(response != NULL); | 8488 ASSERT_TRUE(response != NULL); |
8489 ASSERT_TRUE(response->headers != NULL); | 8489 ASSERT_TRUE(response->headers.get() != NULL); |
8490 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8490 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8491 EXPECT_TRUE(response->was_fetched_via_spdy); | 8491 EXPECT_TRUE(response->was_fetched_via_spdy); |
8492 EXPECT_TRUE(response->was_npn_negotiated); | 8492 EXPECT_TRUE(response->was_npn_negotiated); |
8493 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); | 8493 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); |
8494 EXPECT_EQ("hello!", response_data); | 8494 EXPECT_EQ("hello!", response_data); |
8495 } | 8495 } |
8496 | 8496 |
8497 TEST_F(HttpNetworkTransactionSpdy3Test, StallAlternateProtocolForNpnSpdy) { | 8497 TEST_F(HttpNetworkTransactionSpdy3Test, StallAlternateProtocolForNpnSpdy) { |
8498 HttpStreamFactory::set_use_alternate_protocols(true); | 8498 HttpStreamFactory::set_use_alternate_protocols(true); |
8499 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 8499 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
(...skipping 27 matching lines...) Expand all Loading... |
8527 session_deps_.socket_factory->AddSocketDataProvider( | 8527 session_deps_.socket_factory->AddSocketDataProvider( |
8528 &hanging_alternate_protocol_socket); | 8528 &hanging_alternate_protocol_socket); |
8529 | 8529 |
8530 // 2nd request is just a copy of the first one, over HTTP again. | 8530 // 2nd request is just a copy of the first one, over HTTP again. |
8531 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 8531 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
8532 | 8532 |
8533 TestCompletionCallback callback; | 8533 TestCompletionCallback callback; |
8534 | 8534 |
8535 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8535 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8536 scoped_ptr<HttpTransaction> trans( | 8536 scoped_ptr<HttpTransaction> trans( |
8537 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8537 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8538 | 8538 |
8539 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8539 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8540 EXPECT_EQ(ERR_IO_PENDING, rv); | 8540 EXPECT_EQ(ERR_IO_PENDING, rv); |
8541 EXPECT_EQ(OK, callback.WaitForResult()); | 8541 EXPECT_EQ(OK, callback.WaitForResult()); |
8542 | 8542 |
8543 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8543 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8544 ASSERT_TRUE(response != NULL); | 8544 ASSERT_TRUE(response != NULL); |
8545 ASSERT_TRUE(response->headers != NULL); | 8545 ASSERT_TRUE(response->headers.get() != NULL); |
8546 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8546 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8547 | 8547 |
8548 std::string response_data; | 8548 std::string response_data; |
8549 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8549 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8550 EXPECT_EQ("hello world", response_data); | 8550 EXPECT_EQ("hello world", response_data); |
8551 | 8551 |
8552 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8552 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8553 | 8553 |
8554 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8554 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8555 EXPECT_EQ(ERR_IO_PENDING, rv); | 8555 EXPECT_EQ(ERR_IO_PENDING, rv); |
8556 EXPECT_EQ(OK, callback.WaitForResult()); | 8556 EXPECT_EQ(OK, callback.WaitForResult()); |
8557 | 8557 |
8558 response = trans->GetResponseInfo(); | 8558 response = trans->GetResponseInfo(); |
8559 ASSERT_TRUE(response != NULL); | 8559 ASSERT_TRUE(response != NULL); |
8560 ASSERT_TRUE(response->headers != NULL); | 8560 ASSERT_TRUE(response->headers.get() != NULL); |
8561 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8561 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8562 EXPECT_FALSE(response->was_fetched_via_spdy); | 8562 EXPECT_FALSE(response->was_fetched_via_spdy); |
8563 EXPECT_FALSE(response->was_npn_negotiated); | 8563 EXPECT_FALSE(response->was_npn_negotiated); |
8564 | 8564 |
8565 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8565 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8566 EXPECT_EQ("hello world", response_data); | 8566 EXPECT_EQ("hello world", response_data); |
8567 } | 8567 } |
8568 | 8568 |
8569 class CapturingProxyResolver : public ProxyResolver { | 8569 class CapturingProxyResolver : public ProxyResolver { |
8570 public: | 8570 public: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8677 NULL, 0, NULL, 0); | 8677 NULL, 0, NULL, 0); |
8678 hanging_non_alternate_protocol_socket.set_connect_data( | 8678 hanging_non_alternate_protocol_socket.set_connect_data( |
8679 never_finishing_connect); | 8679 never_finishing_connect); |
8680 session_deps_.socket_factory->AddSocketDataProvider( | 8680 session_deps_.socket_factory->AddSocketDataProvider( |
8681 &hanging_non_alternate_protocol_socket); | 8681 &hanging_non_alternate_protocol_socket); |
8682 | 8682 |
8683 TestCompletionCallback callback; | 8683 TestCompletionCallback callback; |
8684 | 8684 |
8685 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8685 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8686 scoped_ptr<HttpTransaction> trans( | 8686 scoped_ptr<HttpTransaction> trans( |
8687 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8687 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8688 | 8688 |
8689 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8689 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8690 EXPECT_EQ(ERR_IO_PENDING, rv); | 8690 EXPECT_EQ(ERR_IO_PENDING, rv); |
8691 EXPECT_EQ(OK, callback.WaitForResult()); | 8691 EXPECT_EQ(OK, callback.WaitForResult()); |
8692 | 8692 |
8693 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8693 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8694 ASSERT_TRUE(response != NULL); | 8694 ASSERT_TRUE(response != NULL); |
8695 ASSERT_TRUE(response->headers != NULL); | 8695 ASSERT_TRUE(response->headers.get() != NULL); |
8696 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8696 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8697 EXPECT_FALSE(response->was_fetched_via_spdy); | 8697 EXPECT_FALSE(response->was_fetched_via_spdy); |
8698 EXPECT_FALSE(response->was_npn_negotiated); | 8698 EXPECT_FALSE(response->was_npn_negotiated); |
8699 | 8699 |
8700 std::string response_data; | 8700 std::string response_data; |
8701 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8701 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8702 EXPECT_EQ("hello world", response_data); | 8702 EXPECT_EQ("hello world", response_data); |
8703 | 8703 |
8704 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8704 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8705 | 8705 |
8706 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8706 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8707 EXPECT_EQ(ERR_IO_PENDING, rv); | 8707 EXPECT_EQ(ERR_IO_PENDING, rv); |
8708 EXPECT_EQ(OK, callback.WaitForResult()); | 8708 EXPECT_EQ(OK, callback.WaitForResult()); |
8709 | 8709 |
8710 response = trans->GetResponseInfo(); | 8710 response = trans->GetResponseInfo(); |
8711 ASSERT_TRUE(response != NULL); | 8711 ASSERT_TRUE(response != NULL); |
8712 ASSERT_TRUE(response->headers != NULL); | 8712 ASSERT_TRUE(response->headers.get() != NULL); |
8713 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8713 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8714 EXPECT_TRUE(response->was_fetched_via_spdy); | 8714 EXPECT_TRUE(response->was_fetched_via_spdy); |
8715 EXPECT_TRUE(response->was_npn_negotiated); | 8715 EXPECT_TRUE(response->was_npn_negotiated); |
8716 | 8716 |
8717 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8717 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8718 EXPECT_EQ("hello!", response_data); | 8718 EXPECT_EQ("hello!", response_data); |
8719 ASSERT_EQ(3u, capturing_proxy_resolver->resolved().size()); | 8719 ASSERT_EQ(3u, capturing_proxy_resolver->resolved().size()); |
8720 EXPECT_EQ("http://www.google.com/", | 8720 EXPECT_EQ("http://www.google.com/", |
8721 capturing_proxy_resolver->resolved()[0].spec()); | 8721 capturing_proxy_resolver->resolved()[0].spec()); |
8722 EXPECT_EQ("https://www.google.com/", | 8722 EXPECT_EQ("https://www.google.com/", |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8769 1, // wait for one write to finish before reading. | 8769 1, // wait for one write to finish before reading. |
8770 spdy_reads, arraysize(spdy_reads), | 8770 spdy_reads, arraysize(spdy_reads), |
8771 spdy_writes, arraysize(spdy_writes)); | 8771 spdy_writes, arraysize(spdy_writes)); |
8772 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 8772 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
8773 | 8773 |
8774 TestCompletionCallback callback; | 8774 TestCompletionCallback callback; |
8775 | 8775 |
8776 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8776 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8777 | 8777 |
8778 scoped_ptr<HttpTransaction> trans( | 8778 scoped_ptr<HttpTransaction> trans( |
8779 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8779 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8780 | 8780 |
8781 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8781 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8782 EXPECT_EQ(ERR_IO_PENDING, rv); | 8782 EXPECT_EQ(ERR_IO_PENDING, rv); |
8783 EXPECT_EQ(OK, callback.WaitForResult()); | 8783 EXPECT_EQ(OK, callback.WaitForResult()); |
8784 | 8784 |
8785 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8785 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8786 ASSERT_TRUE(response != NULL); | 8786 ASSERT_TRUE(response != NULL); |
8787 ASSERT_TRUE(response->headers != NULL); | 8787 ASSERT_TRUE(response->headers.get() != NULL); |
8788 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8788 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8789 | 8789 |
8790 std::string response_data; | 8790 std::string response_data; |
8791 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8791 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8792 EXPECT_EQ("hello world", response_data); | 8792 EXPECT_EQ("hello world", response_data); |
8793 | 8793 |
8794 // Set up an initial SpdySession in the pool to reuse. | 8794 // Set up an initial SpdySession in the pool to reuse. |
8795 HostPortPair host_port_pair("www.google.com", 443); | 8795 HostPortPair host_port_pair("www.google.com", 443); |
8796 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 8796 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
8797 kPrivacyModeDisabled); | 8797 kPrivacyModeDisabled); |
(...skipping 25 matching lines...) Expand all Loading... |
8823 HostPortPair(std::string(), 443), | 8823 HostPortPair(std::string(), 443), |
8824 ssl_config, | 8824 ssl_config, |
8825 context)); | 8825 context)); |
8826 EXPECT_EQ(ERR_IO_PENDING, | 8826 EXPECT_EQ(ERR_IO_PENDING, |
8827 ssl_connection->socket()->Connect(callback.callback())); | 8827 ssl_connection->socket()->Connect(callback.callback())); |
8828 EXPECT_EQ(OK, callback.WaitForResult()); | 8828 EXPECT_EQ(OK, callback.WaitForResult()); |
8829 | 8829 |
8830 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), | 8830 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), |
8831 true, OK)); | 8831 true, OK)); |
8832 | 8832 |
8833 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8833 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8834 | 8834 |
8835 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8835 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8836 EXPECT_EQ(ERR_IO_PENDING, rv); | 8836 EXPECT_EQ(ERR_IO_PENDING, rv); |
8837 EXPECT_EQ(OK, callback.WaitForResult()); | 8837 EXPECT_EQ(OK, callback.WaitForResult()); |
8838 | 8838 |
8839 response = trans->GetResponseInfo(); | 8839 response = trans->GetResponseInfo(); |
8840 ASSERT_TRUE(response != NULL); | 8840 ASSERT_TRUE(response != NULL); |
8841 ASSERT_TRUE(response->headers != NULL); | 8841 ASSERT_TRUE(response->headers.get() != NULL); |
8842 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8842 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8843 EXPECT_TRUE(response->was_fetched_via_spdy); | 8843 EXPECT_TRUE(response->was_fetched_via_spdy); |
8844 EXPECT_TRUE(response->was_npn_negotiated); | 8844 EXPECT_TRUE(response->was_npn_negotiated); |
8845 | 8845 |
8846 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8846 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8847 EXPECT_EQ("hello!", response_data); | 8847 EXPECT_EQ("hello!", response_data); |
8848 } | 8848 } |
8849 | 8849 |
8850 // GenerateAuthToken is a mighty big test. | 8850 // GenerateAuthToken is a mighty big test. |
8851 // It tests all permutation of GenerateAuthToken behavior: | 8851 // It tests all permutation of GenerateAuthToken behavior: |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9300 &transport_pool_histograms, | 9300 &transport_pool_histograms, |
9301 session_deps_.host_resolver.get(), | 9301 session_deps_.host_resolver.get(), |
9302 session_deps_.socket_factory.get(), | 9302 session_deps_.socket_factory.get(), |
9303 session_deps_.net_log); | 9303 session_deps_.net_log); |
9304 MockClientSocketPoolManager* mock_pool_manager = | 9304 MockClientSocketPoolManager* mock_pool_manager = |
9305 new MockClientSocketPoolManager; | 9305 new MockClientSocketPoolManager; |
9306 mock_pool_manager->SetTransportSocketPool(transport_pool); | 9306 mock_pool_manager->SetTransportSocketPool(transport_pool); |
9307 session_peer.SetClientSocketPoolManager(mock_pool_manager); | 9307 session_peer.SetClientSocketPoolManager(mock_pool_manager); |
9308 | 9308 |
9309 scoped_ptr<HttpTransaction> trans( | 9309 scoped_ptr<HttpTransaction> trans( |
9310 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9310 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9311 TestCompletionCallback callback; | 9311 TestCompletionCallback callback; |
9312 | 9312 |
9313 const MockWrite kGet( | 9313 const MockWrite kGet( |
9314 "GET / HTTP/1.1\r\n" | 9314 "GET / HTTP/1.1\r\n" |
9315 "Host: www.example.com\r\n" | 9315 "Host: www.example.com\r\n" |
9316 "Connection: keep-alive\r\n\r\n"); | 9316 "Connection: keep-alive\r\n\r\n"); |
9317 const MockWrite kGetAuth( | 9317 const MockWrite kGetAuth( |
9318 "GET / HTTP/1.1\r\n" | 9318 "GET / HTTP/1.1\r\n" |
9319 "Host: www.example.com\r\n" | 9319 "Host: www.example.com\r\n" |
9320 "Connection: keep-alive\r\n" | 9320 "Connection: keep-alive\r\n" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9370 EXPECT_EQ(OK, rv); | 9370 EXPECT_EQ(OK, rv); |
9371 response = trans->GetResponseInfo(); | 9371 response = trans->GetResponseInfo(); |
9372 ASSERT_TRUE(response != NULL); | 9372 ASSERT_TRUE(response != NULL); |
9373 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 9373 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
9374 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9374 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9375 | 9375 |
9376 // In between rounds, another request comes in for the same domain. | 9376 // In between rounds, another request comes in for the same domain. |
9377 // It should not be able to grab the TCP socket that trans has already | 9377 // It should not be able to grab the TCP socket that trans has already |
9378 // claimed. | 9378 // claimed. |
9379 scoped_ptr<HttpTransaction> trans_compete( | 9379 scoped_ptr<HttpTransaction> trans_compete( |
9380 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9380 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9381 TestCompletionCallback callback_compete; | 9381 TestCompletionCallback callback_compete; |
9382 rv = trans_compete->Start( | 9382 rv = trans_compete->Start( |
9383 &request, callback_compete.callback(), BoundNetLog()); | 9383 &request, callback_compete.callback(), BoundNetLog()); |
9384 EXPECT_EQ(ERR_IO_PENDING, rv); | 9384 EXPECT_EQ(ERR_IO_PENDING, rv); |
9385 // callback_compete.WaitForResult at this point would stall forever, | 9385 // callback_compete.WaitForResult at this point would stall forever, |
9386 // since the HttpNetworkTransaction does not release the request back to | 9386 // since the HttpNetworkTransaction does not release the request back to |
9387 // the pool until after authentication completes. | 9387 // the pool until after authentication completes. |
9388 | 9388 |
9389 // Second round of authentication. | 9389 // Second round of authentication. |
9390 auth_handler->SetGenerateExpectation(false, OK); | 9390 auth_handler->SetGenerateExpectation(false, OK); |
(...skipping 24 matching lines...) Expand all Loading... |
9415 rv = callback.WaitForResult(); | 9415 rv = callback.WaitForResult(); |
9416 EXPECT_EQ(OK, rv); | 9416 EXPECT_EQ(OK, rv); |
9417 response = trans->GetResponseInfo(); | 9417 response = trans->GetResponseInfo(); |
9418 ASSERT_TRUE(response != NULL); | 9418 ASSERT_TRUE(response != NULL); |
9419 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 9419 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
9420 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9420 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9421 | 9421 |
9422 // Read the body since the fourth round was successful. This will also | 9422 // Read the body since the fourth round was successful. This will also |
9423 // release the socket back to the pool. | 9423 // release the socket back to the pool. |
9424 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); | 9424 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); |
9425 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 9425 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9426 if (rv == ERR_IO_PENDING) | 9426 if (rv == ERR_IO_PENDING) |
9427 rv = callback.WaitForResult(); | 9427 rv = callback.WaitForResult(); |
9428 EXPECT_EQ(3, rv); | 9428 EXPECT_EQ(3, rv); |
9429 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 9429 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9430 EXPECT_EQ(0, rv); | 9430 EXPECT_EQ(0, rv); |
9431 // There are still 0 idle sockets, since the trans_compete transaction | 9431 // There are still 0 idle sockets, since the trans_compete transaction |
9432 // will be handed it immediately after trans releases it to the group. | 9432 // will be handed it immediately after trans releases it to the group. |
9433 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9433 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9434 | 9434 |
9435 // The competing request can now finish. Wait for the headers and then | 9435 // The competing request can now finish. Wait for the headers and then |
9436 // read the body. | 9436 // read the body. |
9437 rv = callback_compete.WaitForResult(); | 9437 rv = callback_compete.WaitForResult(); |
9438 EXPECT_EQ(OK, rv); | 9438 EXPECT_EQ(OK, rv); |
9439 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback()); | 9439 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9440 if (rv == ERR_IO_PENDING) | 9440 if (rv == ERR_IO_PENDING) |
9441 rv = callback.WaitForResult(); | 9441 rv = callback.WaitForResult(); |
9442 EXPECT_EQ(3, rv); | 9442 EXPECT_EQ(3, rv); |
9443 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback()); | 9443 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9444 EXPECT_EQ(0, rv); | 9444 EXPECT_EQ(0, rv); |
9445 | 9445 |
9446 // Finally, the socket is released to the group. | 9446 // Finally, the socket is released to the group. |
9447 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9447 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9448 } | 9448 } |
9449 | 9449 |
9450 // This tests the case that a request is issued via http instead of spdy after | 9450 // This tests the case that a request is issued via http instead of spdy after |
9451 // npn is negotiated. | 9451 // npn is negotiated. |
9452 TEST_F(HttpNetworkTransactionSpdy3Test, NpnWithHttpOverSSL) { | 9452 TEST_F(HttpNetworkTransactionSpdy3Test, NpnWithHttpOverSSL) { |
9453 HttpStreamFactory::set_use_alternate_protocols(true); | 9453 HttpStreamFactory::set_use_alternate_protocols(true); |
(...skipping 25 matching lines...) Expand all Loading... |
9479 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9479 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9480 | 9480 |
9481 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 9481 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
9482 data_writes, arraysize(data_writes)); | 9482 data_writes, arraysize(data_writes)); |
9483 session_deps_.socket_factory->AddSocketDataProvider(&data); | 9483 session_deps_.socket_factory->AddSocketDataProvider(&data); |
9484 | 9484 |
9485 TestCompletionCallback callback; | 9485 TestCompletionCallback callback; |
9486 | 9486 |
9487 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9487 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
9488 scoped_ptr<HttpTransaction> trans( | 9488 scoped_ptr<HttpTransaction> trans( |
9489 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9489 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9490 | 9490 |
9491 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9491 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9492 | 9492 |
9493 EXPECT_EQ(ERR_IO_PENDING, rv); | 9493 EXPECT_EQ(ERR_IO_PENDING, rv); |
9494 EXPECT_EQ(OK, callback.WaitForResult()); | 9494 EXPECT_EQ(OK, callback.WaitForResult()); |
9495 | 9495 |
9496 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9496 const HttpResponseInfo* response = trans->GetResponseInfo(); |
9497 ASSERT_TRUE(response != NULL); | 9497 ASSERT_TRUE(response != NULL); |
9498 ASSERT_TRUE(response->headers != NULL); | 9498 ASSERT_TRUE(response->headers.get() != NULL); |
9499 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9499 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
9500 | 9500 |
9501 std::string response_data; | 9501 std::string response_data; |
9502 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9502 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
9503 EXPECT_EQ("hello world", response_data); | 9503 EXPECT_EQ("hello world", response_data); |
9504 | 9504 |
9505 EXPECT_FALSE(response->was_fetched_via_spdy); | 9505 EXPECT_FALSE(response->was_fetched_via_spdy); |
9506 EXPECT_TRUE(response->was_npn_negotiated); | 9506 EXPECT_TRUE(response->was_npn_negotiated); |
9507 } | 9507 } |
9508 | 9508 |
(...skipping 24 matching lines...) Expand all Loading... |
9533 DelayedSocketData spdy_data( | 9533 DelayedSocketData spdy_data( |
9534 0, // don't wait in this case, immediate hangup. | 9534 0, // don't wait in this case, immediate hangup. |
9535 spdy_reads, arraysize(spdy_reads), | 9535 spdy_reads, arraysize(spdy_reads), |
9536 spdy_writes, arraysize(spdy_writes)); | 9536 spdy_writes, arraysize(spdy_writes)); |
9537 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 9537 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
9538 | 9538 |
9539 TestCompletionCallback callback; | 9539 TestCompletionCallback callback; |
9540 | 9540 |
9541 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9541 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
9542 scoped_ptr<HttpTransaction> trans( | 9542 scoped_ptr<HttpTransaction> trans( |
9543 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9543 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9544 | 9544 |
9545 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9545 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9546 EXPECT_EQ(ERR_IO_PENDING, rv); | 9546 EXPECT_EQ(ERR_IO_PENDING, rv); |
9547 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 9547 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
9548 } | 9548 } |
9549 | 9549 |
9550 TEST_F(HttpNetworkTransactionSpdy3Test, SpdyAlternateProtocolThroughProxy) { | 9550 TEST_F(HttpNetworkTransactionSpdy3Test, SpdyAlternateProtocolThroughProxy) { |
9551 // This test ensures that the URL passed into the proxy is upgraded | 9551 // This test ensures that the URL passed into the proxy is upgraded |
9552 // to https when doing an Alternate Protocol upgrade. | 9552 // to https when doing an Alternate Protocol upgrade. |
9553 HttpStreamFactory::set_use_alternate_protocols(true); | 9553 HttpStreamFactory::set_use_alternate_protocols(true); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9664 session_deps_.socket_factory->AddSocketDataProvider(&data_1); | 9664 session_deps_.socket_factory->AddSocketDataProvider(&data_1); |
9665 session_deps_.socket_factory->AddSocketDataProvider(&data_2); | 9665 session_deps_.socket_factory->AddSocketDataProvider(&data_2); |
9666 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9666 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9667 session_deps_.socket_factory->AddSocketDataProvider( | 9667 session_deps_.socket_factory->AddSocketDataProvider( |
9668 &hanging_non_alternate_protocol_socket); | 9668 &hanging_non_alternate_protocol_socket); |
9669 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9669 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
9670 | 9670 |
9671 // First round should work and provide the Alternate-Protocol state. | 9671 // First round should work and provide the Alternate-Protocol state. |
9672 TestCompletionCallback callback_1; | 9672 TestCompletionCallback callback_1; |
9673 scoped_ptr<HttpTransaction> trans_1( | 9673 scoped_ptr<HttpTransaction> trans_1( |
9674 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9674 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9675 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); | 9675 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); |
9676 EXPECT_EQ(ERR_IO_PENDING, rv); | 9676 EXPECT_EQ(ERR_IO_PENDING, rv); |
9677 EXPECT_EQ(OK, callback_1.WaitForResult()); | 9677 EXPECT_EQ(OK, callback_1.WaitForResult()); |
9678 | 9678 |
9679 // Second round should attempt a tunnel connect and get an auth challenge. | 9679 // Second round should attempt a tunnel connect and get an auth challenge. |
9680 TestCompletionCallback callback_2; | 9680 TestCompletionCallback callback_2; |
9681 scoped_ptr<HttpTransaction> trans_2( | 9681 scoped_ptr<HttpTransaction> trans_2( |
9682 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9682 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9683 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); | 9683 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); |
9684 EXPECT_EQ(ERR_IO_PENDING, rv); | 9684 EXPECT_EQ(ERR_IO_PENDING, rv); |
9685 EXPECT_EQ(OK, callback_2.WaitForResult()); | 9685 EXPECT_EQ(OK, callback_2.WaitForResult()); |
9686 const HttpResponseInfo* response = trans_2->GetResponseInfo(); | 9686 const HttpResponseInfo* response = trans_2->GetResponseInfo(); |
9687 ASSERT_TRUE(response != NULL); | 9687 ASSERT_TRUE(response != NULL); |
9688 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 9688 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
9689 | 9689 |
9690 // Restart with auth. Tunnel should work and response received. | 9690 // Restart with auth. Tunnel should work and response received. |
9691 TestCompletionCallback callback_3; | 9691 TestCompletionCallback callback_3; |
9692 rv = trans_2->RestartWithAuth( | 9692 rv = trans_2->RestartWithAuth( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9770 MockRead(SYNCHRONOUS, OK), | 9770 MockRead(SYNCHRONOUS, OK), |
9771 }; | 9771 }; |
9772 | 9772 |
9773 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 9773 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
9774 data_writes1, arraysize(data_writes1)); | 9774 data_writes1, arraysize(data_writes1)); |
9775 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 9775 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
9776 | 9776 |
9777 TestCompletionCallback callback1; | 9777 TestCompletionCallback callback1; |
9778 | 9778 |
9779 scoped_ptr<HttpTransaction> trans( | 9779 scoped_ptr<HttpTransaction> trans( |
9780 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9780 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9781 | 9781 |
9782 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 9782 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
9783 EXPECT_EQ(ERR_IO_PENDING, rv); | 9783 EXPECT_EQ(ERR_IO_PENDING, rv); |
9784 | 9784 |
9785 rv = callback1.WaitForResult(); | 9785 rv = callback1.WaitForResult(); |
9786 EXPECT_EQ(OK, rv); | 9786 EXPECT_EQ(OK, rv); |
9787 | 9787 |
9788 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9788 const HttpResponseInfo* response = trans->GetResponseInfo(); |
9789 ASSERT_TRUE(response != NULL); | 9789 ASSERT_TRUE(response != NULL); |
9790 | 9790 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9834 | 9834 |
9835 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 9835 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
9836 data_writes1, arraysize(data_writes1)); | 9836 data_writes1, arraysize(data_writes1)); |
9837 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 9837 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
9838 SSLSocketDataProvider ssl(ASYNC, OK); | 9838 SSLSocketDataProvider ssl(ASYNC, OK); |
9839 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9839 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9840 | 9840 |
9841 TestCompletionCallback callback1; | 9841 TestCompletionCallback callback1; |
9842 | 9842 |
9843 scoped_ptr<HttpTransaction> trans( | 9843 scoped_ptr<HttpTransaction> trans( |
9844 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9844 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9845 | 9845 |
9846 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 9846 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
9847 EXPECT_EQ(ERR_IO_PENDING, rv); | 9847 EXPECT_EQ(ERR_IO_PENDING, rv); |
9848 | 9848 |
9849 rv = callback1.WaitForResult(); | 9849 rv = callback1.WaitForResult(); |
9850 EXPECT_EQ(OK, rv); | 9850 EXPECT_EQ(OK, rv); |
9851 CapturingNetLog::CapturedEntryList entries; | 9851 CapturingNetLog::CapturedEntryList entries; |
9852 log.GetEntries(&entries); | 9852 log.GetEntries(&entries); |
9853 size_t pos = ExpectLogContainsSomewhere( | 9853 size_t pos = ExpectLogContainsSomewhere( |
9854 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 9854 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9904 | 9904 |
9905 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 9905 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
9906 data_writes1, arraysize(data_writes1)); | 9906 data_writes1, arraysize(data_writes1)); |
9907 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 9907 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
9908 SSLSocketDataProvider ssl(ASYNC, OK); | 9908 SSLSocketDataProvider ssl(ASYNC, OK); |
9909 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9909 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9910 | 9910 |
9911 TestCompletionCallback callback1; | 9911 TestCompletionCallback callback1; |
9912 | 9912 |
9913 scoped_ptr<HttpTransaction> trans( | 9913 scoped_ptr<HttpTransaction> trans( |
9914 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9914 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9915 | 9915 |
9916 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 9916 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
9917 EXPECT_EQ(ERR_IO_PENDING, rv); | 9917 EXPECT_EQ(ERR_IO_PENDING, rv); |
9918 | 9918 |
9919 rv = callback1.WaitForResult(); | 9919 rv = callback1.WaitForResult(); |
9920 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 9920 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
9921 CapturingNetLog::CapturedEntryList entries; | 9921 CapturingNetLog::CapturedEntryList entries; |
9922 log.GetEntries(&entries); | 9922 log.GetEntries(&entries); |
9923 size_t pos = ExpectLogContainsSomewhere( | 9923 size_t pos = ExpectLogContainsSomewhere( |
9924 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 9924 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9981 | 9981 |
9982 HttpRequestInfo request; | 9982 HttpRequestInfo request; |
9983 request.method = "GET"; | 9983 request.method = "GET"; |
9984 request.url = GURL("https://www.google.com/"); | 9984 request.url = GURL("https://www.google.com/"); |
9985 request.load_flags = 0; | 9985 request.load_flags = 0; |
9986 | 9986 |
9987 // This is the important line that marks this as a preconnect. | 9987 // This is the important line that marks this as a preconnect. |
9988 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; | 9988 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; |
9989 | 9989 |
9990 scoped_ptr<HttpTransaction> trans( | 9990 scoped_ptr<HttpTransaction> trans( |
9991 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9991 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9992 | 9992 |
9993 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9993 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9994 EXPECT_EQ(ERR_IO_PENDING, rv); | 9994 EXPECT_EQ(ERR_IO_PENDING, rv); |
9995 EXPECT_EQ(OK, callback.WaitForResult()); | 9995 EXPECT_EQ(OK, callback.WaitForResult()); |
9996 } | 9996 } |
9997 | 9997 |
9998 // Given a net error, cause that error to be returned from the first Write() | 9998 // Given a net error, cause that error to be returned from the first Write() |
9999 // call and verify that the HttpTransaction fails with that error. | 9999 // call and verify that the HttpTransaction fails with that error. |
10000 void HttpNetworkTransactionSpdy3Test::CheckErrorIsPassedBack( | 10000 void HttpNetworkTransactionSpdy3Test::CheckErrorIsPassedBack( |
10001 int error, IoMode mode) { | 10001 int error, IoMode mode) { |
10002 net::HttpRequestInfo request_info; | 10002 net::HttpRequestInfo request_info; |
10003 request_info.url = GURL("https://www.example.com/"); | 10003 request_info.url = GURL("https://www.example.com/"); |
10004 request_info.method = "GET"; | 10004 request_info.method = "GET"; |
10005 request_info.load_flags = net::LOAD_NORMAL; | 10005 request_info.load_flags = net::LOAD_NORMAL; |
10006 | 10006 |
10007 | 10007 |
10008 SSLSocketDataProvider ssl_data(mode, OK); | 10008 SSLSocketDataProvider ssl_data(mode, OK); |
10009 net::MockWrite data_writes[] = { | 10009 net::MockWrite data_writes[] = { |
10010 net::MockWrite(mode, error), | 10010 net::MockWrite(mode, error), |
10011 }; | 10011 }; |
10012 net::StaticSocketDataProvider data(NULL, 0, | 10012 net::StaticSocketDataProvider data(NULL, 0, |
10013 data_writes, arraysize(data_writes)); | 10013 data_writes, arraysize(data_writes)); |
10014 session_deps_.socket_factory->AddSocketDataProvider(&data); | 10014 session_deps_.socket_factory->AddSocketDataProvider(&data); |
10015 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data); | 10015 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data); |
10016 | 10016 |
10017 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10017 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10018 scoped_ptr<HttpTransaction> trans( | 10018 scoped_ptr<HttpTransaction> trans( |
10019 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10019 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10020 | 10020 |
10021 TestCompletionCallback callback; | 10021 TestCompletionCallback callback; |
10022 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10022 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10023 if (rv == net::ERR_IO_PENDING) | 10023 if (rv == net::ERR_IO_PENDING) |
10024 rv = callback.WaitForResult(); | 10024 rv = callback.WaitForResult(); |
10025 ASSERT_EQ(error, rv); | 10025 ASSERT_EQ(error, rv); |
10026 } | 10026 } |
10027 | 10027 |
10028 TEST_F(HttpNetworkTransactionSpdy3Test, SSLWriteCertError) { | 10028 TEST_F(HttpNetworkTransactionSpdy3Test, SSLWriteCertError) { |
10029 // Just check a grab bag of cert errors. | 10029 // Just check a grab bag of cert errors. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10104 | 10104 |
10105 // Need one more if TLSv1.2 is enabled. | 10105 // Need one more if TLSv1.2 is enabled. |
10106 SSLSocketDataProvider ssl_data5(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 10106 SSLSocketDataProvider ssl_data5(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
10107 ssl_data5.cert_request_info = cert_request.get(); | 10107 ssl_data5.cert_request_info = cert_request.get(); |
10108 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); | 10108 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
10109 net::StaticSocketDataProvider data5(NULL, 0, NULL, 0); | 10109 net::StaticSocketDataProvider data5(NULL, 0, NULL, 0); |
10110 session_deps_.socket_factory->AddSocketDataProvider(&data5); | 10110 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
10111 | 10111 |
10112 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10112 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10113 scoped_ptr<HttpTransaction> trans( | 10113 scoped_ptr<HttpTransaction> trans( |
10114 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10114 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10115 | 10115 |
10116 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 10116 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
10117 TestCompletionCallback callback; | 10117 TestCompletionCallback callback; |
10118 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10118 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10119 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10119 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10120 | 10120 |
10121 // Complete the SSL handshake, which should abort due to requiring a | 10121 // Complete the SSL handshake, which should abort due to requiring a |
10122 // client certificate. | 10122 // client certificate. |
10123 rv = callback.WaitForResult(); | 10123 rv = callback.WaitForResult(); |
10124 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 10124 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10225 // Need one more if TLSv1.2 is enabled. | 10225 // Need one more if TLSv1.2 is enabled. |
10226 SSLSocketDataProvider ssl_data5(ASYNC, net::OK); | 10226 SSLSocketDataProvider ssl_data5(ASYNC, net::OK); |
10227 ssl_data5.cert_request_info = cert_request.get(); | 10227 ssl_data5.cert_request_info = cert_request.get(); |
10228 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); | 10228 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
10229 net::StaticSocketDataProvider data5( | 10229 net::StaticSocketDataProvider data5( |
10230 data2_reads, arraysize(data2_reads), NULL, 0); | 10230 data2_reads, arraysize(data2_reads), NULL, 0); |
10231 session_deps_.socket_factory->AddSocketDataProvider(&data5); | 10231 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
10232 | 10232 |
10233 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10233 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10234 scoped_ptr<HttpTransaction> trans( | 10234 scoped_ptr<HttpTransaction> trans( |
10235 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10235 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10236 | 10236 |
10237 // Begin the initial SSL handshake. | 10237 // Begin the initial SSL handshake. |
10238 TestCompletionCallback callback; | 10238 TestCompletionCallback callback; |
10239 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10239 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10240 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10240 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10241 | 10241 |
10242 // Complete the SSL handshake, which should abort due to requiring a | 10242 // Complete the SSL handshake, which should abort due to requiring a |
10243 // client certificate. | 10243 // client certificate. |
10244 rv = callback.WaitForResult(); | 10244 rv = callback.WaitForResult(); |
10245 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 10245 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10319 requests[0].load_flags = net::LOAD_NORMAL; | 10319 requests[0].load_flags = net::LOAD_NORMAL; |
10320 | 10320 |
10321 requests[1].url = GURL("http://www.example.com/"); | 10321 requests[1].url = GURL("http://www.example.com/"); |
10322 requests[1].method = "GET"; | 10322 requests[1].method = "GET"; |
10323 requests[1].load_flags = net::LOAD_NORMAL; | 10323 requests[1].load_flags = net::LOAD_NORMAL; |
10324 | 10324 |
10325 for (size_t i = 0; i < arraysize(requests); ++i) { | 10325 for (size_t i = 0; i < arraysize(requests); ++i) { |
10326 session_deps_.socket_factory->ResetNextMockIndexes(); | 10326 session_deps_.socket_factory->ResetNextMockIndexes(); |
10327 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10327 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10328 scoped_ptr<HttpNetworkTransaction> trans( | 10328 scoped_ptr<HttpNetworkTransaction> trans( |
10329 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10329 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10330 | 10330 |
10331 // Begin the SSL handshake with the proxy. | 10331 // Begin the SSL handshake with the proxy. |
10332 TestCompletionCallback callback; | 10332 TestCompletionCallback callback; |
10333 int rv = trans->Start( | 10333 int rv = trans->Start( |
10334 &requests[i], callback.callback(), net::BoundNetLog()); | 10334 &requests[i], callback.callback(), net::BoundNetLog()); |
10335 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10335 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10336 | 10336 |
10337 // Complete the SSL handshake, which should abort due to requiring a | 10337 // Complete the SSL handshake, which should abort due to requiring a |
10338 // client certificate. | 10338 // client certificate. |
10339 rv = callback.WaitForResult(); | 10339 rv = callback.WaitForResult(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10414 connect, | 10414 connect, |
10415 spdy_reads, arraysize(spdy_reads), | 10415 spdy_reads, arraysize(spdy_reads), |
10416 spdy_writes, arraysize(spdy_writes)); | 10416 spdy_writes, arraysize(spdy_writes)); |
10417 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10417 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
10418 | 10418 |
10419 TestCompletionCallback callback; | 10419 TestCompletionCallback callback; |
10420 HttpRequestInfo request1; | 10420 HttpRequestInfo request1; |
10421 request1.method = "GET"; | 10421 request1.method = "GET"; |
10422 request1.url = GURL("https://www.google.com/"); | 10422 request1.url = GURL("https://www.google.com/"); |
10423 request1.load_flags = 0; | 10423 request1.load_flags = 0; |
10424 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 10424 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
10425 | 10425 |
10426 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 10426 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
10427 EXPECT_EQ(ERR_IO_PENDING, rv); | 10427 EXPECT_EQ(ERR_IO_PENDING, rv); |
10428 EXPECT_EQ(OK, callback.WaitForResult()); | 10428 EXPECT_EQ(OK, callback.WaitForResult()); |
10429 | 10429 |
10430 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 10430 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
10431 ASSERT_TRUE(response != NULL); | 10431 ASSERT_TRUE(response != NULL); |
10432 ASSERT_TRUE(response->headers != NULL); | 10432 ASSERT_TRUE(response->headers.get() != NULL); |
10433 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10433 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10434 | 10434 |
10435 std::string response_data; | 10435 std::string response_data; |
10436 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 10436 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
10437 EXPECT_EQ("hello!", response_data); | 10437 EXPECT_EQ("hello!", response_data); |
10438 | 10438 |
10439 // Preload www.gmail.com into HostCache. | 10439 // Preload www.gmail.com into HostCache. |
10440 HostPortPair host_port("www.gmail.com", 443); | 10440 HostPortPair host_port("www.gmail.com", 443); |
10441 HostResolver::RequestInfo resolve_info(host_port); | 10441 HostResolver::RequestInfo resolve_info(host_port); |
10442 AddressList ignored; | 10442 AddressList ignored; |
10443 rv = session_deps_.host_resolver->Resolve(resolve_info, &ignored, | 10443 rv = session_deps_.host_resolver->Resolve(resolve_info, &ignored, |
10444 callback.callback(), NULL, | 10444 callback.callback(), NULL, |
10445 BoundNetLog()); | 10445 BoundNetLog()); |
10446 EXPECT_EQ(ERR_IO_PENDING, rv); | 10446 EXPECT_EQ(ERR_IO_PENDING, rv); |
10447 rv = callback.WaitForResult(); | 10447 rv = callback.WaitForResult(); |
10448 EXPECT_EQ(OK, rv); | 10448 EXPECT_EQ(OK, rv); |
10449 | 10449 |
10450 HttpRequestInfo request2; | 10450 HttpRequestInfo request2; |
10451 request2.method = "GET"; | 10451 request2.method = "GET"; |
10452 request2.url = GURL("https://www.gmail.com/"); | 10452 request2.url = GURL("https://www.gmail.com/"); |
10453 request2.load_flags = 0; | 10453 request2.load_flags = 0; |
10454 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 10454 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
10455 | 10455 |
10456 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 10456 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
10457 EXPECT_EQ(ERR_IO_PENDING, rv); | 10457 EXPECT_EQ(ERR_IO_PENDING, rv); |
10458 EXPECT_EQ(OK, callback.WaitForResult()); | 10458 EXPECT_EQ(OK, callback.WaitForResult()); |
10459 | 10459 |
10460 response = trans2.GetResponseInfo(); | 10460 response = trans2.GetResponseInfo(); |
10461 ASSERT_TRUE(response != NULL); | 10461 ASSERT_TRUE(response != NULL); |
10462 ASSERT_TRUE(response->headers != NULL); | 10462 ASSERT_TRUE(response->headers.get() != NULL); |
10463 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10463 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10464 EXPECT_TRUE(response->was_fetched_via_spdy); | 10464 EXPECT_TRUE(response->was_fetched_via_spdy); |
10465 EXPECT_TRUE(response->was_npn_negotiated); | 10465 EXPECT_TRUE(response->was_npn_negotiated); |
10466 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 10466 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
10467 EXPECT_EQ("hello!", response_data); | 10467 EXPECT_EQ("hello!", response_data); |
10468 } | 10468 } |
10469 | 10469 |
10470 TEST_F(HttpNetworkTransactionSpdy3Test, UseIPConnectionPoolingAfterResolution) { | 10470 TEST_F(HttpNetworkTransactionSpdy3Test, UseIPConnectionPoolingAfterResolution) { |
10471 HttpStreamFactory::set_use_alternate_protocols(true); | 10471 HttpStreamFactory::set_use_alternate_protocols(true); |
10472 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 10472 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10509 connect, | 10509 connect, |
10510 spdy_reads, arraysize(spdy_reads), | 10510 spdy_reads, arraysize(spdy_reads), |
10511 spdy_writes, arraysize(spdy_writes)); | 10511 spdy_writes, arraysize(spdy_writes)); |
10512 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10512 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
10513 | 10513 |
10514 TestCompletionCallback callback; | 10514 TestCompletionCallback callback; |
10515 HttpRequestInfo request1; | 10515 HttpRequestInfo request1; |
10516 request1.method = "GET"; | 10516 request1.method = "GET"; |
10517 request1.url = GURL("https://www.google.com/"); | 10517 request1.url = GURL("https://www.google.com/"); |
10518 request1.load_flags = 0; | 10518 request1.load_flags = 0; |
10519 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 10519 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
10520 | 10520 |
10521 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 10521 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
10522 EXPECT_EQ(ERR_IO_PENDING, rv); | 10522 EXPECT_EQ(ERR_IO_PENDING, rv); |
10523 EXPECT_EQ(OK, callback.WaitForResult()); | 10523 EXPECT_EQ(OK, callback.WaitForResult()); |
10524 | 10524 |
10525 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 10525 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
10526 ASSERT_TRUE(response != NULL); | 10526 ASSERT_TRUE(response != NULL); |
10527 ASSERT_TRUE(response->headers != NULL); | 10527 ASSERT_TRUE(response->headers.get() != NULL); |
10528 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10528 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10529 | 10529 |
10530 std::string response_data; | 10530 std::string response_data; |
10531 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 10531 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
10532 EXPECT_EQ("hello!", response_data); | 10532 EXPECT_EQ("hello!", response_data); |
10533 | 10533 |
10534 HttpRequestInfo request2; | 10534 HttpRequestInfo request2; |
10535 request2.method = "GET"; | 10535 request2.method = "GET"; |
10536 request2.url = GURL("https://www.gmail.com/"); | 10536 request2.url = GURL("https://www.gmail.com/"); |
10537 request2.load_flags = 0; | 10537 request2.load_flags = 0; |
10538 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 10538 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
10539 | 10539 |
10540 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 10540 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
10541 EXPECT_EQ(ERR_IO_PENDING, rv); | 10541 EXPECT_EQ(ERR_IO_PENDING, rv); |
10542 EXPECT_EQ(OK, callback.WaitForResult()); | 10542 EXPECT_EQ(OK, callback.WaitForResult()); |
10543 | 10543 |
10544 response = trans2.GetResponseInfo(); | 10544 response = trans2.GetResponseInfo(); |
10545 ASSERT_TRUE(response != NULL); | 10545 ASSERT_TRUE(response != NULL); |
10546 ASSERT_TRUE(response->headers != NULL); | 10546 ASSERT_TRUE(response->headers.get() != NULL); |
10547 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10547 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10548 EXPECT_TRUE(response->was_fetched_via_spdy); | 10548 EXPECT_TRUE(response->was_fetched_via_spdy); |
10549 EXPECT_TRUE(response->was_npn_negotiated); | 10549 EXPECT_TRUE(response->was_npn_negotiated); |
10550 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 10550 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
10551 EXPECT_EQ("hello!", response_data); | 10551 EXPECT_EQ("hello!", response_data); |
10552 } | 10552 } |
10553 | 10553 |
10554 class OneTimeCachingHostResolver : public net::HostResolver { | 10554 class OneTimeCachingHostResolver : public net::HostResolver { |
10555 public: | 10555 public: |
10556 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) | 10556 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10637 connect, | 10637 connect, |
10638 spdy_reads, arraysize(spdy_reads), | 10638 spdy_reads, arraysize(spdy_reads), |
10639 spdy_writes, arraysize(spdy_writes)); | 10639 spdy_writes, arraysize(spdy_writes)); |
10640 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10640 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
10641 | 10641 |
10642 TestCompletionCallback callback; | 10642 TestCompletionCallback callback; |
10643 HttpRequestInfo request1; | 10643 HttpRequestInfo request1; |
10644 request1.method = "GET"; | 10644 request1.method = "GET"; |
10645 request1.url = GURL("https://www.google.com/"); | 10645 request1.url = GURL("https://www.google.com/"); |
10646 request1.load_flags = 0; | 10646 request1.load_flags = 0; |
10647 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 10647 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
10648 | 10648 |
10649 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 10649 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
10650 EXPECT_EQ(ERR_IO_PENDING, rv); | 10650 EXPECT_EQ(ERR_IO_PENDING, rv); |
10651 EXPECT_EQ(OK, callback.WaitForResult()); | 10651 EXPECT_EQ(OK, callback.WaitForResult()); |
10652 | 10652 |
10653 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 10653 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
10654 ASSERT_TRUE(response != NULL); | 10654 ASSERT_TRUE(response != NULL); |
10655 ASSERT_TRUE(response->headers != NULL); | 10655 ASSERT_TRUE(response->headers.get() != NULL); |
10656 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10656 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10657 | 10657 |
10658 std::string response_data; | 10658 std::string response_data; |
10659 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 10659 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
10660 EXPECT_EQ("hello!", response_data); | 10660 EXPECT_EQ("hello!", response_data); |
10661 | 10661 |
10662 // Preload cache entries into HostCache. | 10662 // Preload cache entries into HostCache. |
10663 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); | 10663 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); |
10664 AddressList ignored; | 10664 AddressList ignored; |
10665 rv = host_resolver.Resolve(resolve_info, &ignored, callback.callback(), NULL, | 10665 rv = host_resolver.Resolve(resolve_info, &ignored, callback.callback(), NULL, |
10666 BoundNetLog()); | 10666 BoundNetLog()); |
10667 EXPECT_EQ(ERR_IO_PENDING, rv); | 10667 EXPECT_EQ(ERR_IO_PENDING, rv); |
10668 rv = callback.WaitForResult(); | 10668 rv = callback.WaitForResult(); |
10669 EXPECT_EQ(OK, rv); | 10669 EXPECT_EQ(OK, rv); |
10670 | 10670 |
10671 HttpRequestInfo request2; | 10671 HttpRequestInfo request2; |
10672 request2.method = "GET"; | 10672 request2.method = "GET"; |
10673 request2.url = GURL("https://www.gmail.com/"); | 10673 request2.url = GURL("https://www.gmail.com/"); |
10674 request2.load_flags = 0; | 10674 request2.load_flags = 0; |
10675 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 10675 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
10676 | 10676 |
10677 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 10677 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
10678 EXPECT_EQ(ERR_IO_PENDING, rv); | 10678 EXPECT_EQ(ERR_IO_PENDING, rv); |
10679 EXPECT_EQ(OK, callback.WaitForResult()); | 10679 EXPECT_EQ(OK, callback.WaitForResult()); |
10680 | 10680 |
10681 response = trans2.GetResponseInfo(); | 10681 response = trans2.GetResponseInfo(); |
10682 ASSERT_TRUE(response != NULL); | 10682 ASSERT_TRUE(response != NULL); |
10683 ASSERT_TRUE(response->headers != NULL); | 10683 ASSERT_TRUE(response->headers.get() != NULL); |
10684 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10684 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10685 EXPECT_TRUE(response->was_fetched_via_spdy); | 10685 EXPECT_TRUE(response->was_fetched_via_spdy); |
10686 EXPECT_TRUE(response->was_npn_negotiated); | 10686 EXPECT_TRUE(response->was_npn_negotiated); |
10687 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 10687 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
10688 EXPECT_EQ("hello!", response_data); | 10688 EXPECT_EQ("hello!", response_data); |
10689 } | 10689 } |
10690 | 10690 |
10691 TEST_F(HttpNetworkTransactionSpdy3Test, ReadPipelineEvictionFallback) { | 10691 TEST_F(HttpNetworkTransactionSpdy3Test, ReadPipelineEvictionFallback) { |
10692 MockRead data_reads1[] = { | 10692 MockRead data_reads1[] = { |
10693 MockRead(SYNCHRONOUS, ERR_PIPELINE_EVICTION), | 10693 MockRead(SYNCHRONOUS, ERR_PIPELINE_EVICTION), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10785 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 10785 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
10786 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 10786 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
10787 | 10787 |
10788 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10788 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10789 | 10789 |
10790 // Start the first transaction to set up the SpdySession | 10790 // Start the first transaction to set up the SpdySession |
10791 HttpRequestInfo request1; | 10791 HttpRequestInfo request1; |
10792 request1.method = "GET"; | 10792 request1.method = "GET"; |
10793 request1.url = GURL(https_url); | 10793 request1.url = GURL(https_url); |
10794 request1.load_flags = 0; | 10794 request1.load_flags = 0; |
10795 HttpNetworkTransaction trans1(LOWEST, session); | 10795 HttpNetworkTransaction trans1(LOWEST, session.get()); |
10796 TestCompletionCallback callback1; | 10796 TestCompletionCallback callback1; |
10797 EXPECT_EQ(ERR_IO_PENDING, | 10797 EXPECT_EQ(ERR_IO_PENDING, |
10798 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 10798 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
10799 base::MessageLoop::current()->RunUntilIdle(); | 10799 base::MessageLoop::current()->RunUntilIdle(); |
10800 | 10800 |
10801 EXPECT_EQ(OK, callback1.WaitForResult()); | 10801 EXPECT_EQ(OK, callback1.WaitForResult()); |
10802 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 10802 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
10803 | 10803 |
10804 // Now, start the HTTP request | 10804 // Now, start the HTTP request |
10805 HttpRequestInfo request2; | 10805 HttpRequestInfo request2; |
10806 request2.method = "GET"; | 10806 request2.method = "GET"; |
10807 request2.url = GURL(httpUrl); | 10807 request2.url = GURL(httpUrl); |
10808 request2.load_flags = 0; | 10808 request2.load_flags = 0; |
10809 HttpNetworkTransaction trans2(MEDIUM, session); | 10809 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
10810 TestCompletionCallback callback2; | 10810 TestCompletionCallback callback2; |
10811 EXPECT_EQ(ERR_IO_PENDING, | 10811 EXPECT_EQ(ERR_IO_PENDING, |
10812 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10812 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
10813 base::MessageLoop::current()->RunUntilIdle(); | 10813 base::MessageLoop::current()->RunUntilIdle(); |
10814 | 10814 |
10815 EXPECT_EQ(OK, callback2.WaitForResult()); | 10815 EXPECT_EQ(OK, callback2.WaitForResult()); |
10816 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10816 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
10817 } | 10817 } |
10818 | 10818 |
10819 TEST_F(HttpNetworkTransactionSpdy3Test, DoNotUseSpdySessionForHttpOverTunnel) { | 10819 TEST_F(HttpNetworkTransactionSpdy3Test, DoNotUseSpdySessionForHttpOverTunnel) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10870 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1); | 10870 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1); |
10871 | 10871 |
10872 scoped_refptr<HttpNetworkSession> session( | 10872 scoped_refptr<HttpNetworkSession> session( |
10873 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); | 10873 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); |
10874 | 10874 |
10875 // Start the first transaction to set up the SpdySession | 10875 // Start the first transaction to set up the SpdySession |
10876 HttpRequestInfo request1; | 10876 HttpRequestInfo request1; |
10877 request1.method = "GET"; | 10877 request1.method = "GET"; |
10878 request1.url = GURL(https_url); | 10878 request1.url = GURL(https_url); |
10879 request1.load_flags = 0; | 10879 request1.load_flags = 0; |
10880 HttpNetworkTransaction trans1(LOWEST, session); | 10880 HttpNetworkTransaction trans1(LOWEST, session.get()); |
10881 TestCompletionCallback callback1; | 10881 TestCompletionCallback callback1; |
10882 EXPECT_EQ(ERR_IO_PENDING, | 10882 EXPECT_EQ(ERR_IO_PENDING, |
10883 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 10883 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
10884 base::MessageLoop::current()->RunUntilIdle(); | 10884 base::MessageLoop::current()->RunUntilIdle(); |
10885 data1.RunFor(4); | 10885 data1.RunFor(4); |
10886 | 10886 |
10887 EXPECT_EQ(OK, callback1.WaitForResult()); | 10887 EXPECT_EQ(OK, callback1.WaitForResult()); |
10888 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 10888 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
10889 | 10889 |
10890 LoadTimingInfo load_timing_info1; | 10890 LoadTimingInfo load_timing_info1; |
10891 EXPECT_TRUE(trans1.GetLoadTimingInfo(&load_timing_info1)); | 10891 EXPECT_TRUE(trans1.GetLoadTimingInfo(&load_timing_info1)); |
10892 TestLoadTimingNotReusedWithPac(load_timing_info1, | 10892 TestLoadTimingNotReusedWithPac(load_timing_info1, |
10893 CONNECT_TIMING_HAS_SSL_TIMES); | 10893 CONNECT_TIMING_HAS_SSL_TIMES); |
10894 | 10894 |
10895 // Now, start the HTTP request | 10895 // Now, start the HTTP request |
10896 HttpRequestInfo request2; | 10896 HttpRequestInfo request2; |
10897 request2.method = "GET"; | 10897 request2.method = "GET"; |
10898 request2.url = GURL(httpUrl); | 10898 request2.url = GURL(httpUrl); |
10899 request2.load_flags = 0; | 10899 request2.load_flags = 0; |
10900 HttpNetworkTransaction trans2(MEDIUM, session); | 10900 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
10901 TestCompletionCallback callback2; | 10901 TestCompletionCallback callback2; |
10902 EXPECT_EQ(ERR_IO_PENDING, | 10902 EXPECT_EQ(ERR_IO_PENDING, |
10903 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10903 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
10904 base::MessageLoop::current()->RunUntilIdle(); | 10904 base::MessageLoop::current()->RunUntilIdle(); |
10905 data1.RunFor(3); | 10905 data1.RunFor(3); |
10906 | 10906 |
10907 EXPECT_EQ(OK, callback2.WaitForResult()); | 10907 EXPECT_EQ(OK, callback2.WaitForResult()); |
10908 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10908 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
10909 | 10909 |
10910 // HTTP requests over a SPDY session should have a different connection | 10910 // HTTP requests over a SPDY session should have a different connection |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10952 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 10952 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
10953 session_deps_.socket_factory->AddSocketDataProvider(&data); | 10953 session_deps_.socket_factory->AddSocketDataProvider(&data); |
10954 | 10954 |
10955 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10955 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10956 | 10956 |
10957 // Start the first transaction to set up the SpdySession | 10957 // Start the first transaction to set up the SpdySession |
10958 HttpRequestInfo request1; | 10958 HttpRequestInfo request1; |
10959 request1.method = "GET"; | 10959 request1.method = "GET"; |
10960 request1.url = GURL(https_url); | 10960 request1.url = GURL(https_url); |
10961 request1.load_flags = 0; | 10961 request1.load_flags = 0; |
10962 HttpNetworkTransaction trans1(LOWEST, session); | 10962 HttpNetworkTransaction trans1(LOWEST, session.get()); |
10963 TestCompletionCallback callback1; | 10963 TestCompletionCallback callback1; |
10964 EXPECT_EQ(ERR_IO_PENDING, | 10964 EXPECT_EQ(ERR_IO_PENDING, |
10965 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 10965 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
10966 base::MessageLoop::current()->RunUntilIdle(); | 10966 base::MessageLoop::current()->RunUntilIdle(); |
10967 | 10967 |
10968 EXPECT_EQ(OK, callback1.WaitForResult()); | 10968 EXPECT_EQ(OK, callback1.WaitForResult()); |
10969 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 10969 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
10970 | 10970 |
10971 // Now, start the HTTP request | 10971 // Now, start the HTTP request |
10972 HttpRequestInfo request2; | 10972 HttpRequestInfo request2; |
10973 request2.method = "GET"; | 10973 request2.method = "GET"; |
10974 request2.url = GURL(http_url); | 10974 request2.url = GURL(http_url); |
10975 request2.load_flags = 0; | 10975 request2.load_flags = 0; |
10976 HttpNetworkTransaction trans2(MEDIUM, session); | 10976 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
10977 TestCompletionCallback callback2; | 10977 TestCompletionCallback callback2; |
10978 EXPECT_EQ(ERR_IO_PENDING, | 10978 EXPECT_EQ(ERR_IO_PENDING, |
10979 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10979 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
10980 base::MessageLoop::current()->RunUntilIdle(); | 10980 base::MessageLoop::current()->RunUntilIdle(); |
10981 | 10981 |
10982 EXPECT_EQ(OK, callback2.WaitForResult()); | 10982 EXPECT_EQ(OK, callback2.WaitForResult()); |
10983 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10983 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
10984 } | 10984 } |
10985 | 10985 |
10986 // Test that in the case where we have a SPDY session to a SPDY proxy | 10986 // Test that in the case where we have a SPDY session to a SPDY proxy |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11075 session_deps_.host_resolver->rules()->AddRule("proxy", ip_addr); | 11075 session_deps_.host_resolver->rules()->AddRule("proxy", ip_addr); |
11076 | 11076 |
11077 scoped_refptr<HttpNetworkSession> session( | 11077 scoped_refptr<HttpNetworkSession> session( |
11078 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); | 11078 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); |
11079 | 11079 |
11080 // Start the first transaction to set up the SpdySession | 11080 // Start the first transaction to set up the SpdySession |
11081 HttpRequestInfo request1; | 11081 HttpRequestInfo request1; |
11082 request1.method = "GET"; | 11082 request1.method = "GET"; |
11083 request1.url = GURL(url1); | 11083 request1.url = GURL(url1); |
11084 request1.load_flags = 0; | 11084 request1.load_flags = 0; |
11085 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 11085 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
11086 TestCompletionCallback callback1; | 11086 TestCompletionCallback callback1; |
11087 ASSERT_EQ(ERR_IO_PENDING, | 11087 ASSERT_EQ(ERR_IO_PENDING, |
11088 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 11088 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
11089 data1->RunFor(3); | 11089 data1->RunFor(3); |
11090 | 11090 |
11091 ASSERT_TRUE(callback1.have_result()); | 11091 ASSERT_TRUE(callback1.have_result()); |
11092 EXPECT_EQ(OK, callback1.WaitForResult()); | 11092 EXPECT_EQ(OK, callback1.WaitForResult()); |
11093 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 11093 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
11094 | 11094 |
11095 // Now, start the HTTP request | 11095 // Now, start the HTTP request |
11096 HttpRequestInfo request2; | 11096 HttpRequestInfo request2; |
11097 request2.method = "GET"; | 11097 request2.method = "GET"; |
11098 request2.url = GURL(url2); | 11098 request2.url = GURL(url2); |
11099 request2.load_flags = 0; | 11099 request2.load_flags = 0; |
11100 HttpNetworkTransaction trans2(MEDIUM, session); | 11100 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
11101 TestCompletionCallback callback2; | 11101 TestCompletionCallback callback2; |
11102 EXPECT_EQ(ERR_IO_PENDING, | 11102 EXPECT_EQ(ERR_IO_PENDING, |
11103 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11103 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11104 base::MessageLoop::current()->RunUntilIdle(); | 11104 base::MessageLoop::current()->RunUntilIdle(); |
11105 data2->RunFor(3); | 11105 data2->RunFor(3); |
11106 | 11106 |
11107 ASSERT_TRUE(callback2.have_result()); | 11107 ASSERT_TRUE(callback2.have_result()); |
11108 EXPECT_EQ(OK, callback2.WaitForResult()); | 11108 EXPECT_EQ(OK, callback2.WaitForResult()); |
11109 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11109 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11110 } | 11110 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11156 | 11156 |
11157 scoped_refptr<HttpNetworkSession> session( | 11157 scoped_refptr<HttpNetworkSession> session( |
11158 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); | 11158 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); |
11159 | 11159 |
11160 // Start the first transaction to set up the SpdySession and verify that | 11160 // Start the first transaction to set up the SpdySession and verify that |
11161 // connection was closed. | 11161 // connection was closed. |
11162 HttpRequestInfo request1; | 11162 HttpRequestInfo request1; |
11163 request1.method = "GET"; | 11163 request1.method = "GET"; |
11164 request1.url = GURL(https_url); | 11164 request1.url = GURL(https_url); |
11165 request1.load_flags = 0; | 11165 request1.load_flags = 0; |
11166 HttpNetworkTransaction trans1(MEDIUM, session); | 11166 HttpNetworkTransaction trans1(MEDIUM, session.get()); |
11167 TestCompletionCallback callback1; | 11167 TestCompletionCallback callback1; |
11168 EXPECT_EQ(ERR_IO_PENDING, | 11168 EXPECT_EQ(ERR_IO_PENDING, |
11169 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 11169 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
11170 base::MessageLoop::current()->RunUntilIdle(); | 11170 base::MessageLoop::current()->RunUntilIdle(); |
11171 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback1.WaitForResult()); | 11171 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback1.WaitForResult()); |
11172 | 11172 |
11173 // Now, start the second request and make sure it succeeds. | 11173 // Now, start the second request and make sure it succeeds. |
11174 HttpRequestInfo request2; | 11174 HttpRequestInfo request2; |
11175 request2.method = "GET"; | 11175 request2.method = "GET"; |
11176 request2.url = GURL(https_url); | 11176 request2.url = GURL(https_url); |
11177 request2.load_flags = 0; | 11177 request2.load_flags = 0; |
11178 HttpNetworkTransaction trans2(MEDIUM, session); | 11178 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
11179 TestCompletionCallback callback2; | 11179 TestCompletionCallback callback2; |
11180 EXPECT_EQ(ERR_IO_PENDING, | 11180 EXPECT_EQ(ERR_IO_PENDING, |
11181 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11181 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11182 base::MessageLoop::current()->RunUntilIdle(); | 11182 base::MessageLoop::current()->RunUntilIdle(); |
11183 data2->RunFor(3); | 11183 data2->RunFor(3); |
11184 | 11184 |
11185 ASSERT_TRUE(callback2.have_result()); | 11185 ASSERT_TRUE(callback2.have_result()); |
11186 EXPECT_EQ(OK, callback2.WaitForResult()); | 11186 EXPECT_EQ(OK, callback2.WaitForResult()); |
11187 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11187 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11188 } | 11188 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11265 host_port_pair_a, ProxyServer::Direct(), kPrivacyModeDisabled); | 11265 host_port_pair_a, ProxyServer::Direct(), kPrivacyModeDisabled); |
11266 EXPECT_FALSE( | 11266 EXPECT_FALSE( |
11267 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11267 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11268 | 11268 |
11269 TestCompletionCallback callback; | 11269 TestCompletionCallback callback; |
11270 HttpRequestInfo request1; | 11270 HttpRequestInfo request1; |
11271 request1.method = "GET"; | 11271 request1.method = "GET"; |
11272 request1.url = GURL("https://www.a.com/"); | 11272 request1.url = GURL("https://www.a.com/"); |
11273 request1.load_flags = 0; | 11273 request1.load_flags = 0; |
11274 scoped_ptr<HttpNetworkTransaction> trans( | 11274 scoped_ptr<HttpNetworkTransaction> trans( |
11275 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 11275 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
11276 | 11276 |
11277 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 11277 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
11278 EXPECT_EQ(ERR_IO_PENDING, rv); | 11278 EXPECT_EQ(ERR_IO_PENDING, rv); |
11279 EXPECT_EQ(OK, callback.WaitForResult()); | 11279 EXPECT_EQ(OK, callback.WaitForResult()); |
11280 | 11280 |
11281 const HttpResponseInfo* response = trans->GetResponseInfo(); | 11281 const HttpResponseInfo* response = trans->GetResponseInfo(); |
11282 ASSERT_TRUE(response != NULL); | 11282 ASSERT_TRUE(response != NULL); |
11283 ASSERT_TRUE(response->headers != NULL); | 11283 ASSERT_TRUE(response->headers.get() != NULL); |
11284 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11284 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
11285 EXPECT_TRUE(response->was_fetched_via_spdy); | 11285 EXPECT_TRUE(response->was_fetched_via_spdy); |
11286 EXPECT_TRUE(response->was_npn_negotiated); | 11286 EXPECT_TRUE(response->was_npn_negotiated); |
11287 | 11287 |
11288 std::string response_data; | 11288 std::string response_data; |
11289 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11289 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
11290 EXPECT_EQ("hello!", response_data); | 11290 EXPECT_EQ("hello!", response_data); |
11291 trans.reset(); | 11291 trans.reset(); |
11292 EXPECT_TRUE( | 11292 EXPECT_TRUE( |
11293 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11293 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11294 | 11294 |
11295 HostPortPair host_port_pair_b("www.b.com", 443); | 11295 HostPortPair host_port_pair_b("www.b.com", 443); |
11296 SpdySessionKey spdy_session_key_b( | 11296 SpdySessionKey spdy_session_key_b( |
11297 host_port_pair_b, ProxyServer::Direct(), kPrivacyModeDisabled); | 11297 host_port_pair_b, ProxyServer::Direct(), kPrivacyModeDisabled); |
11298 EXPECT_FALSE( | 11298 EXPECT_FALSE( |
11299 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11299 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11300 HttpRequestInfo request2; | 11300 HttpRequestInfo request2; |
11301 request2.method = "GET"; | 11301 request2.method = "GET"; |
11302 request2.url = GURL("https://www.b.com/"); | 11302 request2.url = GURL("https://www.b.com/"); |
11303 request2.load_flags = 0; | 11303 request2.load_flags = 0; |
11304 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 11304 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
11305 | 11305 |
11306 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); | 11306 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); |
11307 EXPECT_EQ(ERR_IO_PENDING, rv); | 11307 EXPECT_EQ(ERR_IO_PENDING, rv); |
11308 EXPECT_EQ(OK, callback.WaitForResult()); | 11308 EXPECT_EQ(OK, callback.WaitForResult()); |
11309 | 11309 |
11310 response = trans->GetResponseInfo(); | 11310 response = trans->GetResponseInfo(); |
11311 ASSERT_TRUE(response != NULL); | 11311 ASSERT_TRUE(response != NULL); |
11312 ASSERT_TRUE(response->headers != NULL); | 11312 ASSERT_TRUE(response->headers.get() != NULL); |
11313 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11313 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
11314 EXPECT_TRUE(response->was_fetched_via_spdy); | 11314 EXPECT_TRUE(response->was_fetched_via_spdy); |
11315 EXPECT_TRUE(response->was_npn_negotiated); | 11315 EXPECT_TRUE(response->was_npn_negotiated); |
11316 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11316 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
11317 EXPECT_EQ("hello!", response_data); | 11317 EXPECT_EQ("hello!", response_data); |
11318 EXPECT_FALSE( | 11318 EXPECT_FALSE( |
11319 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11319 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11320 EXPECT_TRUE( | 11320 EXPECT_TRUE( |
11321 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11321 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11322 | 11322 |
11323 HostPortPair host_port_pair_a1("www.a.com", 80); | 11323 HostPortPair host_port_pair_a1("www.a.com", 80); |
11324 SpdySessionKey spdy_session_key_a1( | 11324 SpdySessionKey spdy_session_key_a1( |
11325 host_port_pair_a1, ProxyServer::Direct(), kPrivacyModeDisabled); | 11325 host_port_pair_a1, ProxyServer::Direct(), kPrivacyModeDisabled); |
11326 EXPECT_FALSE( | 11326 EXPECT_FALSE( |
11327 session->spdy_session_pool()->HasSession(spdy_session_key_a1)); | 11327 session->spdy_session_pool()->HasSession(spdy_session_key_a1)); |
11328 HttpRequestInfo request3; | 11328 HttpRequestInfo request3; |
11329 request3.method = "GET"; | 11329 request3.method = "GET"; |
11330 request3.url = GURL("http://www.a.com/"); | 11330 request3.url = GURL("http://www.a.com/"); |
11331 request3.load_flags = 0; | 11331 request3.load_flags = 0; |
11332 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 11332 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
11333 | 11333 |
11334 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); | 11334 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); |
11335 EXPECT_EQ(ERR_IO_PENDING, rv); | 11335 EXPECT_EQ(ERR_IO_PENDING, rv); |
11336 EXPECT_EQ(OK, callback.WaitForResult()); | 11336 EXPECT_EQ(OK, callback.WaitForResult()); |
11337 | 11337 |
11338 response = trans->GetResponseInfo(); | 11338 response = trans->GetResponseInfo(); |
11339 ASSERT_TRUE(response != NULL); | 11339 ASSERT_TRUE(response != NULL); |
11340 ASSERT_TRUE(response->headers != NULL); | 11340 ASSERT_TRUE(response->headers.get() != NULL); |
11341 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11341 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
11342 EXPECT_FALSE(response->was_fetched_via_spdy); | 11342 EXPECT_FALSE(response->was_fetched_via_spdy); |
11343 EXPECT_FALSE(response->was_npn_negotiated); | 11343 EXPECT_FALSE(response->was_npn_negotiated); |
11344 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11344 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
11345 EXPECT_EQ("hello!", response_data); | 11345 EXPECT_EQ("hello!", response_data); |
11346 EXPECT_FALSE( | 11346 EXPECT_FALSE( |
11347 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11347 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11348 EXPECT_FALSE( | 11348 EXPECT_FALSE( |
11349 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11349 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11350 | 11350 |
11351 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 11351 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
11352 } | 11352 } |
11353 | 11353 |
11354 } // namespace net | 11354 } // namespace net |
OLD | NEW |