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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 // successfully established before the error. | 318 // successfully established before the error. |
319 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); | 319 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); |
320 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 320 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
321 | 321 |
322 if (out.rv != OK) | 322 if (out.rv != OK) |
323 return out; | 323 return out; |
324 | 324 |
325 const HttpResponseInfo* response = trans->GetResponseInfo(); | 325 const HttpResponseInfo* response = trans->GetResponseInfo(); |
326 // Can't use ASSERT_* inside helper functions like this, so | 326 // Can't use ASSERT_* inside helper functions like this, so |
327 // return an error. | 327 // return an error. |
328 if (response == NULL || response->headers == NULL) { | 328 if (response == NULL || response->headers.get() == NULL) { |
329 out.rv = ERR_UNEXPECTED; | 329 out.rv = ERR_UNEXPECTED; |
330 return out; | 330 return out; |
331 } | 331 } |
332 out.status_line = response->headers->GetStatusLine(); | 332 out.status_line = response->headers->GetStatusLine(); |
333 | 333 |
334 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 334 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
335 EXPECT_EQ(80, response->socket_address.port()); | 335 EXPECT_EQ(80, response->socket_address.port()); |
336 | 336 |
337 rv = ReadTransaction(trans.get(), &out.response_data); | 337 rv = ReadTransaction(trans.get(), &out.response_data); |
338 EXPECT_EQ(OK, rv); | 338 EXPECT_EQ(OK, rv); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 session_deps_.socket_factory->AddSocketDataProvider(&data); | 866 session_deps_.socket_factory->AddSocketDataProvider(&data); |
867 | 867 |
868 TestCompletionCallback callback; | 868 TestCompletionCallback callback; |
869 | 869 |
870 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 870 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
871 EXPECT_EQ(ERR_IO_PENDING, rv); | 871 EXPECT_EQ(ERR_IO_PENDING, rv); |
872 | 872 |
873 EXPECT_EQ(OK, callback.WaitForResult()); | 873 EXPECT_EQ(OK, callback.WaitForResult()); |
874 | 874 |
875 const HttpResponseInfo* response = trans->GetResponseInfo(); | 875 const HttpResponseInfo* response = trans->GetResponseInfo(); |
876 ASSERT_TRUE(response != NULL && response->headers != NULL); | 876 ASSERT_TRUE(response != NULL && response->headers.get() != NULL); |
877 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); | 877 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); |
878 std::string url; | 878 std::string url; |
879 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 879 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
880 EXPECT_EQ("http://good.com/", url); | 880 EXPECT_EQ("http://good.com/", url); |
881 } | 881 } |
882 | 882 |
883 // Checks that two distinct Location headers result in an error. | 883 // Checks that two distinct Location headers result in an error. |
884 TEST_F(HttpNetworkTransactionSpdy2Test, TwoDistinctLocationHeaders) { | 884 TEST_F(HttpNetworkTransactionSpdy2Test, TwoDistinctLocationHeaders) { |
885 MockRead data_reads[] = { | 885 MockRead data_reads[] = { |
886 MockRead("HTTP/1.1 302 Redirect\r\n"), | 886 MockRead("HTTP/1.1 302 Redirect\r\n"), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 930 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
931 EXPECT_EQ(ERR_IO_PENDING, rv); | 931 EXPECT_EQ(ERR_IO_PENDING, rv); |
932 | 932 |
933 rv = callback1.WaitForResult(); | 933 rv = callback1.WaitForResult(); |
934 EXPECT_EQ(OK, rv); | 934 EXPECT_EQ(OK, rv); |
935 | 935 |
936 const HttpResponseInfo* response = trans->GetResponseInfo(); | 936 const HttpResponseInfo* response = trans->GetResponseInfo(); |
937 ASSERT_TRUE(response != NULL); | 937 ASSERT_TRUE(response != NULL); |
938 | 938 |
939 // Check that the headers got parsed. | 939 // Check that the headers got parsed. |
940 EXPECT_TRUE(response->headers != NULL); | 940 EXPECT_TRUE(response->headers.get() != NULL); |
941 EXPECT_EQ(1234, response->headers->GetContentLength()); | 941 EXPECT_EQ(1234, response->headers->GetContentLength()); |
942 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); | 942 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); |
943 | 943 |
944 std::string server_header; | 944 std::string server_header; |
945 void* iter = NULL; | 945 void* iter = NULL; |
946 bool has_server_header = response->headers->EnumerateHeader( | 946 bool has_server_header = response->headers->EnumerateHeader( |
947 &iter, "Server", &server_header); | 947 &iter, "Server", &server_header); |
948 EXPECT_TRUE(has_server_header); | 948 EXPECT_TRUE(has_server_header); |
949 EXPECT_EQ("Blah", server_header); | 949 EXPECT_EQ("Blah", server_header); |
950 | 950 |
(...skipping 22 matching lines...) Expand all Loading... |
973 "hello", "world" | 973 "hello", "world" |
974 }; | 974 }; |
975 | 975 |
976 for (int i = 0; i < 2; ++i) { | 976 for (int i = 0; i < 2; ++i) { |
977 HttpRequestInfo request; | 977 HttpRequestInfo request; |
978 request.method = "GET"; | 978 request.method = "GET"; |
979 request.url = GURL("http://www.google.com/"); | 979 request.url = GURL("http://www.google.com/"); |
980 request.load_flags = 0; | 980 request.load_flags = 0; |
981 | 981 |
982 scoped_ptr<HttpTransaction> trans( | 982 scoped_ptr<HttpTransaction> trans( |
983 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 983 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
984 | 984 |
985 TestCompletionCallback callback; | 985 TestCompletionCallback callback; |
986 | 986 |
987 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 987 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
988 EXPECT_EQ(ERR_IO_PENDING, rv); | 988 EXPECT_EQ(ERR_IO_PENDING, rv); |
989 | 989 |
990 rv = callback.WaitForResult(); | 990 rv = callback.WaitForResult(); |
991 EXPECT_EQ(OK, rv); | 991 EXPECT_EQ(OK, rv); |
992 | 992 |
993 const HttpResponseInfo* response = trans->GetResponseInfo(); | 993 const HttpResponseInfo* response = trans->GetResponseInfo(); |
994 ASSERT_TRUE(response != NULL); | 994 ASSERT_TRUE(response != NULL); |
995 | 995 |
996 EXPECT_TRUE(response->headers != NULL); | 996 EXPECT_TRUE(response->headers.get() != NULL); |
997 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 997 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
998 | 998 |
999 std::string response_data; | 999 std::string response_data; |
1000 rv = ReadTransaction(trans.get(), &response_data); | 1000 rv = ReadTransaction(trans.get(), &response_data); |
1001 EXPECT_EQ(OK, rv); | 1001 EXPECT_EQ(OK, rv); |
1002 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1002 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1003 } | 1003 } |
1004 } | 1004 } |
1005 | 1005 |
1006 TEST_F(HttpNetworkTransactionSpdy2Test, Ignores100) { | 1006 TEST_F(HttpNetworkTransactionSpdy2Test, Ignores100) { |
(...skipping 24 matching lines...) Expand all Loading... |
1031 | 1031 |
1032 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1032 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1033 EXPECT_EQ(ERR_IO_PENDING, rv); | 1033 EXPECT_EQ(ERR_IO_PENDING, rv); |
1034 | 1034 |
1035 rv = callback.WaitForResult(); | 1035 rv = callback.WaitForResult(); |
1036 EXPECT_EQ(OK, rv); | 1036 EXPECT_EQ(OK, rv); |
1037 | 1037 |
1038 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1038 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1039 ASSERT_TRUE(response != NULL); | 1039 ASSERT_TRUE(response != NULL); |
1040 | 1040 |
1041 EXPECT_TRUE(response->headers != NULL); | 1041 EXPECT_TRUE(response->headers.get() != NULL); |
1042 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 1042 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
1043 | 1043 |
1044 std::string response_data; | 1044 std::string response_data; |
1045 rv = ReadTransaction(trans.get(), &response_data); | 1045 rv = ReadTransaction(trans.get(), &response_data); |
1046 EXPECT_EQ(OK, rv); | 1046 EXPECT_EQ(OK, rv); |
1047 EXPECT_EQ("hello world", response_data); | 1047 EXPECT_EQ("hello world", response_data); |
1048 } | 1048 } |
1049 | 1049 |
1050 // This test is almost the same as Ignores100 above, but the response contains | 1050 // This test is almost the same as Ignores100 above, but the response contains |
1051 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is | 1051 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is |
(...skipping 21 matching lines...) Expand all Loading... |
1073 | 1073 |
1074 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1074 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1075 EXPECT_EQ(ERR_IO_PENDING, rv); | 1075 EXPECT_EQ(ERR_IO_PENDING, rv); |
1076 | 1076 |
1077 rv = callback.WaitForResult(); | 1077 rv = callback.WaitForResult(); |
1078 EXPECT_EQ(OK, rv); | 1078 EXPECT_EQ(OK, rv); |
1079 | 1079 |
1080 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1080 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1081 ASSERT_TRUE(response != NULL); | 1081 ASSERT_TRUE(response != NULL); |
1082 | 1082 |
1083 EXPECT_TRUE(response->headers != NULL); | 1083 EXPECT_TRUE(response->headers.get() != NULL); |
1084 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1084 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1085 | 1085 |
1086 std::string response_data; | 1086 std::string response_data; |
1087 rv = ReadTransaction(trans.get(), &response_data); | 1087 rv = ReadTransaction(trans.get(), &response_data); |
1088 EXPECT_EQ(OK, rv); | 1088 EXPECT_EQ(OK, rv); |
1089 EXPECT_EQ("hello world", response_data); | 1089 EXPECT_EQ("hello world", response_data); |
1090 } | 1090 } |
1091 | 1091 |
1092 TEST_F(HttpNetworkTransactionSpdy2Test, Incomplete100ThenEOF) { | 1092 TEST_F(HttpNetworkTransactionSpdy2Test, Incomplete100ThenEOF) { |
1093 HttpRequestInfo request; | 1093 HttpRequestInfo request; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 | 1196 |
1197 const char* kExpectedResponseData[] = { | 1197 const char* kExpectedResponseData[] = { |
1198 "hello", "world" | 1198 "hello", "world" |
1199 }; | 1199 }; |
1200 | 1200 |
1201 uint32 first_socket_log_id = NetLog::Source::kInvalidId; | 1201 uint32 first_socket_log_id = NetLog::Source::kInvalidId; |
1202 for (int i = 0; i < 2; ++i) { | 1202 for (int i = 0; i < 2; ++i) { |
1203 TestCompletionCallback callback; | 1203 TestCompletionCallback callback; |
1204 | 1204 |
1205 scoped_ptr<HttpTransaction> trans( | 1205 scoped_ptr<HttpTransaction> trans( |
1206 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1206 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1207 | 1207 |
1208 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1208 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1209 EXPECT_EQ(ERR_IO_PENDING, rv); | 1209 EXPECT_EQ(ERR_IO_PENDING, rv); |
1210 | 1210 |
1211 rv = callback.WaitForResult(); | 1211 rv = callback.WaitForResult(); |
1212 EXPECT_EQ(OK, rv); | 1212 EXPECT_EQ(OK, rv); |
1213 | 1213 |
1214 LoadTimingInfo load_timing_info; | 1214 LoadTimingInfo load_timing_info; |
1215 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 1215 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
1216 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 1216 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
1217 if (i == 0) { | 1217 if (i == 0) { |
1218 first_socket_log_id = load_timing_info.socket_log_id; | 1218 first_socket_log_id = load_timing_info.socket_log_id; |
1219 } else { | 1219 } else { |
1220 // The second request should be using a new socket. | 1220 // The second request should be using a new socket. |
1221 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); | 1221 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); |
1222 } | 1222 } |
1223 | 1223 |
1224 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1224 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1225 ASSERT_TRUE(response != NULL); | 1225 ASSERT_TRUE(response != NULL); |
1226 | 1226 |
1227 EXPECT_TRUE(response->headers != NULL); | 1227 EXPECT_TRUE(response->headers.get() != NULL); |
1228 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1228 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1229 | 1229 |
1230 std::string response_data; | 1230 std::string response_data; |
1231 rv = ReadTransaction(trans.get(), &response_data); | 1231 rv = ReadTransaction(trans.get(), &response_data); |
1232 EXPECT_EQ(OK, rv); | 1232 EXPECT_EQ(OK, rv); |
1233 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1233 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1234 } | 1234 } |
1235 } | 1235 } |
1236 | 1236 |
1237 TEST_F(HttpNetworkTransactionSpdy2Test, | 1237 TEST_F(HttpNetworkTransactionSpdy2Test, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 // destructor in such situations. | 1307 // destructor in such situations. |
1308 // See http://crbug.com/154712 and http://crbug.com/156609. | 1308 // See http://crbug.com/154712 and http://crbug.com/156609. |
1309 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose) { | 1309 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose) { |
1310 HttpRequestInfo request; | 1310 HttpRequestInfo request; |
1311 request.method = "GET"; | 1311 request.method = "GET"; |
1312 request.url = GURL("http://www.google.com/"); | 1312 request.url = GURL("http://www.google.com/"); |
1313 request.load_flags = 0; | 1313 request.load_flags = 0; |
1314 | 1314 |
1315 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 1315 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
1316 scoped_ptr<HttpTransaction> trans( | 1316 scoped_ptr<HttpTransaction> trans( |
1317 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1317 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1318 | 1318 |
1319 MockRead data_reads[] = { | 1319 MockRead data_reads[] = { |
1320 MockRead("HTTP/1.0 200 OK\r\n"), | 1320 MockRead("HTTP/1.0 200 OK\r\n"), |
1321 MockRead("Connection: keep-alive\r\n"), | 1321 MockRead("Connection: keep-alive\r\n"), |
1322 MockRead("Content-Length: 100\r\n\r\n"), | 1322 MockRead("Content-Length: 100\r\n\r\n"), |
1323 MockRead("hello"), | 1323 MockRead("hello"), |
1324 MockRead(SYNCHRONOUS, 0), | 1324 MockRead(SYNCHRONOUS, 0), |
1325 }; | 1325 }; |
1326 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1326 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
1327 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1327 session_deps_.socket_factory->AddSocketDataProvider(&data); |
1328 | 1328 |
1329 TestCompletionCallback callback; | 1329 TestCompletionCallback callback; |
1330 | 1330 |
1331 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1331 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1332 EXPECT_EQ(ERR_IO_PENDING, rv); | 1332 EXPECT_EQ(ERR_IO_PENDING, rv); |
1333 | 1333 |
1334 rv = callback.WaitForResult(); | 1334 rv = callback.WaitForResult(); |
1335 EXPECT_EQ(OK, rv); | 1335 EXPECT_EQ(OK, rv); |
1336 | 1336 |
1337 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1337 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
1338 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1338 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1339 if (rv == ERR_IO_PENDING) | 1339 if (rv == ERR_IO_PENDING) |
1340 rv = callback.WaitForResult(); | 1340 rv = callback.WaitForResult(); |
1341 EXPECT_EQ(5, rv); | 1341 EXPECT_EQ(5, rv); |
1342 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1342 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1343 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1343 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
1344 | 1344 |
1345 trans.reset(); | 1345 trans.reset(); |
1346 base::MessageLoop::current()->RunUntilIdle(); | 1346 base::MessageLoop::current()->RunUntilIdle(); |
1347 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1347 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
1348 } | 1348 } |
1349 | 1349 |
1350 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose2) { | 1350 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose2) { |
1351 HttpRequestInfo request; | 1351 HttpRequestInfo request; |
1352 request.method = "GET"; | 1352 request.method = "GET"; |
1353 request.url = GURL("http://www.google.com/"); | 1353 request.url = GURL("http://www.google.com/"); |
1354 request.load_flags = 0; | 1354 request.load_flags = 0; |
1355 | 1355 |
1356 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 1356 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
1357 scoped_ptr<HttpTransaction> trans( | 1357 scoped_ptr<HttpTransaction> trans( |
1358 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1358 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1359 | 1359 |
1360 MockRead data_reads[] = { | 1360 MockRead data_reads[] = { |
1361 MockRead("HTTP/1.0 200 OK\r\n"), | 1361 MockRead("HTTP/1.0 200 OK\r\n"), |
1362 MockRead("Connection: keep-alive\r\n"), | 1362 MockRead("Connection: keep-alive\r\n"), |
1363 MockRead("Content-Length: 100\r\n\r\n"), | 1363 MockRead("Content-Length: 100\r\n\r\n"), |
1364 MockRead(SYNCHRONOUS, 0), | 1364 MockRead(SYNCHRONOUS, 0), |
1365 }; | 1365 }; |
1366 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1366 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
1367 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1367 session_deps_.socket_factory->AddSocketDataProvider(&data); |
1368 | 1368 |
1369 TestCompletionCallback callback; | 1369 TestCompletionCallback callback; |
1370 | 1370 |
1371 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1371 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1372 EXPECT_EQ(ERR_IO_PENDING, rv); | 1372 EXPECT_EQ(ERR_IO_PENDING, rv); |
1373 | 1373 |
1374 rv = callback.WaitForResult(); | 1374 rv = callback.WaitForResult(); |
1375 EXPECT_EQ(OK, rv); | 1375 EXPECT_EQ(OK, rv); |
1376 | 1376 |
1377 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1377 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
1378 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1378 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1379 if (rv == ERR_IO_PENDING) | 1379 if (rv == ERR_IO_PENDING) |
1380 rv = callback.WaitForResult(); | 1380 rv = callback.WaitForResult(); |
1381 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1381 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
1382 | 1382 |
1383 trans.reset(); | 1383 trans.reset(); |
1384 base::MessageLoop::current()->RunUntilIdle(); | 1384 base::MessageLoop::current()->RunUntilIdle(); |
1385 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1385 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
1386 } | 1386 } |
1387 | 1387 |
1388 // Test that we correctly reuse a keep-alive connection after not explicitly | 1388 // 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... |
1427 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1427 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1428 | 1428 |
1429 const int kNumUnreadBodies = arraysize(data1_reads) - 2; | 1429 const int kNumUnreadBodies = arraysize(data1_reads) - 2; |
1430 std::string response_lines[kNumUnreadBodies]; | 1430 std::string response_lines[kNumUnreadBodies]; |
1431 | 1431 |
1432 uint32 first_socket_log_id = NetLog::Source::kInvalidId; | 1432 uint32 first_socket_log_id = NetLog::Source::kInvalidId; |
1433 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { | 1433 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { |
1434 TestCompletionCallback callback; | 1434 TestCompletionCallback callback; |
1435 | 1435 |
1436 scoped_ptr<HttpTransaction> trans( | 1436 scoped_ptr<HttpTransaction> trans( |
1437 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1437 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1438 | 1438 |
1439 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1439 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1440 EXPECT_EQ(ERR_IO_PENDING, rv); | 1440 EXPECT_EQ(ERR_IO_PENDING, rv); |
1441 | 1441 |
1442 rv = callback.WaitForResult(); | 1442 rv = callback.WaitForResult(); |
1443 EXPECT_EQ(OK, rv); | 1443 EXPECT_EQ(OK, rv); |
1444 | 1444 |
1445 LoadTimingInfo load_timing_info; | 1445 LoadTimingInfo load_timing_info; |
1446 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 1446 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
1447 if (i == 0) { | 1447 if (i == 0) { |
1448 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 1448 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
1449 first_socket_log_id = load_timing_info.socket_log_id; | 1449 first_socket_log_id = load_timing_info.socket_log_id; |
1450 } else { | 1450 } else { |
1451 TestLoadTimingReused(load_timing_info); | 1451 TestLoadTimingReused(load_timing_info); |
1452 EXPECT_EQ(first_socket_log_id, load_timing_info.socket_log_id); | 1452 EXPECT_EQ(first_socket_log_id, load_timing_info.socket_log_id); |
1453 } | 1453 } |
1454 | 1454 |
1455 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1455 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1456 ASSERT_TRUE(response != NULL); | 1456 ASSERT_TRUE(response != NULL); |
1457 | 1457 |
1458 ASSERT_TRUE(response->headers != NULL); | 1458 ASSERT_TRUE(response->headers.get() != NULL); |
1459 response_lines[i] = response->headers->GetStatusLine(); | 1459 response_lines[i] = response->headers->GetStatusLine(); |
1460 | 1460 |
1461 // We intentionally don't read the response bodies. | 1461 // We intentionally don't read the response bodies. |
1462 } | 1462 } |
1463 | 1463 |
1464 const char* const kStatusLines[] = { | 1464 const char* const kStatusLines[] = { |
1465 "HTTP/1.1 204 No Content", | 1465 "HTTP/1.1 204 No Content", |
1466 "HTTP/1.1 205 Reset Content", | 1466 "HTTP/1.1 205 Reset Content", |
1467 "HTTP/1.1 304 Not Modified", | 1467 "HTTP/1.1 304 Not Modified", |
1468 "HTTP/1.1 302 Found", | 1468 "HTTP/1.1 302 Found", |
1469 "HTTP/1.1 302 Found", | 1469 "HTTP/1.1 302 Found", |
1470 "HTTP/1.1 301 Moved Permanently", | 1470 "HTTP/1.1 301 Moved Permanently", |
1471 "HTTP/1.1 301 Moved Permanently", | 1471 "HTTP/1.1 301 Moved Permanently", |
1472 }; | 1472 }; |
1473 | 1473 |
1474 COMPILE_ASSERT(kNumUnreadBodies == arraysize(kStatusLines), | 1474 COMPILE_ASSERT(kNumUnreadBodies == arraysize(kStatusLines), |
1475 forgot_to_update_kStatusLines); | 1475 forgot_to_update_kStatusLines); |
1476 | 1476 |
1477 for (int i = 0; i < kNumUnreadBodies; ++i) | 1477 for (int i = 0; i < kNumUnreadBodies; ++i) |
1478 EXPECT_EQ(kStatusLines[i], response_lines[i]); | 1478 EXPECT_EQ(kStatusLines[i], response_lines[i]); |
1479 | 1479 |
1480 TestCompletionCallback callback; | 1480 TestCompletionCallback callback; |
1481 scoped_ptr<HttpTransaction> trans( | 1481 scoped_ptr<HttpTransaction> trans( |
1482 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1482 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1483 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1483 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1484 EXPECT_EQ(ERR_IO_PENDING, rv); | 1484 EXPECT_EQ(ERR_IO_PENDING, rv); |
1485 rv = callback.WaitForResult(); | 1485 rv = callback.WaitForResult(); |
1486 EXPECT_EQ(OK, rv); | 1486 EXPECT_EQ(OK, rv); |
1487 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1487 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1488 ASSERT_TRUE(response != NULL); | 1488 ASSERT_TRUE(response != NULL); |
1489 ASSERT_TRUE(response->headers != NULL); | 1489 ASSERT_TRUE(response->headers.get() != NULL); |
1490 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1490 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1491 std::string response_data; | 1491 std::string response_data; |
1492 rv = ReadTransaction(trans.get(), &response_data); | 1492 rv = ReadTransaction(trans.get(), &response_data); |
1493 EXPECT_EQ(OK, rv); | 1493 EXPECT_EQ(OK, rv); |
1494 EXPECT_EQ("hello", response_data); | 1494 EXPECT_EQ("hello", response_data); |
1495 } | 1495 } |
1496 | 1496 |
1497 // Test the request-challenge-retry sequence for basic auth. | 1497 // Test the request-challenge-retry sequence for basic auth. |
1498 // (basic auth is the easiest to mock, because it has no randomness). | 1498 // (basic auth is the easiest to mock, because it has no randomness). |
1499 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuth) { | 1499 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuth) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1680 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1681 data_writes1, arraysize(data_writes1)); | 1681 data_writes1, arraysize(data_writes1)); |
1682 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1682 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1683 NULL, 0); | 1683 NULL, 0); |
1684 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1684 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1685 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1685 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1686 | 1686 |
1687 TestCompletionCallback callback1; | 1687 TestCompletionCallback callback1; |
1688 | 1688 |
1689 scoped_ptr<HttpTransaction> trans( | 1689 scoped_ptr<HttpTransaction> trans( |
1690 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1690 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1691 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1691 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1692 EXPECT_EQ(ERR_IO_PENDING, rv); | 1692 EXPECT_EQ(ERR_IO_PENDING, rv); |
1693 | 1693 |
1694 rv = callback1.WaitForResult(); | 1694 rv = callback1.WaitForResult(); |
1695 EXPECT_EQ(OK, rv); | 1695 EXPECT_EQ(OK, rv); |
1696 | 1696 |
1697 LoadTimingInfo load_timing_info1; | 1697 LoadTimingInfo load_timing_info1; |
1698 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info1)); | 1698 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info1)); |
1699 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_DNS_TIMES); | 1699 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_DNS_TIMES); |
1700 | 1700 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1769 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1769 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1770 data_writes1, arraysize(data_writes1)); | 1770 data_writes1, arraysize(data_writes1)); |
1771 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1771 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1772 NULL, 0); | 1772 NULL, 0); |
1773 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1773 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1774 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1774 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1775 | 1775 |
1776 TestCompletionCallback callback1; | 1776 TestCompletionCallback callback1; |
1777 | 1777 |
1778 scoped_ptr<HttpTransaction> trans( | 1778 scoped_ptr<HttpTransaction> trans( |
1779 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1779 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1780 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1780 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1781 EXPECT_EQ(ERR_IO_PENDING, rv); | 1781 EXPECT_EQ(ERR_IO_PENDING, rv); |
1782 | 1782 |
1783 rv = callback1.WaitForResult(); | 1783 rv = callback1.WaitForResult(); |
1784 EXPECT_EQ(OK, rv); | 1784 EXPECT_EQ(OK, rv); |
1785 | 1785 |
1786 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1786 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1787 ASSERT_TRUE(response != NULL); | 1787 ASSERT_TRUE(response != NULL); |
1788 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1788 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1789 | 1789 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1853 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1854 data_writes1, arraysize(data_writes1)); | 1854 data_writes1, arraysize(data_writes1)); |
1855 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1855 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1856 NULL, 0); | 1856 NULL, 0); |
1857 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1857 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1858 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1858 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1859 | 1859 |
1860 TestCompletionCallback callback1; | 1860 TestCompletionCallback callback1; |
1861 | 1861 |
1862 scoped_ptr<HttpTransaction> trans( | 1862 scoped_ptr<HttpTransaction> trans( |
1863 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1863 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1864 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1864 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1865 EXPECT_EQ(ERR_IO_PENDING, rv); | 1865 EXPECT_EQ(ERR_IO_PENDING, rv); |
1866 | 1866 |
1867 rv = callback1.WaitForResult(); | 1867 rv = callback1.WaitForResult(); |
1868 EXPECT_EQ(OK, rv); | 1868 EXPECT_EQ(OK, rv); |
1869 | 1869 |
1870 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1870 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1871 ASSERT_TRUE(response != NULL); | 1871 ASSERT_TRUE(response != NULL); |
1872 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1872 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1873 | 1873 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1939 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
1940 data_writes1, arraysize(data_writes1)); | 1940 data_writes1, arraysize(data_writes1)); |
1941 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1941 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
1942 data_writes2, arraysize(data_writes2)); | 1942 data_writes2, arraysize(data_writes2)); |
1943 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 1943 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
1944 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1944 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
1945 | 1945 |
1946 TestCompletionCallback callback1; | 1946 TestCompletionCallback callback1; |
1947 | 1947 |
1948 scoped_ptr<HttpTransaction> trans( | 1948 scoped_ptr<HttpTransaction> trans( |
1949 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 1949 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
1950 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1950 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
1951 EXPECT_EQ(ERR_IO_PENDING, rv); | 1951 EXPECT_EQ(ERR_IO_PENDING, rv); |
1952 | 1952 |
1953 rv = callback1.WaitForResult(); | 1953 rv = callback1.WaitForResult(); |
1954 EXPECT_EQ(OK, rv); | 1954 EXPECT_EQ(OK, rv); |
1955 | 1955 |
1956 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1956 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1957 ASSERT_TRUE(response != NULL); | 1957 ASSERT_TRUE(response != NULL); |
1958 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1958 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1959 | 1959 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2024 | 2024 |
2025 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2025 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2026 data_writes1, arraysize(data_writes1)); | 2026 data_writes1, arraysize(data_writes1)); |
2027 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2027 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2028 SSLSocketDataProvider ssl(ASYNC, OK); | 2028 SSLSocketDataProvider ssl(ASYNC, OK); |
2029 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2029 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2030 | 2030 |
2031 TestCompletionCallback callback1; | 2031 TestCompletionCallback callback1; |
2032 | 2032 |
2033 scoped_ptr<HttpTransaction> trans( | 2033 scoped_ptr<HttpTransaction> trans( |
2034 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2034 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2035 | 2035 |
2036 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2036 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2037 EXPECT_EQ(ERR_IO_PENDING, rv); | 2037 EXPECT_EQ(ERR_IO_PENDING, rv); |
2038 | 2038 |
2039 rv = callback1.WaitForResult(); | 2039 rv = callback1.WaitForResult(); |
2040 EXPECT_EQ(OK, rv); | 2040 EXPECT_EQ(OK, rv); |
2041 net::CapturingNetLog::CapturedEntryList entries; | 2041 net::CapturingNetLog::CapturedEntryList entries; |
2042 log.GetEntries(&entries); | 2042 log.GetEntries(&entries); |
2043 size_t pos = ExpectLogContainsSomewhere( | 2043 size_t pos = ExpectLogContainsSomewhere( |
2044 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2044 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
2045 NetLog::PHASE_NONE); | 2045 NetLog::PHASE_NONE); |
2046 ExpectLogContainsSomewhere( | 2046 ExpectLogContainsSomewhere( |
2047 entries, pos, | 2047 entries, pos, |
2048 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2048 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
2049 NetLog::PHASE_NONE); | 2049 NetLog::PHASE_NONE); |
2050 | 2050 |
2051 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2051 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2052 ASSERT_TRUE(response != NULL); | 2052 ASSERT_TRUE(response != NULL); |
2053 ASSERT_FALSE(response->headers == NULL); | 2053 ASSERT_FALSE(response->headers.get() == NULL); |
2054 EXPECT_EQ(407, response->headers->response_code()); | 2054 EXPECT_EQ(407, response->headers->response_code()); |
2055 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2055 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2056 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2056 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2057 | 2057 |
2058 LoadTimingInfo load_timing_info; | 2058 LoadTimingInfo load_timing_info; |
2059 // CONNECT requests and responses are handled at the connect job level, so | 2059 // CONNECT requests and responses are handled at the connect job level, so |
2060 // the transaction does not yet have a connection. | 2060 // the transaction does not yet have a connection. |
2061 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); | 2061 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); |
2062 | 2062 |
2063 TestCompletionCallback callback2; | 2063 TestCompletionCallback callback2; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2098 // when the no authentication data flag is set. | 2098 // when the no authentication data flag is set. |
2099 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 2099 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
2100 | 2100 |
2101 // Configure against proxy server "myproxy:70". | 2101 // Configure against proxy server "myproxy:70". |
2102 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); | 2102 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); |
2103 CapturingBoundNetLog log; | 2103 CapturingBoundNetLog log; |
2104 session_deps_.net_log = log.bound().net_log(); | 2104 session_deps_.net_log = log.bound().net_log(); |
2105 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2105 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2106 | 2106 |
2107 scoped_ptr<HttpTransaction> trans( | 2107 scoped_ptr<HttpTransaction> trans( |
2108 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2108 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2109 | 2109 |
2110 // Since we have proxy, should try to establish tunnel. | 2110 // Since we have proxy, should try to establish tunnel. |
2111 MockWrite data_writes1[] = { | 2111 MockWrite data_writes1[] = { |
2112 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2112 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
2113 "Host: www.google.com\r\n" | 2113 "Host: www.google.com\r\n" |
2114 "Proxy-Connection: keep-alive\r\n\r\n"), | 2114 "Proxy-Connection: keep-alive\r\n\r\n"), |
2115 | 2115 |
2116 // After calling trans->RestartWithAuth(), this is the request we should | 2116 // After calling trans->RestartWithAuth(), this is the request we should |
2117 // be issuing -- the final header line contains the credentials. | 2117 // be issuing -- the final header line contains the credentials. |
2118 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2118 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 size_t pos = ExpectLogContainsSomewhere( | 2154 size_t pos = ExpectLogContainsSomewhere( |
2155 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2155 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
2156 NetLog::PHASE_NONE); | 2156 NetLog::PHASE_NONE); |
2157 ExpectLogContainsSomewhere( | 2157 ExpectLogContainsSomewhere( |
2158 entries, pos, | 2158 entries, pos, |
2159 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2159 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
2160 NetLog::PHASE_NONE); | 2160 NetLog::PHASE_NONE); |
2161 | 2161 |
2162 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2162 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2163 ASSERT_TRUE(response != NULL); | 2163 ASSERT_TRUE(response != NULL); |
2164 ASSERT_FALSE(response->headers == NULL); | 2164 ASSERT_FALSE(response->headers.get() == NULL); |
2165 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2165 EXPECT_TRUE(response->headers->IsKeepAlive()); |
2166 EXPECT_EQ(407, response->headers->response_code()); | 2166 EXPECT_EQ(407, response->headers->response_code()); |
2167 EXPECT_EQ(10, response->headers->GetContentLength()); | 2167 EXPECT_EQ(10, response->headers->GetContentLength()); |
2168 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2168 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2169 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2169 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2170 | 2170 |
2171 TestCompletionCallback callback2; | 2171 TestCompletionCallback callback2; |
2172 | 2172 |
2173 // Wrong password (should be "bar"). | 2173 // Wrong password (should be "bar"). |
2174 rv = trans->RestartWithAuth( | 2174 rv = trans->RestartWithAuth( |
2175 AuthCredentials(kFoo, kBaz), callback2.callback()); | 2175 AuthCredentials(kFoo, kBaz), callback2.callback()); |
2176 EXPECT_EQ(ERR_IO_PENDING, rv); | 2176 EXPECT_EQ(ERR_IO_PENDING, rv); |
2177 | 2177 |
2178 rv = callback2.WaitForResult(); | 2178 rv = callback2.WaitForResult(); |
2179 EXPECT_EQ(OK, rv); | 2179 EXPECT_EQ(OK, rv); |
2180 | 2180 |
2181 response = trans->GetResponseInfo(); | 2181 response = trans->GetResponseInfo(); |
2182 ASSERT_TRUE(response != NULL); | 2182 ASSERT_TRUE(response != NULL); |
2183 ASSERT_FALSE(response->headers == NULL); | 2183 ASSERT_FALSE(response->headers.get() == NULL); |
2184 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2184 EXPECT_TRUE(response->headers->IsKeepAlive()); |
2185 EXPECT_EQ(407, response->headers->response_code()); | 2185 EXPECT_EQ(407, response->headers->response_code()); |
2186 EXPECT_EQ(10, response->headers->GetContentLength()); | 2186 EXPECT_EQ(10, response->headers->GetContentLength()); |
2187 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2187 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2188 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2188 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2189 | 2189 |
2190 // Flush the idle socket before the NetLog and HttpNetworkTransaction go | 2190 // Flush the idle socket before the NetLog and HttpNetworkTransaction go |
2191 // out of scope. | 2191 // out of scope. |
2192 session->CloseAllConnections(); | 2192 session->CloseAllConnections(); |
2193 } | 2193 } |
2194 | 2194 |
2195 // Test that we don't read the response body when we fail to establish a tunnel, | 2195 // Test that we don't read the response body when we fail to establish a tunnel, |
2196 // even if the user cancels the proxy's auth attempt. | 2196 // even if the user cancels the proxy's auth attempt. |
2197 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyCancelTunnel) { | 2197 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyCancelTunnel) { |
2198 HttpRequestInfo request; | 2198 HttpRequestInfo request; |
2199 request.method = "GET"; | 2199 request.method = "GET"; |
2200 request.url = GURL("https://www.google.com/"); | 2200 request.url = GURL("https://www.google.com/"); |
2201 request.load_flags = 0; | 2201 request.load_flags = 0; |
2202 | 2202 |
2203 // Configure against proxy server "myproxy:70". | 2203 // Configure against proxy server "myproxy:70". |
2204 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); | 2204 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); |
2205 | 2205 |
2206 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2206 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2207 | 2207 |
2208 scoped_ptr<HttpTransaction> trans( | 2208 scoped_ptr<HttpTransaction> trans( |
2209 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2209 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2210 | 2210 |
2211 // Since we have proxy, should try to establish tunnel. | 2211 // Since we have proxy, should try to establish tunnel. |
2212 MockWrite data_writes[] = { | 2212 MockWrite data_writes[] = { |
2213 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2213 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
2214 "Host: www.google.com\r\n" | 2214 "Host: www.google.com\r\n" |
2215 "Proxy-Connection: keep-alive\r\n\r\n"), | 2215 "Proxy-Connection: keep-alive\r\n\r\n"), |
2216 }; | 2216 }; |
2217 | 2217 |
2218 // The proxy responds to the connect with a 407. | 2218 // The proxy responds to the connect with a 407. |
2219 MockRead data_reads[] = { | 2219 MockRead data_reads[] = { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 | 2331 |
2332 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2332 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2333 data_writes1, arraysize(data_writes1)); | 2333 data_writes1, arraysize(data_writes1)); |
2334 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2334 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2335 SSLSocketDataProvider ssl(ASYNC, OK); | 2335 SSLSocketDataProvider ssl(ASYNC, OK); |
2336 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2336 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2337 | 2337 |
2338 TestCompletionCallback callback1; | 2338 TestCompletionCallback callback1; |
2339 | 2339 |
2340 scoped_ptr<HttpTransaction> trans( | 2340 scoped_ptr<HttpTransaction> trans( |
2341 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2341 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2342 | 2342 |
2343 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2343 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2344 EXPECT_EQ(ERR_IO_PENDING, rv); | 2344 EXPECT_EQ(ERR_IO_PENDING, rv); |
2345 | 2345 |
2346 rv = callback1.WaitForResult(); | 2346 rv = callback1.WaitForResult(); |
2347 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2347 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
2348 net::CapturingNetLog::CapturedEntryList entries; | 2348 net::CapturingNetLog::CapturedEntryList entries; |
2349 log.GetEntries(&entries); | 2349 log.GetEntries(&entries); |
2350 size_t pos = ExpectLogContainsSomewhere( | 2350 size_t pos = ExpectLogContainsSomewhere( |
2351 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2351 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 }; | 2403 }; |
2404 | 2404 |
2405 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2405 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2406 data_writes1, arraysize(data_writes1)); | 2406 data_writes1, arraysize(data_writes1)); |
2407 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2407 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2408 SSLSocketDataProvider ssl(ASYNC, OK); | 2408 SSLSocketDataProvider ssl(ASYNC, OK); |
2409 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2409 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2410 | 2410 |
2411 TestCompletionCallback callback1; | 2411 TestCompletionCallback callback1; |
2412 scoped_ptr<HttpTransaction> trans1( | 2412 scoped_ptr<HttpTransaction> trans1( |
2413 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2413 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2414 | 2414 |
2415 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 2415 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
2416 EXPECT_EQ(ERR_IO_PENDING, rv); | 2416 EXPECT_EQ(ERR_IO_PENDING, rv); |
2417 | 2417 |
2418 rv = callback1.WaitForResult(); | 2418 rv = callback1.WaitForResult(); |
2419 EXPECT_EQ(OK, rv); | 2419 EXPECT_EQ(OK, rv); |
2420 | 2420 |
2421 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 2421 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
2422 ASSERT_TRUE(response1 != NULL); | 2422 ASSERT_TRUE(response1 != NULL); |
2423 ASSERT_TRUE(response1->headers != NULL); | 2423 ASSERT_TRUE(response1->headers.get() != NULL); |
2424 EXPECT_EQ(1, response1->headers->GetContentLength()); | 2424 EXPECT_EQ(1, response1->headers->GetContentLength()); |
2425 | 2425 |
2426 LoadTimingInfo load_timing_info1; | 2426 LoadTimingInfo load_timing_info1; |
2427 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 2427 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
2428 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); | 2428 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); |
2429 | 2429 |
2430 trans1.reset(); | 2430 trans1.reset(); |
2431 | 2431 |
2432 TestCompletionCallback callback2; | 2432 TestCompletionCallback callback2; |
2433 scoped_ptr<HttpTransaction> trans2( | 2433 scoped_ptr<HttpTransaction> trans2( |
2434 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2434 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2435 | 2435 |
2436 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 2436 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
2437 EXPECT_EQ(ERR_IO_PENDING, rv); | 2437 EXPECT_EQ(ERR_IO_PENDING, rv); |
2438 | 2438 |
2439 rv = callback2.WaitForResult(); | 2439 rv = callback2.WaitForResult(); |
2440 EXPECT_EQ(OK, rv); | 2440 EXPECT_EQ(OK, rv); |
2441 | 2441 |
2442 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 2442 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
2443 ASSERT_TRUE(response2 != NULL); | 2443 ASSERT_TRUE(response2 != NULL); |
2444 ASSERT_TRUE(response2->headers != NULL); | 2444 ASSERT_TRUE(response2->headers.get() != NULL); |
2445 EXPECT_EQ(2, response2->headers->GetContentLength()); | 2445 EXPECT_EQ(2, response2->headers->GetContentLength()); |
2446 | 2446 |
2447 LoadTimingInfo load_timing_info2; | 2447 LoadTimingInfo load_timing_info2; |
2448 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 2448 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
2449 TestLoadTimingReused(load_timing_info2); | 2449 TestLoadTimingReused(load_timing_info2); |
2450 | 2450 |
2451 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 2451 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
2452 | 2452 |
2453 trans2.reset(); | 2453 trans2.reset(); |
2454 session->CloseAllConnections(); | 2454 session->CloseAllConnections(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 }; | 2501 }; |
2502 | 2502 |
2503 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2503 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2504 data_writes1, arraysize(data_writes1)); | 2504 data_writes1, arraysize(data_writes1)); |
2505 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2505 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2506 SSLSocketDataProvider ssl(ASYNC, OK); | 2506 SSLSocketDataProvider ssl(ASYNC, OK); |
2507 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2507 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2508 | 2508 |
2509 TestCompletionCallback callback1; | 2509 TestCompletionCallback callback1; |
2510 scoped_ptr<HttpTransaction> trans1( | 2510 scoped_ptr<HttpTransaction> trans1( |
2511 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2511 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2512 | 2512 |
2513 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 2513 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
2514 EXPECT_EQ(ERR_IO_PENDING, rv); | 2514 EXPECT_EQ(ERR_IO_PENDING, rv); |
2515 | 2515 |
2516 rv = callback1.WaitForResult(); | 2516 rv = callback1.WaitForResult(); |
2517 EXPECT_EQ(OK, rv); | 2517 EXPECT_EQ(OK, rv); |
2518 | 2518 |
2519 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 2519 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
2520 ASSERT_TRUE(response1 != NULL); | 2520 ASSERT_TRUE(response1 != NULL); |
2521 ASSERT_TRUE(response1->headers != NULL); | 2521 ASSERT_TRUE(response1->headers.get() != NULL); |
2522 EXPECT_EQ(1, response1->headers->GetContentLength()); | 2522 EXPECT_EQ(1, response1->headers->GetContentLength()); |
2523 | 2523 |
2524 LoadTimingInfo load_timing_info1; | 2524 LoadTimingInfo load_timing_info1; |
2525 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 2525 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
2526 TestLoadTimingNotReusedWithPac(load_timing_info1, | 2526 TestLoadTimingNotReusedWithPac(load_timing_info1, |
2527 CONNECT_TIMING_HAS_SSL_TIMES); | 2527 CONNECT_TIMING_HAS_SSL_TIMES); |
2528 | 2528 |
2529 trans1.reset(); | 2529 trans1.reset(); |
2530 | 2530 |
2531 TestCompletionCallback callback2; | 2531 TestCompletionCallback callback2; |
2532 scoped_ptr<HttpTransaction> trans2( | 2532 scoped_ptr<HttpTransaction> trans2( |
2533 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2533 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2534 | 2534 |
2535 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 2535 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
2536 EXPECT_EQ(ERR_IO_PENDING, rv); | 2536 EXPECT_EQ(ERR_IO_PENDING, rv); |
2537 | 2537 |
2538 rv = callback2.WaitForResult(); | 2538 rv = callback2.WaitForResult(); |
2539 EXPECT_EQ(OK, rv); | 2539 EXPECT_EQ(OK, rv); |
2540 | 2540 |
2541 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 2541 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
2542 ASSERT_TRUE(response2 != NULL); | 2542 ASSERT_TRUE(response2 != NULL); |
2543 ASSERT_TRUE(response2->headers != NULL); | 2543 ASSERT_TRUE(response2->headers.get() != NULL); |
2544 EXPECT_EQ(2, response2->headers->GetContentLength()); | 2544 EXPECT_EQ(2, response2->headers->GetContentLength()); |
2545 | 2545 |
2546 LoadTimingInfo load_timing_info2; | 2546 LoadTimingInfo load_timing_info2; |
2547 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 2547 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
2548 TestLoadTimingReusedWithPac(load_timing_info2); | 2548 TestLoadTimingReusedWithPac(load_timing_info2); |
2549 | 2549 |
2550 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 2550 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
2551 | 2551 |
2552 trans2.reset(); | 2552 trans2.reset(); |
2553 session->CloseAllConnections(); | 2553 session->CloseAllConnections(); |
(...skipping 28 matching lines...) Expand all Loading... |
2582 | 2582 |
2583 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2583 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
2584 data_writes1, arraysize(data_writes1)); | 2584 data_writes1, arraysize(data_writes1)); |
2585 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 2585 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
2586 SSLSocketDataProvider ssl(ASYNC, OK); | 2586 SSLSocketDataProvider ssl(ASYNC, OK); |
2587 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2587 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2588 | 2588 |
2589 TestCompletionCallback callback1; | 2589 TestCompletionCallback callback1; |
2590 | 2590 |
2591 scoped_ptr<HttpTransaction> trans( | 2591 scoped_ptr<HttpTransaction> trans( |
2592 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2592 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2593 | 2593 |
2594 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2594 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2595 EXPECT_EQ(ERR_IO_PENDING, rv); | 2595 EXPECT_EQ(ERR_IO_PENDING, rv); |
2596 | 2596 |
2597 rv = callback1.WaitForResult(); | 2597 rv = callback1.WaitForResult(); |
2598 EXPECT_EQ(OK, rv); | 2598 EXPECT_EQ(OK, rv); |
2599 | 2599 |
2600 LoadTimingInfo load_timing_info; | 2600 LoadTimingInfo load_timing_info; |
2601 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2601 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2602 TestLoadTimingNotReused(load_timing_info, | 2602 TestLoadTimingNotReused(load_timing_info, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2647 spdy_writes, arraysize(spdy_writes)); | 2647 spdy_writes, arraysize(spdy_writes)); |
2648 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 2648 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
2649 | 2649 |
2650 SSLSocketDataProvider ssl(ASYNC, OK); | 2650 SSLSocketDataProvider ssl(ASYNC, OK); |
2651 ssl.SetNextProto(kProtoSPDY2); | 2651 ssl.SetNextProto(kProtoSPDY2); |
2652 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2652 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2653 | 2653 |
2654 TestCompletionCallback callback1; | 2654 TestCompletionCallback callback1; |
2655 | 2655 |
2656 scoped_ptr<HttpTransaction> trans( | 2656 scoped_ptr<HttpTransaction> trans( |
2657 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2657 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2658 | 2658 |
2659 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2659 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2660 EXPECT_EQ(ERR_IO_PENDING, rv); | 2660 EXPECT_EQ(ERR_IO_PENDING, rv); |
2661 | 2661 |
2662 rv = callback1.WaitForResult(); | 2662 rv = callback1.WaitForResult(); |
2663 EXPECT_EQ(OK, rv); | 2663 EXPECT_EQ(OK, rv); |
2664 | 2664 |
2665 LoadTimingInfo load_timing_info; | 2665 LoadTimingInfo load_timing_info; |
2666 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2666 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2667 TestLoadTimingNotReused(load_timing_info, | 2667 TestLoadTimingNotReused(load_timing_info, |
2668 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 2668 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
2669 | 2669 |
2670 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2670 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2671 ASSERT_TRUE(response != NULL); | 2671 ASSERT_TRUE(response != NULL); |
2672 ASSERT_TRUE(response->headers != NULL); | 2672 ASSERT_TRUE(response->headers.get() != NULL); |
2673 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2673 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2674 | 2674 |
2675 std::string response_data; | 2675 std::string response_data; |
2676 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2676 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2677 EXPECT_EQ(kUploadData, response_data); | 2677 EXPECT_EQ(kUploadData, response_data); |
2678 } | 2678 } |
2679 | 2679 |
2680 // Test a SPDY get through an HTTPS Proxy. | 2680 // Test a SPDY get through an HTTPS Proxy. |
2681 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGetWithProxyAuth) { | 2681 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGetWithProxyAuth) { |
2682 HttpRequestInfo request; | 2682 HttpRequestInfo request; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2738 spdy_writes, arraysize(spdy_writes)); | 2738 spdy_writes, arraysize(spdy_writes)); |
2739 session_deps_.socket_factory->AddSocketDataProvider(&data); | 2739 session_deps_.socket_factory->AddSocketDataProvider(&data); |
2740 | 2740 |
2741 SSLSocketDataProvider ssl(ASYNC, OK); | 2741 SSLSocketDataProvider ssl(ASYNC, OK); |
2742 ssl.SetNextProto(kProtoSPDY2); | 2742 ssl.SetNextProto(kProtoSPDY2); |
2743 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 2743 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
2744 | 2744 |
2745 TestCompletionCallback callback1; | 2745 TestCompletionCallback callback1; |
2746 | 2746 |
2747 scoped_ptr<HttpTransaction> trans( | 2747 scoped_ptr<HttpTransaction> trans( |
2748 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2748 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2749 | 2749 |
2750 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2750 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2751 EXPECT_EQ(ERR_IO_PENDING, rv); | 2751 EXPECT_EQ(ERR_IO_PENDING, rv); |
2752 | 2752 |
2753 rv = callback1.WaitForResult(); | 2753 rv = callback1.WaitForResult(); |
2754 EXPECT_EQ(OK, rv); | 2754 EXPECT_EQ(OK, rv); |
2755 | 2755 |
2756 const HttpResponseInfo* const response = trans->GetResponseInfo(); | 2756 const HttpResponseInfo* const response = trans->GetResponseInfo(); |
2757 | 2757 |
2758 ASSERT_TRUE(response != NULL); | 2758 ASSERT_TRUE(response != NULL); |
2759 ASSERT_TRUE(response->headers != NULL); | 2759 ASSERT_TRUE(response->headers.get() != NULL); |
2760 EXPECT_EQ(407, response->headers->response_code()); | 2760 EXPECT_EQ(407, response->headers->response_code()); |
2761 EXPECT_TRUE(response->was_fetched_via_spdy); | 2761 EXPECT_TRUE(response->was_fetched_via_spdy); |
2762 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2762 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2763 | 2763 |
2764 TestCompletionCallback callback2; | 2764 TestCompletionCallback callback2; |
2765 | 2765 |
2766 rv = trans->RestartWithAuth( | 2766 rv = trans->RestartWithAuth( |
2767 AuthCredentials(kFoo, kBar), callback2.callback()); | 2767 AuthCredentials(kFoo, kBar), callback2.callback()); |
2768 EXPECT_EQ(ERR_IO_PENDING, rv); | 2768 EXPECT_EQ(ERR_IO_PENDING, rv); |
2769 | 2769 |
2770 rv = callback2.WaitForResult(); | 2770 rv = callback2.WaitForResult(); |
2771 EXPECT_EQ(OK, rv); | 2771 EXPECT_EQ(OK, rv); |
2772 | 2772 |
2773 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 2773 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
2774 | 2774 |
2775 ASSERT_TRUE(response_restart != NULL); | 2775 ASSERT_TRUE(response_restart != NULL); |
2776 ASSERT_TRUE(response_restart->headers != NULL); | 2776 ASSERT_TRUE(response_restart->headers.get() != NULL); |
2777 EXPECT_EQ(200, response_restart->headers->response_code()); | 2777 EXPECT_EQ(200, response_restart->headers->response_code()); |
2778 // The password prompt info should not be set. | 2778 // The password prompt info should not be set. |
2779 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 2779 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
2780 } | 2780 } |
2781 | 2781 |
2782 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. | 2782 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. |
2783 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectHttps) { | 2783 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectHttps) { |
2784 HttpRequestInfo request; | 2784 HttpRequestInfo request; |
2785 request.method = "GET"; | 2785 request.method = "GET"; |
2786 request.url = GURL("https://www.google.com/"); | 2786 request.url = GURL("https://www.google.com/"); |
2787 request.load_flags = 0; | 2787 request.load_flags = 0; |
2788 | 2788 |
2789 // Configure against https proxy server "proxy:70". | 2789 // Configure against https proxy server "proxy:70". |
2790 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 2790 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
2791 "https://proxy:70")); | 2791 "https://proxy:70")); |
2792 CapturingBoundNetLog log; | 2792 CapturingBoundNetLog log; |
2793 session_deps_.net_log = log.bound().net_log(); | 2793 session_deps_.net_log = log.bound().net_log(); |
2794 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2794 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2795 | 2795 |
2796 scoped_ptr<HttpTransaction> trans( | 2796 scoped_ptr<HttpTransaction> trans( |
2797 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2797 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2798 | 2798 |
2799 // CONNECT to www.google.com:443 via SPDY | 2799 // CONNECT to www.google.com:443 via SPDY |
2800 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); | 2800 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); |
2801 // fetch https://www.google.com/ via HTTP | 2801 // fetch https://www.google.com/ via HTTP |
2802 | 2802 |
2803 const char get[] = "GET / HTTP/1.1\r\n" | 2803 const char get[] = "GET / HTTP/1.1\r\n" |
2804 "Host: www.google.com\r\n" | 2804 "Host: www.google.com\r\n" |
2805 "Connection: keep-alive\r\n\r\n"; | 2805 "Connection: keep-alive\r\n\r\n"; |
2806 scoped_ptr<SpdyFrame> wrapped_get( | 2806 scoped_ptr<SpdyFrame> wrapped_get( |
2807 ConstructSpdyBodyFrame(1, get, strlen(get), false)); | 2807 ConstructSpdyBodyFrame(1, get, strlen(get), false)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 | 2849 |
2850 rv = callback1.WaitForResult(); | 2850 rv = callback1.WaitForResult(); |
2851 EXPECT_EQ(OK, rv); | 2851 EXPECT_EQ(OK, rv); |
2852 | 2852 |
2853 LoadTimingInfo load_timing_info; | 2853 LoadTimingInfo load_timing_info; |
2854 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2854 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2855 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 2855 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
2856 | 2856 |
2857 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2857 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2858 ASSERT_TRUE(response != NULL); | 2858 ASSERT_TRUE(response != NULL); |
2859 ASSERT_TRUE(response->headers != NULL); | 2859 ASSERT_TRUE(response->headers.get() != NULL); |
2860 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2860 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2861 | 2861 |
2862 std::string response_data; | 2862 std::string response_data; |
2863 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2863 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2864 EXPECT_EQ("1234567890", response_data); | 2864 EXPECT_EQ("1234567890", response_data); |
2865 } | 2865 } |
2866 | 2866 |
2867 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. | 2867 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. |
2868 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectSpdy) { | 2868 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectSpdy) { |
2869 HttpRequestInfo request; | 2869 HttpRequestInfo request; |
2870 request.method = "GET"; | 2870 request.method = "GET"; |
2871 request.url = GURL("https://www.google.com/"); | 2871 request.url = GURL("https://www.google.com/"); |
2872 request.load_flags = 0; | 2872 request.load_flags = 0; |
2873 | 2873 |
2874 // Configure against https proxy server "proxy:70". | 2874 // Configure against https proxy server "proxy:70". |
2875 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 2875 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
2876 "https://proxy:70")); | 2876 "https://proxy:70")); |
2877 CapturingBoundNetLog log; | 2877 CapturingBoundNetLog log; |
2878 session_deps_.net_log = log.bound().net_log(); | 2878 session_deps_.net_log = log.bound().net_log(); |
2879 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2879 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2880 | 2880 |
2881 scoped_ptr<HttpTransaction> trans( | 2881 scoped_ptr<HttpTransaction> trans( |
2882 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2882 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2883 | 2883 |
2884 // CONNECT to www.google.com:443 via SPDY | 2884 // CONNECT to www.google.com:443 via SPDY |
2885 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); | 2885 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); |
2886 // fetch https://www.google.com/ via SPDY | 2886 // fetch https://www.google.com/ via SPDY |
2887 const char* const kMyUrl = "https://www.google.com/"; | 2887 const char* const kMyUrl = "https://www.google.com/"; |
2888 scoped_ptr<SpdyFrame> get( | 2888 scoped_ptr<SpdyFrame> get( |
2889 spdy_util_.ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); | 2889 spdy_util_.ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); |
2890 scoped_ptr<SpdyFrame> wrapped_get(ConstructWrappedSpdyFrame(get, 1)); | 2890 scoped_ptr<SpdyFrame> wrapped_get(ConstructWrappedSpdyFrame(get, 1)); |
2891 scoped_ptr<SpdyFrame> conn_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2891 scoped_ptr<SpdyFrame> conn_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
2892 scoped_ptr<SpdyFrame> get_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2892 scoped_ptr<SpdyFrame> get_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2933 | 2933 |
2934 rv = callback1.WaitForResult(); | 2934 rv = callback1.WaitForResult(); |
2935 EXPECT_EQ(OK, rv); | 2935 EXPECT_EQ(OK, rv); |
2936 | 2936 |
2937 LoadTimingInfo load_timing_info; | 2937 LoadTimingInfo load_timing_info; |
2938 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2938 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
2939 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 2939 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
2940 | 2940 |
2941 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2941 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2942 ASSERT_TRUE(response != NULL); | 2942 ASSERT_TRUE(response != NULL); |
2943 ASSERT_TRUE(response->headers != NULL); | 2943 ASSERT_TRUE(response->headers.get() != NULL); |
2944 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2944 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2945 | 2945 |
2946 std::string response_data; | 2946 std::string response_data; |
2947 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2947 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2948 EXPECT_EQ(kUploadData, response_data); | 2948 EXPECT_EQ(kUploadData, response_data); |
2949 } | 2949 } |
2950 | 2950 |
2951 // Test a SPDY CONNECT failure through an HTTPS Proxy. | 2951 // Test a SPDY CONNECT failure through an HTTPS Proxy. |
2952 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectFailure) { | 2952 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectFailure) { |
2953 HttpRequestInfo request; | 2953 HttpRequestInfo request; |
2954 request.method = "GET"; | 2954 request.method = "GET"; |
2955 request.url = GURL("https://www.google.com/"); | 2955 request.url = GURL("https://www.google.com/"); |
2956 request.load_flags = 0; | 2956 request.load_flags = 0; |
2957 | 2957 |
2958 // Configure against https proxy server "proxy:70". | 2958 // Configure against https proxy server "proxy:70". |
2959 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 2959 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
2960 "https://proxy:70")); | 2960 "https://proxy:70")); |
2961 CapturingBoundNetLog log; | 2961 CapturingBoundNetLog log; |
2962 session_deps_.net_log = log.bound().net_log(); | 2962 session_deps_.net_log = log.bound().net_log(); |
2963 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 2963 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
2964 | 2964 |
2965 scoped_ptr<HttpTransaction> trans( | 2965 scoped_ptr<HttpTransaction> trans( |
2966 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 2966 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
2967 | 2967 |
2968 // CONNECT to www.google.com:443 via SPDY | 2968 // CONNECT to www.google.com:443 via SPDY |
2969 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); | 2969 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1)); |
2970 scoped_ptr<SpdyFrame> get( | 2970 scoped_ptr<SpdyFrame> get( |
2971 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 2971 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
2972 | 2972 |
2973 MockWrite spdy_writes[] = { | 2973 MockWrite spdy_writes[] = { |
2974 CreateMockWrite(*connect, 1), | 2974 CreateMockWrite(*connect, 1), |
2975 CreateMockWrite(*get, 3), | 2975 CreateMockWrite(*get, 3), |
2976 }; | 2976 }; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3108 ssl2.protocol_negotiated = kProtoUnknown; | 3108 ssl2.protocol_negotiated = kProtoUnknown; |
3109 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); | 3109 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); |
3110 SSLSocketDataProvider ssl3(ASYNC, OK); | 3110 SSLSocketDataProvider ssl3(ASYNC, OK); |
3111 ssl3.was_npn_negotiated = false; | 3111 ssl3.was_npn_negotiated = false; |
3112 ssl3.protocol_negotiated = kProtoUnknown; | 3112 ssl3.protocol_negotiated = kProtoUnknown; |
3113 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl3); | 3113 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl3); |
3114 | 3114 |
3115 TestCompletionCallback callback; | 3115 TestCompletionCallback callback; |
3116 | 3116 |
3117 scoped_ptr<HttpTransaction> trans( | 3117 scoped_ptr<HttpTransaction> trans( |
3118 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3118 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3119 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 3119 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
3120 EXPECT_EQ(ERR_IO_PENDING, rv); | 3120 EXPECT_EQ(ERR_IO_PENDING, rv); |
3121 // The first connect and request, each of their responses, and the body. | 3121 // The first connect and request, each of their responses, and the body. |
3122 spdy_data.RunFor(5); | 3122 spdy_data.RunFor(5); |
3123 | 3123 |
3124 rv = callback.WaitForResult(); | 3124 rv = callback.WaitForResult(); |
3125 EXPECT_EQ(OK, rv); | 3125 EXPECT_EQ(OK, rv); |
3126 | 3126 |
3127 LoadTimingInfo load_timing_info; | 3127 LoadTimingInfo load_timing_info; |
3128 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3128 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3129 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 3129 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
3130 | 3130 |
3131 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3131 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3132 ASSERT_TRUE(response != NULL); | 3132 ASSERT_TRUE(response != NULL); |
3133 ASSERT_TRUE(response->headers != NULL); | 3133 ASSERT_TRUE(response->headers.get() != NULL); |
3134 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3134 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
3135 | 3135 |
3136 std::string response_data; | 3136 std::string response_data; |
3137 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); | 3137 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
3138 EXPECT_EQ(1, trans->Read(buf, 256, callback.callback())); | 3138 EXPECT_EQ(1, trans->Read(buf.get(), 256, callback.callback())); |
3139 | 3139 |
3140 scoped_ptr<HttpTransaction> trans2( | 3140 scoped_ptr<HttpTransaction> trans2( |
3141 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3141 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3142 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 3142 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
3143 EXPECT_EQ(ERR_IO_PENDING, rv); | 3143 EXPECT_EQ(ERR_IO_PENDING, rv); |
3144 | 3144 |
3145 // The second connect and request, each of their responses, and the body. | 3145 // The second connect and request, each of their responses, and the body. |
3146 spdy_data.RunFor(5); | 3146 spdy_data.RunFor(5); |
3147 rv = callback.WaitForResult(); | 3147 rv = callback.WaitForResult(); |
3148 EXPECT_EQ(OK, rv); | 3148 EXPECT_EQ(OK, rv); |
3149 | 3149 |
3150 LoadTimingInfo load_timing_info2; | 3150 LoadTimingInfo load_timing_info2; |
3151 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 3151 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
3152 // Even though the SPDY connection is reused, a new tunnelled connection has | 3152 // Even though the SPDY connection is reused, a new tunnelled connection has |
3153 // to be created, so the socket's load timing looks like a fresh connection. | 3153 // to be created, so the socket's load timing looks like a fresh connection. |
3154 TestLoadTimingNotReused(load_timing_info2, CONNECT_TIMING_HAS_SSL_TIMES); | 3154 TestLoadTimingNotReused(load_timing_info2, CONNECT_TIMING_HAS_SSL_TIMES); |
3155 | 3155 |
3156 // The requests should have different IDs, since they each are using their own | 3156 // The requests should have different IDs, since they each are using their own |
3157 // separate stream. | 3157 // separate stream. |
3158 EXPECT_NE(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); | 3158 EXPECT_NE(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); |
3159 | 3159 |
3160 EXPECT_EQ(2, trans2->Read(buf, 256, callback.callback())); | 3160 EXPECT_EQ(2, trans2->Read(buf.get(), 256, callback.callback())); |
3161 } | 3161 } |
3162 | 3162 |
3163 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY | 3163 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY |
3164 // HTTPS Proxy to the same server. | 3164 // HTTPS Proxy to the same server. |
3165 TEST_F(HttpNetworkTransactionSpdy2Test, | 3165 TEST_F(HttpNetworkTransactionSpdy2Test, |
3166 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) { | 3166 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) { |
3167 // Configure against https proxy server "proxy:70". | 3167 // Configure against https proxy server "proxy:70". |
3168 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 3168 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
3169 "https://proxy:70")); | 3169 "https://proxy:70")); |
3170 CapturingBoundNetLog log; | 3170 CapturingBoundNetLog log; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3237 ssl.SetNextProto(kProtoSPDY2); | 3237 ssl.SetNextProto(kProtoSPDY2); |
3238 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | 3238 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); |
3239 SSLSocketDataProvider ssl2(ASYNC, OK); | 3239 SSLSocketDataProvider ssl2(ASYNC, OK); |
3240 ssl2.was_npn_negotiated = false; | 3240 ssl2.was_npn_negotiated = false; |
3241 ssl2.protocol_negotiated = kProtoUnknown; | 3241 ssl2.protocol_negotiated = kProtoUnknown; |
3242 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); | 3242 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); |
3243 | 3243 |
3244 TestCompletionCallback callback; | 3244 TestCompletionCallback callback; |
3245 | 3245 |
3246 scoped_ptr<HttpTransaction> trans( | 3246 scoped_ptr<HttpTransaction> trans( |
3247 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3247 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3248 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 3248 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
3249 EXPECT_EQ(ERR_IO_PENDING, rv); | 3249 EXPECT_EQ(ERR_IO_PENDING, rv); |
3250 // The first connect and request, each of their responses, and the body. | 3250 // The first connect and request, each of their responses, and the body. |
3251 spdy_data.RunFor(5); | 3251 spdy_data.RunFor(5); |
3252 | 3252 |
3253 rv = callback.WaitForResult(); | 3253 rv = callback.WaitForResult(); |
3254 EXPECT_EQ(OK, rv); | 3254 EXPECT_EQ(OK, rv); |
3255 | 3255 |
3256 LoadTimingInfo load_timing_info; | 3256 LoadTimingInfo load_timing_info; |
3257 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3257 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3258 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 3258 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
3259 | 3259 |
3260 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3260 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3261 ASSERT_TRUE(response != NULL); | 3261 ASSERT_TRUE(response != NULL); |
3262 ASSERT_TRUE(response->headers != NULL); | 3262 ASSERT_TRUE(response->headers.get() != NULL); |
3263 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3263 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
3264 | 3264 |
3265 std::string response_data; | 3265 std::string response_data; |
3266 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); | 3266 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
3267 EXPECT_EQ(1, trans->Read(buf, 256, callback.callback())); | 3267 EXPECT_EQ(1, trans->Read(buf.get(), 256, callback.callback())); |
3268 trans.reset(); | 3268 trans.reset(); |
3269 | 3269 |
3270 scoped_ptr<HttpTransaction> trans2( | 3270 scoped_ptr<HttpTransaction> trans2( |
3271 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3271 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3272 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 3272 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
3273 EXPECT_EQ(ERR_IO_PENDING, rv); | 3273 EXPECT_EQ(ERR_IO_PENDING, rv); |
3274 | 3274 |
3275 // The second request, response, and body. There should not be a second | 3275 // The second request, response, and body. There should not be a second |
3276 // connect. | 3276 // connect. |
3277 spdy_data.RunFor(3); | 3277 spdy_data.RunFor(3); |
3278 rv = callback.WaitForResult(); | 3278 rv = callback.WaitForResult(); |
3279 EXPECT_EQ(OK, rv); | 3279 EXPECT_EQ(OK, rv); |
3280 | 3280 |
3281 LoadTimingInfo load_timing_info2; | 3281 LoadTimingInfo load_timing_info2; |
3282 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 3282 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
3283 TestLoadTimingReused(load_timing_info2); | 3283 TestLoadTimingReused(load_timing_info2); |
3284 | 3284 |
3285 // The requests should have the same ID. | 3285 // The requests should have the same ID. |
3286 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); | 3286 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); |
3287 | 3287 |
3288 EXPECT_EQ(2, trans2->Read(buf, 256, callback.callback())); | 3288 EXPECT_EQ(2, trans2->Read(buf.get(), 256, callback.callback())); |
3289 } | 3289 } |
3290 | 3290 |
3291 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS | 3291 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS |
3292 // Proxy to different servers. | 3292 // Proxy to different servers. |
3293 TEST_F(HttpNetworkTransactionSpdy2Test, | 3293 TEST_F(HttpNetworkTransactionSpdy2Test, |
3294 HttpsProxySpdyLoadTimingTwoHttpRequests) { | 3294 HttpsProxySpdyLoadTimingTwoHttpRequests) { |
3295 // Configure against https proxy server "proxy:70". | 3295 // Configure against https proxy server "proxy:70". |
3296 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 3296 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
3297 "https://proxy:70")); | 3297 "https://proxy:70")); |
3298 CapturingBoundNetLog log; | 3298 CapturingBoundNetLog log; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3356 spdy_writes, arraysize(spdy_writes)); | 3356 spdy_writes, arraysize(spdy_writes)); |
3357 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&spdy_data); | 3357 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&spdy_data); |
3358 | 3358 |
3359 SSLSocketDataProvider ssl(ASYNC, OK); | 3359 SSLSocketDataProvider ssl(ASYNC, OK); |
3360 ssl.SetNextProto(kProtoSPDY2); | 3360 ssl.SetNextProto(kProtoSPDY2); |
3361 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); | 3361 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); |
3362 | 3362 |
3363 TestCompletionCallback callback; | 3363 TestCompletionCallback callback; |
3364 | 3364 |
3365 scoped_ptr<HttpTransaction> trans( | 3365 scoped_ptr<HttpTransaction> trans( |
3366 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3366 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3367 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 3367 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
3368 EXPECT_EQ(ERR_IO_PENDING, rv); | 3368 EXPECT_EQ(ERR_IO_PENDING, rv); |
3369 spdy_data.RunFor(2); | 3369 spdy_data.RunFor(2); |
3370 | 3370 |
3371 rv = callback.WaitForResult(); | 3371 rv = callback.WaitForResult(); |
3372 EXPECT_EQ(OK, rv); | 3372 EXPECT_EQ(OK, rv); |
3373 | 3373 |
3374 LoadTimingInfo load_timing_info; | 3374 LoadTimingInfo load_timing_info; |
3375 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3375 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3376 TestLoadTimingNotReused(load_timing_info, | 3376 TestLoadTimingNotReused(load_timing_info, |
3377 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 3377 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
3378 | 3378 |
3379 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3379 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3380 ASSERT_TRUE(response != NULL); | 3380 ASSERT_TRUE(response != NULL); |
3381 ASSERT_TRUE(response->headers != NULL); | 3381 ASSERT_TRUE(response->headers.get() != NULL); |
3382 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3382 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
3383 | 3383 |
3384 std::string response_data; | 3384 std::string response_data; |
3385 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); | 3385 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
3386 EXPECT_EQ(ERR_IO_PENDING, trans->Read(buf, 256, callback.callback())); | 3386 EXPECT_EQ(ERR_IO_PENDING, trans->Read(buf.get(), 256, callback.callback())); |
3387 spdy_data.RunFor(1); | 3387 spdy_data.RunFor(1); |
3388 EXPECT_EQ(1, callback.WaitForResult()); | 3388 EXPECT_EQ(1, callback.WaitForResult()); |
3389 // Delete the first request, so the second one can reuse the socket. | 3389 // Delete the first request, so the second one can reuse the socket. |
3390 trans.reset(); | 3390 trans.reset(); |
3391 | 3391 |
3392 scoped_ptr<HttpTransaction> trans2( | 3392 scoped_ptr<HttpTransaction> trans2( |
3393 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3393 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3394 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 3394 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
3395 EXPECT_EQ(ERR_IO_PENDING, rv); | 3395 EXPECT_EQ(ERR_IO_PENDING, rv); |
3396 | 3396 |
3397 spdy_data.RunFor(2); | 3397 spdy_data.RunFor(2); |
3398 rv = callback.WaitForResult(); | 3398 rv = callback.WaitForResult(); |
3399 EXPECT_EQ(OK, rv); | 3399 EXPECT_EQ(OK, rv); |
3400 | 3400 |
3401 LoadTimingInfo load_timing_info2; | 3401 LoadTimingInfo load_timing_info2; |
3402 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 3402 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
3403 TestLoadTimingReused(load_timing_info2); | 3403 TestLoadTimingReused(load_timing_info2); |
3404 | 3404 |
3405 // The requests should have the same ID. | 3405 // The requests should have the same ID. |
3406 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); | 3406 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); |
3407 | 3407 |
3408 EXPECT_EQ(ERR_IO_PENDING, trans2->Read(buf, 256, callback.callback())); | 3408 EXPECT_EQ(ERR_IO_PENDING, trans2->Read(buf.get(), 256, callback.callback())); |
3409 spdy_data.RunFor(1); | 3409 spdy_data.RunFor(1); |
3410 EXPECT_EQ(2, callback.WaitForResult()); | 3410 EXPECT_EQ(2, callback.WaitForResult()); |
3411 } | 3411 } |
3412 | 3412 |
3413 // Test the challenge-response-retry sequence through an HTTPS Proxy | 3413 // Test the challenge-response-retry sequence through an HTTPS Proxy |
3414 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyAuthRetry) { | 3414 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyAuthRetry) { |
3415 HttpRequestInfo request; | 3415 HttpRequestInfo request; |
3416 request.method = "GET"; | 3416 request.method = "GET"; |
3417 request.url = GURL("http://www.google.com/"); | 3417 request.url = GURL("http://www.google.com/"); |
3418 // when the no authentication data flag is set. | 3418 // when the no authentication data flag is set. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3456 | 3456 |
3457 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3457 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
3458 data_writes1, arraysize(data_writes1)); | 3458 data_writes1, arraysize(data_writes1)); |
3459 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 3459 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
3460 SSLSocketDataProvider ssl(ASYNC, OK); | 3460 SSLSocketDataProvider ssl(ASYNC, OK); |
3461 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 3461 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
3462 | 3462 |
3463 TestCompletionCallback callback1; | 3463 TestCompletionCallback callback1; |
3464 | 3464 |
3465 scoped_ptr<HttpTransaction> trans( | 3465 scoped_ptr<HttpTransaction> trans( |
3466 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3466 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3467 | 3467 |
3468 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 3468 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
3469 EXPECT_EQ(ERR_IO_PENDING, rv); | 3469 EXPECT_EQ(ERR_IO_PENDING, rv); |
3470 | 3470 |
3471 rv = callback1.WaitForResult(); | 3471 rv = callback1.WaitForResult(); |
3472 EXPECT_EQ(OK, rv); | 3472 EXPECT_EQ(OK, rv); |
3473 | 3473 |
3474 LoadTimingInfo load_timing_info; | 3474 LoadTimingInfo load_timing_info; |
3475 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3475 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
3476 TestLoadTimingNotReused(load_timing_info, | 3476 TestLoadTimingNotReused(load_timing_info, |
3477 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 3477 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
3478 | 3478 |
3479 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3479 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3480 ASSERT_TRUE(response != NULL); | 3480 ASSERT_TRUE(response != NULL); |
3481 ASSERT_FALSE(response->headers == NULL); | 3481 ASSERT_FALSE(response->headers.get() == NULL); |
3482 EXPECT_EQ(407, response->headers->response_code()); | 3482 EXPECT_EQ(407, response->headers->response_code()); |
3483 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 3483 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
3484 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 3484 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
3485 | 3485 |
3486 TestCompletionCallback callback2; | 3486 TestCompletionCallback callback2; |
3487 | 3487 |
3488 rv = trans->RestartWithAuth( | 3488 rv = trans->RestartWithAuth( |
3489 AuthCredentials(kFoo, kBar), callback2.callback()); | 3489 AuthCredentials(kFoo, kBar), callback2.callback()); |
3490 EXPECT_EQ(ERR_IO_PENDING, rv); | 3490 EXPECT_EQ(ERR_IO_PENDING, rv); |
3491 | 3491 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3535 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 3535 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
3536 }; | 3536 }; |
3537 | 3537 |
3538 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 3538 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
3539 data_writes, arraysize(data_writes)); | 3539 data_writes, arraysize(data_writes)); |
3540 session_deps_.socket_factory->AddSocketDataProvider(&data); | 3540 session_deps_.socket_factory->AddSocketDataProvider(&data); |
3541 | 3541 |
3542 TestCompletionCallback callback; | 3542 TestCompletionCallback callback; |
3543 | 3543 |
3544 scoped_ptr<HttpTransaction> trans( | 3544 scoped_ptr<HttpTransaction> trans( |
3545 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3545 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3546 | 3546 |
3547 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3547 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
3548 EXPECT_EQ(ERR_IO_PENDING, rv); | 3548 EXPECT_EQ(ERR_IO_PENDING, rv); |
3549 | 3549 |
3550 rv = callback.WaitForResult(); | 3550 rv = callback.WaitForResult(); |
3551 EXPECT_EQ(expected_status, rv); | 3551 EXPECT_EQ(expected_status, rv); |
3552 } | 3552 } |
3553 | 3553 |
3554 void HttpNetworkTransactionSpdy2Test::ConnectStatusHelper( | 3554 void HttpNetworkTransactionSpdy2Test::ConnectStatusHelper( |
3555 const MockRead& status) { | 3555 const MockRead& status) { |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3931 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3931 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
3932 data_writes1, arraysize(data_writes1)); | 3932 data_writes1, arraysize(data_writes1)); |
3933 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3933 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
3934 data_writes2, arraysize(data_writes2)); | 3934 data_writes2, arraysize(data_writes2)); |
3935 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 3935 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
3936 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 3936 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
3937 | 3937 |
3938 TestCompletionCallback callback1; | 3938 TestCompletionCallback callback1; |
3939 | 3939 |
3940 scoped_ptr<HttpTransaction> trans( | 3940 scoped_ptr<HttpTransaction> trans( |
3941 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 3941 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3942 | 3942 |
3943 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 3943 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
3944 EXPECT_EQ(ERR_IO_PENDING, rv); | 3944 EXPECT_EQ(ERR_IO_PENDING, rv); |
3945 | 3945 |
3946 rv = callback1.WaitForResult(); | 3946 rv = callback1.WaitForResult(); |
3947 EXPECT_EQ(OK, rv); | 3947 EXPECT_EQ(OK, rv); |
3948 | 3948 |
3949 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3949 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3950 | 3950 |
3951 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3951 const HttpResponseInfo* response = trans->GetResponseInfo(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4111 data_writes2, arraysize(data_writes2)); | 4111 data_writes2, arraysize(data_writes2)); |
4112 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 4112 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
4113 data_writes3, arraysize(data_writes3)); | 4113 data_writes3, arraysize(data_writes3)); |
4114 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 4114 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
4115 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 4115 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
4116 session_deps_.socket_factory->AddSocketDataProvider(&data3); | 4116 session_deps_.socket_factory->AddSocketDataProvider(&data3); |
4117 | 4117 |
4118 TestCompletionCallback callback1; | 4118 TestCompletionCallback callback1; |
4119 | 4119 |
4120 scoped_ptr<HttpTransaction> trans( | 4120 scoped_ptr<HttpTransaction> trans( |
4121 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4121 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4122 | 4122 |
4123 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4123 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
4124 EXPECT_EQ(ERR_IO_PENDING, rv); | 4124 EXPECT_EQ(ERR_IO_PENDING, rv); |
4125 | 4125 |
4126 rv = callback1.WaitForResult(); | 4126 rv = callback1.WaitForResult(); |
4127 EXPECT_EQ(OK, rv); | 4127 EXPECT_EQ(OK, rv); |
4128 | 4128 |
4129 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 4129 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
4130 | 4130 |
4131 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4131 const HttpResponseInfo* response = trans->GetResponseInfo(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4228 request.method = "GET"; | 4228 request.method = "GET"; |
4229 request.url = GURL("https://www.google.com/"); | 4229 request.url = GURL("https://www.google.com/"); |
4230 request.load_flags = 0; | 4230 request.load_flags = 0; |
4231 | 4231 |
4232 // Configure against proxy server "myproxy:70". | 4232 // Configure against proxy server "myproxy:70". |
4233 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); | 4233 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); |
4234 | 4234 |
4235 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4235 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4236 | 4236 |
4237 scoped_ptr<HttpTransaction> trans( | 4237 scoped_ptr<HttpTransaction> trans( |
4238 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4238 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4239 | 4239 |
4240 // Since we have proxy, should try to establish tunnel. | 4240 // Since we have proxy, should try to establish tunnel. |
4241 MockWrite data_writes1[] = { | 4241 MockWrite data_writes1[] = { |
4242 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4242 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
4243 "Host: www.google.com\r\n" | 4243 "Host: www.google.com\r\n" |
4244 "Proxy-Connection: keep-alive\r\n\r\n"), | 4244 "Proxy-Connection: keep-alive\r\n\r\n"), |
4245 }; | 4245 }; |
4246 | 4246 |
4247 // The proxy responds to the connect with a 404, using a persistent | 4247 // The proxy responds to the connect with a 404, using a persistent |
4248 // connection. Usually a proxy would return 501 (not implemented), | 4248 // connection. Usually a proxy would return 501 (not implemented), |
(...skipping 18 matching lines...) Expand all Loading... |
4267 | 4267 |
4268 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4268 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4269 EXPECT_TRUE(response == NULL); | 4269 EXPECT_TRUE(response == NULL); |
4270 | 4270 |
4271 // Empty the current queue. This is necessary because idle sockets are | 4271 // Empty the current queue. This is necessary because idle sockets are |
4272 // added to the connection pool asynchronously with a PostTask. | 4272 // added to the connection pool asynchronously with a PostTask. |
4273 base::MessageLoop::current()->RunUntilIdle(); | 4273 base::MessageLoop::current()->RunUntilIdle(); |
4274 | 4274 |
4275 // We now check to make sure the TCPClientSocket was not added back to | 4275 // We now check to make sure the TCPClientSocket was not added back to |
4276 // the pool. | 4276 // the pool. |
4277 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4277 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4278 trans.reset(); | 4278 trans.reset(); |
4279 base::MessageLoop::current()->RunUntilIdle(); | 4279 base::MessageLoop::current()->RunUntilIdle(); |
4280 // Make sure that the socket didn't get recycled after calling the destructor. | 4280 // Make sure that the socket didn't get recycled after calling the destructor. |
4281 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4281 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4282 } | 4282 } |
4283 | 4283 |
4284 // Make sure that we recycle a socket after reading all of the response body. | 4284 // Make sure that we recycle a socket after reading all of the response body. |
4285 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocket) { | 4285 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocket) { |
4286 HttpRequestInfo request; | 4286 HttpRequestInfo request; |
4287 request.method = "GET"; | 4287 request.method = "GET"; |
4288 request.url = GURL("http://www.google.com/"); | 4288 request.url = GURL("http://www.google.com/"); |
4289 request.load_flags = 0; | 4289 request.load_flags = 0; |
4290 | 4290 |
4291 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4291 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4292 | 4292 |
4293 scoped_ptr<HttpTransaction> trans( | 4293 scoped_ptr<HttpTransaction> trans( |
4294 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4294 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4295 | 4295 |
4296 MockRead data_reads[] = { | 4296 MockRead data_reads[] = { |
4297 // A part of the response body is received with the response headers. | 4297 // A part of the response body is received with the response headers. |
4298 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), | 4298 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), |
4299 // The rest of the response body is received in two parts. | 4299 // The rest of the response body is received in two parts. |
4300 MockRead("lo"), | 4300 MockRead("lo"), |
4301 MockRead(" world"), | 4301 MockRead(" world"), |
4302 MockRead("junk"), // Should not be read!! | 4302 MockRead("junk"), // Should not be read!! |
4303 MockRead(SYNCHRONOUS, OK), | 4303 MockRead(SYNCHRONOUS, OK), |
4304 }; | 4304 }; |
4305 | 4305 |
4306 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 4306 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
4307 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4307 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4308 | 4308 |
4309 TestCompletionCallback callback; | 4309 TestCompletionCallback callback; |
4310 | 4310 |
4311 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4311 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4312 EXPECT_EQ(ERR_IO_PENDING, rv); | 4312 EXPECT_EQ(ERR_IO_PENDING, rv); |
4313 | 4313 |
4314 rv = callback.WaitForResult(); | 4314 rv = callback.WaitForResult(); |
4315 EXPECT_EQ(OK, rv); | 4315 EXPECT_EQ(OK, rv); |
4316 | 4316 |
4317 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4317 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4318 ASSERT_TRUE(response != NULL); | 4318 ASSERT_TRUE(response != NULL); |
4319 | 4319 |
4320 EXPECT_TRUE(response->headers != NULL); | 4320 EXPECT_TRUE(response->headers.get() != NULL); |
4321 std::string status_line = response->headers->GetStatusLine(); | 4321 std::string status_line = response->headers->GetStatusLine(); |
4322 EXPECT_EQ("HTTP/1.1 200 OK", status_line); | 4322 EXPECT_EQ("HTTP/1.1 200 OK", status_line); |
4323 | 4323 |
4324 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4324 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4325 | 4325 |
4326 std::string response_data; | 4326 std::string response_data; |
4327 rv = ReadTransaction(trans.get(), &response_data); | 4327 rv = ReadTransaction(trans.get(), &response_data); |
4328 EXPECT_EQ(OK, rv); | 4328 EXPECT_EQ(OK, rv); |
4329 EXPECT_EQ("hello world", response_data); | 4329 EXPECT_EQ("hello world", response_data); |
4330 | 4330 |
4331 // Empty the current queue. This is necessary because idle sockets are | 4331 // Empty the current queue. This is necessary because idle sockets are |
4332 // added to the connection pool asynchronously with a PostTask. | 4332 // added to the connection pool asynchronously with a PostTask. |
4333 base::MessageLoop::current()->RunUntilIdle(); | 4333 base::MessageLoop::current()->RunUntilIdle(); |
4334 | 4334 |
4335 // We now check to make sure the socket was added back to the pool. | 4335 // We now check to make sure the socket was added back to the pool. |
4336 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); | 4336 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
4337 } | 4337 } |
4338 | 4338 |
4339 // Make sure that we recycle a SSL socket after reading all of the response | 4339 // Make sure that we recycle a SSL socket after reading all of the response |
4340 // body. | 4340 // body. |
4341 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSSLSocket) { | 4341 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSSLSocket) { |
4342 HttpRequestInfo request; | 4342 HttpRequestInfo request; |
4343 request.method = "GET"; | 4343 request.method = "GET"; |
4344 request.url = GURL("https://www.google.com/"); | 4344 request.url = GURL("https://www.google.com/"); |
4345 request.load_flags = 0; | 4345 request.load_flags = 0; |
4346 | 4346 |
(...skipping 14 matching lines...) Expand all Loading... |
4361 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 4361 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
4362 | 4362 |
4363 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4363 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
4364 data_writes, arraysize(data_writes)); | 4364 data_writes, arraysize(data_writes)); |
4365 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4365 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4366 | 4366 |
4367 TestCompletionCallback callback; | 4367 TestCompletionCallback callback; |
4368 | 4368 |
4369 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4369 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4370 scoped_ptr<HttpTransaction> trans( | 4370 scoped_ptr<HttpTransaction> trans( |
4371 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4371 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4372 | 4372 |
4373 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4373 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4374 | 4374 |
4375 EXPECT_EQ(ERR_IO_PENDING, rv); | 4375 EXPECT_EQ(ERR_IO_PENDING, rv); |
4376 EXPECT_EQ(OK, callback.WaitForResult()); | 4376 EXPECT_EQ(OK, callback.WaitForResult()); |
4377 | 4377 |
4378 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4378 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4379 ASSERT_TRUE(response != NULL); | 4379 ASSERT_TRUE(response != NULL); |
4380 ASSERT_TRUE(response->headers != NULL); | 4380 ASSERT_TRUE(response->headers.get() != NULL); |
4381 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4381 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4382 | 4382 |
4383 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4383 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4384 | 4384 |
4385 std::string response_data; | 4385 std::string response_data; |
4386 rv = ReadTransaction(trans.get(), &response_data); | 4386 rv = ReadTransaction(trans.get(), &response_data); |
4387 EXPECT_EQ(OK, rv); | 4387 EXPECT_EQ(OK, rv); |
4388 EXPECT_EQ("hello world", response_data); | 4388 EXPECT_EQ("hello world", response_data); |
4389 | 4389 |
4390 // Empty the current queue. This is necessary because idle sockets are | 4390 // Empty the current queue. This is necessary because idle sockets are |
4391 // added to the connection pool asynchronously with a PostTask. | 4391 // added to the connection pool asynchronously with a PostTask. |
4392 base::MessageLoop::current()->RunUntilIdle(); | 4392 base::MessageLoop::current()->RunUntilIdle(); |
4393 | 4393 |
4394 // We now check to make sure the socket was added back to the pool. | 4394 // We now check to make sure the socket was added back to the pool. |
4395 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); | 4395 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
4396 } | 4396 } |
4397 | 4397 |
4398 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it | 4398 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it |
4399 // from the pool and make sure that we recover okay. | 4399 // from the pool and make sure that we recover okay. |
4400 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleDeadSSLSocket) { | 4400 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleDeadSSLSocket) { |
4401 HttpRequestInfo request; | 4401 HttpRequestInfo request; |
4402 request.method = "GET"; | 4402 request.method = "GET"; |
4403 request.url = GURL("https://www.google.com/"); | 4403 request.url = GURL("https://www.google.com/"); |
4404 request.load_flags = 0; | 4404 request.load_flags = 0; |
4405 | 4405 |
(...skipping 23 matching lines...) Expand all Loading... |
4429 data_writes, arraysize(data_writes)); | 4429 data_writes, arraysize(data_writes)); |
4430 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), | 4430 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), |
4431 data_writes, arraysize(data_writes)); | 4431 data_writes, arraysize(data_writes)); |
4432 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4432 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4433 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 4433 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
4434 | 4434 |
4435 TestCompletionCallback callback; | 4435 TestCompletionCallback callback; |
4436 | 4436 |
4437 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4437 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4438 scoped_ptr<HttpTransaction> trans( | 4438 scoped_ptr<HttpTransaction> trans( |
4439 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4439 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4440 | 4440 |
4441 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4441 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4442 | 4442 |
4443 EXPECT_EQ(ERR_IO_PENDING, rv); | 4443 EXPECT_EQ(ERR_IO_PENDING, rv); |
4444 EXPECT_EQ(OK, callback.WaitForResult()); | 4444 EXPECT_EQ(OK, callback.WaitForResult()); |
4445 | 4445 |
4446 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4446 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4447 ASSERT_TRUE(response != NULL); | 4447 ASSERT_TRUE(response != NULL); |
4448 ASSERT_TRUE(response->headers != NULL); | 4448 ASSERT_TRUE(response->headers.get() != NULL); |
4449 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4449 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4450 | 4450 |
4451 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4451 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4452 | 4452 |
4453 std::string response_data; | 4453 std::string response_data; |
4454 rv = ReadTransaction(trans.get(), &response_data); | 4454 rv = ReadTransaction(trans.get(), &response_data); |
4455 EXPECT_EQ(OK, rv); | 4455 EXPECT_EQ(OK, rv); |
4456 EXPECT_EQ("hello world", response_data); | 4456 EXPECT_EQ("hello world", response_data); |
4457 | 4457 |
4458 // Empty the current queue. This is necessary because idle sockets are | 4458 // Empty the current queue. This is necessary because idle sockets are |
4459 // added to the connection pool asynchronously with a PostTask. | 4459 // added to the connection pool asynchronously with a PostTask. |
4460 base::MessageLoop::current()->RunUntilIdle(); | 4460 base::MessageLoop::current()->RunUntilIdle(); |
4461 | 4461 |
4462 // We now check to make sure the socket was added back to the pool. | 4462 // We now check to make sure the socket was added back to the pool. |
4463 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); | 4463 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
4464 | 4464 |
4465 // Now start the second transaction, which should reuse the previous socket. | 4465 // Now start the second transaction, which should reuse the previous socket. |
4466 | 4466 |
4467 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4467 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4468 | 4468 |
4469 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4469 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4470 | 4470 |
4471 EXPECT_EQ(ERR_IO_PENDING, rv); | 4471 EXPECT_EQ(ERR_IO_PENDING, rv); |
4472 EXPECT_EQ(OK, callback.WaitForResult()); | 4472 EXPECT_EQ(OK, callback.WaitForResult()); |
4473 | 4473 |
4474 response = trans->GetResponseInfo(); | 4474 response = trans->GetResponseInfo(); |
4475 ASSERT_TRUE(response != NULL); | 4475 ASSERT_TRUE(response != NULL); |
4476 ASSERT_TRUE(response->headers != NULL); | 4476 ASSERT_TRUE(response->headers.get() != NULL); |
4477 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4477 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4478 | 4478 |
4479 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4479 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4480 | 4480 |
4481 rv = ReadTransaction(trans.get(), &response_data); | 4481 rv = ReadTransaction(trans.get(), &response_data); |
4482 EXPECT_EQ(OK, rv); | 4482 EXPECT_EQ(OK, rv); |
4483 EXPECT_EQ("hello world", response_data); | 4483 EXPECT_EQ("hello world", response_data); |
4484 | 4484 |
4485 // Empty the current queue. This is necessary because idle sockets are | 4485 // Empty the current queue. This is necessary because idle sockets are |
4486 // added to the connection pool asynchronously with a PostTask. | 4486 // added to the connection pool asynchronously with a PostTask. |
4487 base::MessageLoop::current()->RunUntilIdle(); | 4487 base::MessageLoop::current()->RunUntilIdle(); |
4488 | 4488 |
4489 // We now check to make sure the socket was added back to the pool. | 4489 // We now check to make sure the socket was added back to the pool. |
4490 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); | 4490 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
4491 } | 4491 } |
4492 | 4492 |
4493 // Make sure that we recycle a socket after a zero-length response. | 4493 // Make sure that we recycle a socket after a zero-length response. |
4494 // http://crbug.com/9880 | 4494 // http://crbug.com/9880 |
4495 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocketAfterZeroContentLength) { | 4495 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocketAfterZeroContentLength) { |
4496 HttpRequestInfo request; | 4496 HttpRequestInfo request; |
4497 request.method = "GET"; | 4497 request.method = "GET"; |
4498 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" | 4498 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" |
4499 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" | 4499 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" |
4500 "e=17259,18167,19592,19773,19981,20133,20173,20233&" | 4500 "e=17259,18167,19592,19773,19981,20133,20173,20233&" |
4501 "rt=prt.2642,ol.2649,xjs.2951"); | 4501 "rt=prt.2642,ol.2649,xjs.2951"); |
4502 request.load_flags = 0; | 4502 request.load_flags = 0; |
4503 | 4503 |
4504 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4504 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4505 | 4505 |
4506 scoped_ptr<HttpTransaction> trans( | 4506 scoped_ptr<HttpTransaction> trans( |
4507 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4507 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4508 | 4508 |
4509 MockRead data_reads[] = { | 4509 MockRead data_reads[] = { |
4510 MockRead("HTTP/1.1 204 No Content\r\n" | 4510 MockRead("HTTP/1.1 204 No Content\r\n" |
4511 "Content-Length: 0\r\n" | 4511 "Content-Length: 0\r\n" |
4512 "Content-Type: text/html\r\n\r\n"), | 4512 "Content-Type: text/html\r\n\r\n"), |
4513 MockRead("junk"), // Should not be read!! | 4513 MockRead("junk"), // Should not be read!! |
4514 MockRead(SYNCHRONOUS, OK), | 4514 MockRead(SYNCHRONOUS, OK), |
4515 }; | 4515 }; |
4516 | 4516 |
4517 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 4517 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
4518 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4518 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4519 | 4519 |
4520 TestCompletionCallback callback; | 4520 TestCompletionCallback callback; |
4521 | 4521 |
4522 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4522 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4523 EXPECT_EQ(ERR_IO_PENDING, rv); | 4523 EXPECT_EQ(ERR_IO_PENDING, rv); |
4524 | 4524 |
4525 rv = callback.WaitForResult(); | 4525 rv = callback.WaitForResult(); |
4526 EXPECT_EQ(OK, rv); | 4526 EXPECT_EQ(OK, rv); |
4527 | 4527 |
4528 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4528 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4529 ASSERT_TRUE(response != NULL); | 4529 ASSERT_TRUE(response != NULL); |
4530 | 4530 |
4531 EXPECT_TRUE(response->headers != NULL); | 4531 EXPECT_TRUE(response->headers.get() != NULL); |
4532 std::string status_line = response->headers->GetStatusLine(); | 4532 std::string status_line = response->headers->GetStatusLine(); |
4533 EXPECT_EQ("HTTP/1.1 204 No Content", status_line); | 4533 EXPECT_EQ("HTTP/1.1 204 No Content", status_line); |
4534 | 4534 |
4535 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 4535 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
4536 | 4536 |
4537 std::string response_data; | 4537 std::string response_data; |
4538 rv = ReadTransaction(trans.get(), &response_data); | 4538 rv = ReadTransaction(trans.get(), &response_data); |
4539 EXPECT_EQ(OK, rv); | 4539 EXPECT_EQ(OK, rv); |
4540 EXPECT_EQ("", response_data); | 4540 EXPECT_EQ("", response_data); |
4541 | 4541 |
4542 // Empty the current queue. This is necessary because idle sockets are | 4542 // Empty the current queue. This is necessary because idle sockets are |
4543 // added to the connection pool asynchronously with a PostTask. | 4543 // added to the connection pool asynchronously with a PostTask. |
4544 base::MessageLoop::current()->RunUntilIdle(); | 4544 base::MessageLoop::current()->RunUntilIdle(); |
4545 | 4545 |
4546 // We now check to make sure the socket was added back to the pool. | 4546 // We now check to make sure the socket was added back to the pool. |
4547 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); | 4547 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
4548 } | 4548 } |
4549 | 4549 |
4550 TEST_F(HttpNetworkTransactionSpdy2Test, ResendRequestOnWriteBodyError) { | 4550 TEST_F(HttpNetworkTransactionSpdy2Test, ResendRequestOnWriteBodyError) { |
4551 ScopedVector<UploadElementReader> element_readers; | 4551 ScopedVector<UploadElementReader> element_readers; |
4552 element_readers.push_back(new UploadBytesElementReader("foo", 3)); | 4552 element_readers.push_back(new UploadBytesElementReader("foo", 3)); |
4553 UploadDataStream upload_data_stream(&element_readers, 0); | 4553 UploadDataStream upload_data_stream(&element_readers, 0); |
4554 | 4554 |
4555 HttpRequestInfo request[2]; | 4555 HttpRequestInfo request[2]; |
4556 // Transaction 1: a GET request that succeeds. The socket is recycled | 4556 // Transaction 1: a GET request that succeeds. The socket is recycled |
4557 // after use. | 4557 // after use. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4606 | 4606 |
4607 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 4607 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
4608 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 4608 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
4609 | 4609 |
4610 const char* kExpectedResponseData[] = { | 4610 const char* kExpectedResponseData[] = { |
4611 "hello world", "welcome" | 4611 "hello world", "welcome" |
4612 }; | 4612 }; |
4613 | 4613 |
4614 for (int i = 0; i < 2; ++i) { | 4614 for (int i = 0; i < 2; ++i) { |
4615 scoped_ptr<HttpTransaction> trans( | 4615 scoped_ptr<HttpTransaction> trans( |
4616 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4616 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4617 | 4617 |
4618 TestCompletionCallback callback; | 4618 TestCompletionCallback callback; |
4619 | 4619 |
4620 int rv = trans->Start(&request[i], callback.callback(), BoundNetLog()); | 4620 int rv = trans->Start(&request[i], callback.callback(), BoundNetLog()); |
4621 EXPECT_EQ(ERR_IO_PENDING, rv); | 4621 EXPECT_EQ(ERR_IO_PENDING, rv); |
4622 | 4622 |
4623 rv = callback.WaitForResult(); | 4623 rv = callback.WaitForResult(); |
4624 EXPECT_EQ(OK, rv); | 4624 EXPECT_EQ(OK, rv); |
4625 | 4625 |
4626 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4626 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4627 ASSERT_TRUE(response != NULL); | 4627 ASSERT_TRUE(response != NULL); |
4628 | 4628 |
4629 EXPECT_TRUE(response->headers != NULL); | 4629 EXPECT_TRUE(response->headers.get() != NULL); |
4630 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4630 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4631 | 4631 |
4632 std::string response_data; | 4632 std::string response_data; |
4633 rv = ReadTransaction(trans.get(), &response_data); | 4633 rv = ReadTransaction(trans.get(), &response_data); |
4634 EXPECT_EQ(OK, rv); | 4634 EXPECT_EQ(OK, rv); |
4635 EXPECT_EQ(kExpectedResponseData[i], response_data); | 4635 EXPECT_EQ(kExpectedResponseData[i], response_data); |
4636 } | 4636 } |
4637 } | 4637 } |
4638 | 4638 |
4639 // Test the request-challenge-retry sequence for basic auth when there is | 4639 // 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... |
4829 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4829 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
4830 | 4830 |
4831 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 4831 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
4832 { | 4832 { |
4833 HttpRequestInfo request; | 4833 HttpRequestInfo request; |
4834 request.method = "GET"; | 4834 request.method = "GET"; |
4835 request.url = GURL("http://www.google.com/x/y/z"); | 4835 request.url = GURL("http://www.google.com/x/y/z"); |
4836 request.load_flags = 0; | 4836 request.load_flags = 0; |
4837 | 4837 |
4838 scoped_ptr<HttpTransaction> trans( | 4838 scoped_ptr<HttpTransaction> trans( |
4839 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4839 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4840 | 4840 |
4841 MockWrite data_writes1[] = { | 4841 MockWrite data_writes1[] = { |
4842 MockWrite("GET /x/y/z HTTP/1.1\r\n" | 4842 MockWrite("GET /x/y/z HTTP/1.1\r\n" |
4843 "Host: www.google.com\r\n" | 4843 "Host: www.google.com\r\n" |
4844 "Connection: keep-alive\r\n\r\n"), | 4844 "Connection: keep-alive\r\n\r\n"), |
4845 }; | 4845 }; |
4846 | 4846 |
4847 MockRead data_reads1[] = { | 4847 MockRead data_reads1[] = { |
4848 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 4848 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
4849 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 4849 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4905 // Transaction 2: authenticate (foo2, bar2) on MyRealm2 | 4905 // Transaction 2: authenticate (foo2, bar2) on MyRealm2 |
4906 { | 4906 { |
4907 HttpRequestInfo request; | 4907 HttpRequestInfo request; |
4908 request.method = "GET"; | 4908 request.method = "GET"; |
4909 // Note that Transaction 1 was at /x/y/z, so this is in the same | 4909 // Note that Transaction 1 was at /x/y/z, so this is in the same |
4910 // protection space as MyRealm1. | 4910 // protection space as MyRealm1. |
4911 request.url = GURL("http://www.google.com/x/y/a/b"); | 4911 request.url = GURL("http://www.google.com/x/y/a/b"); |
4912 request.load_flags = 0; | 4912 request.load_flags = 0; |
4913 | 4913 |
4914 scoped_ptr<HttpTransaction> trans( | 4914 scoped_ptr<HttpTransaction> trans( |
4915 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4915 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4916 | 4916 |
4917 MockWrite data_writes1[] = { | 4917 MockWrite data_writes1[] = { |
4918 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" | 4918 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" |
4919 "Host: www.google.com\r\n" | 4919 "Host: www.google.com\r\n" |
4920 "Connection: keep-alive\r\n" | 4920 "Connection: keep-alive\r\n" |
4921 // Send preemptive authorization for MyRealm1 | 4921 // Send preemptive authorization for MyRealm1 |
4922 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 4922 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
4923 }; | 4923 }; |
4924 | 4924 |
4925 // The server didn't like the preemptive authorization, and | 4925 // The server didn't like the preemptive authorization, and |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4989 | 4989 |
4990 // Transaction 3: Resend a request in MyRealm's protection space -- | 4990 // Transaction 3: Resend a request in MyRealm's protection space -- |
4991 // succeed with preemptive authorization. | 4991 // succeed with preemptive authorization. |
4992 { | 4992 { |
4993 HttpRequestInfo request; | 4993 HttpRequestInfo request; |
4994 request.method = "GET"; | 4994 request.method = "GET"; |
4995 request.url = GURL("http://www.google.com/x/y/z2"); | 4995 request.url = GURL("http://www.google.com/x/y/z2"); |
4996 request.load_flags = 0; | 4996 request.load_flags = 0; |
4997 | 4997 |
4998 scoped_ptr<HttpTransaction> trans( | 4998 scoped_ptr<HttpTransaction> trans( |
4999 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 4999 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5000 | 5000 |
5001 MockWrite data_writes1[] = { | 5001 MockWrite data_writes1[] = { |
5002 MockWrite("GET /x/y/z2 HTTP/1.1\r\n" | 5002 MockWrite("GET /x/y/z2 HTTP/1.1\r\n" |
5003 "Host: www.google.com\r\n" | 5003 "Host: www.google.com\r\n" |
5004 "Connection: keep-alive\r\n" | 5004 "Connection: keep-alive\r\n" |
5005 // The authorization for MyRealm1 gets sent preemptively | 5005 // The authorization for MyRealm1 gets sent preemptively |
5006 // (since the url is in the same protection space) | 5006 // (since the url is in the same protection space) |
5007 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 5007 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
5008 }; | 5008 }; |
5009 | 5009 |
(...skipping 27 matching lines...) Expand all Loading... |
5037 | 5037 |
5038 // Transaction 4: request another URL in MyRealm (however the | 5038 // Transaction 4: request another URL in MyRealm (however the |
5039 // url is not known to belong to the protection space, so no pre-auth). | 5039 // url is not known to belong to the protection space, so no pre-auth). |
5040 { | 5040 { |
5041 HttpRequestInfo request; | 5041 HttpRequestInfo request; |
5042 request.method = "GET"; | 5042 request.method = "GET"; |
5043 request.url = GURL("http://www.google.com/x/1"); | 5043 request.url = GURL("http://www.google.com/x/1"); |
5044 request.load_flags = 0; | 5044 request.load_flags = 0; |
5045 | 5045 |
5046 scoped_ptr<HttpTransaction> trans( | 5046 scoped_ptr<HttpTransaction> trans( |
5047 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5047 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5048 | 5048 |
5049 MockWrite data_writes1[] = { | 5049 MockWrite data_writes1[] = { |
5050 MockWrite("GET /x/1 HTTP/1.1\r\n" | 5050 MockWrite("GET /x/1 HTTP/1.1\r\n" |
5051 "Host: www.google.com\r\n" | 5051 "Host: www.google.com\r\n" |
5052 "Connection: keep-alive\r\n\r\n"), | 5052 "Connection: keep-alive\r\n\r\n"), |
5053 }; | 5053 }; |
5054 | 5054 |
5055 MockRead data_reads1[] = { | 5055 MockRead data_reads1[] = { |
5056 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 5056 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
5057 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 5057 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5107 | 5107 |
5108 // Transaction 5: request a URL in MyRealm, but the server rejects the | 5108 // Transaction 5: request a URL in MyRealm, but the server rejects the |
5109 // cached identity. Should invalidate and re-prompt. | 5109 // cached identity. Should invalidate and re-prompt. |
5110 { | 5110 { |
5111 HttpRequestInfo request; | 5111 HttpRequestInfo request; |
5112 request.method = "GET"; | 5112 request.method = "GET"; |
5113 request.url = GURL("http://www.google.com/p/q/t"); | 5113 request.url = GURL("http://www.google.com/p/q/t"); |
5114 request.load_flags = 0; | 5114 request.load_flags = 0; |
5115 | 5115 |
5116 scoped_ptr<HttpTransaction> trans( | 5116 scoped_ptr<HttpTransaction> trans( |
5117 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5117 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5118 | 5118 |
5119 MockWrite data_writes1[] = { | 5119 MockWrite data_writes1[] = { |
5120 MockWrite("GET /p/q/t HTTP/1.1\r\n" | 5120 MockWrite("GET /p/q/t HTTP/1.1\r\n" |
5121 "Host: www.google.com\r\n" | 5121 "Host: www.google.com\r\n" |
5122 "Connection: keep-alive\r\n\r\n"), | 5122 "Connection: keep-alive\r\n\r\n"), |
5123 }; | 5123 }; |
5124 | 5124 |
5125 MockRead data_reads1[] = { | 5125 MockRead data_reads1[] = { |
5126 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 5126 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
5127 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 5127 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5219 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 5219 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
5220 | 5220 |
5221 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 5221 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
5222 { | 5222 { |
5223 HttpRequestInfo request; | 5223 HttpRequestInfo request; |
5224 request.method = "GET"; | 5224 request.method = "GET"; |
5225 request.url = GURL("http://www.google.com/x/y/z"); | 5225 request.url = GURL("http://www.google.com/x/y/z"); |
5226 request.load_flags = 0; | 5226 request.load_flags = 0; |
5227 | 5227 |
5228 scoped_ptr<HttpTransaction> trans( | 5228 scoped_ptr<HttpTransaction> trans( |
5229 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5229 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5230 | 5230 |
5231 MockWrite data_writes1[] = { | 5231 MockWrite data_writes1[] = { |
5232 MockWrite("GET /x/y/z HTTP/1.1\r\n" | 5232 MockWrite("GET /x/y/z HTTP/1.1\r\n" |
5233 "Host: www.google.com\r\n" | 5233 "Host: www.google.com\r\n" |
5234 "Connection: keep-alive\r\n\r\n"), | 5234 "Connection: keep-alive\r\n\r\n"), |
5235 }; | 5235 }; |
5236 | 5236 |
5237 MockRead data_reads1[] = { | 5237 MockRead data_reads1[] = { |
5238 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 5238 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
5239 MockRead("WWW-Authenticate: Digest realm=\"digestive\", nonce=\"OU812\", " | 5239 MockRead("WWW-Authenticate: Digest realm=\"digestive\", nonce=\"OU812\", " |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5298 // "nc" value of 2 (as compared to 1 in the first use. | 5298 // "nc" value of 2 (as compared to 1 in the first use. |
5299 { | 5299 { |
5300 HttpRequestInfo request; | 5300 HttpRequestInfo request; |
5301 request.method = "GET"; | 5301 request.method = "GET"; |
5302 // Note that Transaction 1 was at /x/y/z, so this is in the same | 5302 // Note that Transaction 1 was at /x/y/z, so this is in the same |
5303 // protection space as digest. | 5303 // protection space as digest. |
5304 request.url = GURL("http://www.google.com/x/y/a/b"); | 5304 request.url = GURL("http://www.google.com/x/y/a/b"); |
5305 request.load_flags = 0; | 5305 request.load_flags = 0; |
5306 | 5306 |
5307 scoped_ptr<HttpTransaction> trans( | 5307 scoped_ptr<HttpTransaction> trans( |
5308 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5308 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5309 | 5309 |
5310 MockWrite data_writes1[] = { | 5310 MockWrite data_writes1[] = { |
5311 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" | 5311 MockWrite("GET /x/y/a/b HTTP/1.1\r\n" |
5312 "Host: www.google.com\r\n" | 5312 "Host: www.google.com\r\n" |
5313 "Connection: keep-alive\r\n" | 5313 "Connection: keep-alive\r\n" |
5314 "Authorization: Digest username=\"foo\", realm=\"digestive\", " | 5314 "Authorization: Digest username=\"foo\", realm=\"digestive\", " |
5315 "nonce=\"OU812\", uri=\"/x/y/a/b\", algorithm=MD5, " | 5315 "nonce=\"OU812\", uri=\"/x/y/a/b\", algorithm=MD5, " |
5316 "response=\"d6f9a2c07d1c5df7b89379dca1269b35\", qop=auth, " | 5316 "response=\"d6f9a2c07d1c5df7b89379dca1269b35\", qop=auth, " |
5317 "nc=00000002, cnonce=\"0123456789abcdef\"\r\n\r\n"), | 5317 "nc=00000002, cnonce=\"0123456789abcdef\"\r\n\r\n"), |
5318 }; | 5318 }; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5361 response->response_time = base::Time::Now(); | 5361 response->response_time = base::Time::Now(); |
5362 response->was_cached = true; // (Wouldn't ever actually be true...) | 5362 response->was_cached = true; // (Wouldn't ever actually be true...) |
5363 | 5363 |
5364 { // Setup state for response_.vary_data | 5364 { // Setup state for response_.vary_data |
5365 HttpRequestInfo request; | 5365 HttpRequestInfo request; |
5366 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); | 5366 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); |
5367 std::replace(temp.begin(), temp.end(), '\n', '\0'); | 5367 std::replace(temp.begin(), temp.end(), '\n', '\0'); |
5368 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); | 5368 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); |
5369 request.extra_headers.SetHeader("Foo", "1"); | 5369 request.extra_headers.SetHeader("Foo", "1"); |
5370 request.extra_headers.SetHeader("bar", "23"); | 5370 request.extra_headers.SetHeader("bar", "23"); |
5371 EXPECT_TRUE(response->vary_data.Init(request, *headers)); | 5371 EXPECT_TRUE(response->vary_data.Init(request, *headers.get())); |
5372 } | 5372 } |
5373 | 5373 |
5374 // Cause the above state to be reset. | 5374 // Cause the above state to be reset. |
5375 trans->ResetStateForRestart(); | 5375 trans->ResetStateForRestart(); |
5376 | 5376 |
5377 // Verify that the state that needed to be reset, has been reset. | 5377 // Verify that the state that needed to be reset, has been reset. |
5378 EXPECT_TRUE(trans->read_buf_.get() == NULL); | 5378 EXPECT_TRUE(trans->read_buf_.get() == NULL); |
5379 EXPECT_EQ(0, trans->read_buf_len_); | 5379 EXPECT_EQ(0, trans->read_buf_len_); |
5380 EXPECT_TRUE(trans->request_headers_.IsEmpty()); | 5380 EXPECT_TRUE(trans->request_headers_.IsEmpty()); |
5381 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 5381 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5911 SSLSocketDataProvider proxy(ASYNC, OK); | 5911 SSLSocketDataProvider proxy(ASYNC, OK); |
5912 proxy.SetNextProto(kProtoSPDY2); | 5912 proxy.SetNextProto(kProtoSPDY2); |
5913 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); | 5913 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); |
5914 // Vanilla SSL to the server | 5914 // Vanilla SSL to the server |
5915 SSLSocketDataProvider server(ASYNC, OK); | 5915 SSLSocketDataProvider server(ASYNC, OK); |
5916 session_deps_.socket_factory->AddSSLSocketDataProvider(&server); | 5916 session_deps_.socket_factory->AddSSLSocketDataProvider(&server); |
5917 | 5917 |
5918 TestCompletionCallback callback1; | 5918 TestCompletionCallback callback1; |
5919 | 5919 |
5920 scoped_ptr<HttpTransaction> trans( | 5920 scoped_ptr<HttpTransaction> trans( |
5921 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 5921 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
5922 | 5922 |
5923 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 5923 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
5924 EXPECT_EQ(ERR_IO_PENDING, rv); | 5924 EXPECT_EQ(ERR_IO_PENDING, rv); |
5925 | 5925 |
5926 rv = callback1.WaitForResult(); | 5926 rv = callback1.WaitForResult(); |
5927 EXPECT_EQ(OK, rv); | 5927 EXPECT_EQ(OK, rv); |
5928 net::CapturingNetLog::CapturedEntryList entries; | 5928 net::CapturingNetLog::CapturedEntryList entries; |
5929 log.GetEntries(&entries); | 5929 log.GetEntries(&entries); |
5930 size_t pos = ExpectLogContainsSomewhere( | 5930 size_t pos = ExpectLogContainsSomewhere( |
5931 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 5931 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
5932 NetLog::PHASE_NONE); | 5932 NetLog::PHASE_NONE); |
5933 ExpectLogContainsSomewhere( | 5933 ExpectLogContainsSomewhere( |
5934 entries, pos, | 5934 entries, pos, |
5935 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 5935 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
5936 NetLog::PHASE_NONE); | 5936 NetLog::PHASE_NONE); |
5937 | 5937 |
5938 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5938 const HttpResponseInfo* response = trans->GetResponseInfo(); |
5939 ASSERT_TRUE(response != NULL); | 5939 ASSERT_TRUE(response != NULL); |
5940 ASSERT_FALSE(response->headers == NULL); | 5940 ASSERT_FALSE(response->headers.get() == NULL); |
5941 EXPECT_EQ(407, response->headers->response_code()); | 5941 EXPECT_EQ(407, response->headers->response_code()); |
5942 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 5942 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
5943 EXPECT_TRUE(response->auth_challenge.get() != NULL); | 5943 EXPECT_TRUE(response->auth_challenge.get() != NULL); |
5944 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 5944 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
5945 | 5945 |
5946 TestCompletionCallback callback2; | 5946 TestCompletionCallback callback2; |
5947 | 5947 |
5948 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), | 5948 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), |
5949 callback2.callback()); | 5949 callback2.callback()); |
5950 EXPECT_EQ(ERR_IO_PENDING, rv); | 5950 EXPECT_EQ(ERR_IO_PENDING, rv); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6032 OrderedSocketData spdy_data( | 6032 OrderedSocketData spdy_data( |
6033 spdy_reads, arraysize(spdy_reads), | 6033 spdy_reads, arraysize(spdy_reads), |
6034 spdy_writes, arraysize(spdy_writes)); | 6034 spdy_writes, arraysize(spdy_writes)); |
6035 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 6035 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
6036 // Negotiate SPDY to the proxy | 6036 // Negotiate SPDY to the proxy |
6037 SSLSocketDataProvider proxy(ASYNC, OK); | 6037 SSLSocketDataProvider proxy(ASYNC, OK); |
6038 proxy.SetNextProto(kProtoSPDY2); | 6038 proxy.SetNextProto(kProtoSPDY2); |
6039 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); | 6039 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); |
6040 | 6040 |
6041 scoped_ptr<HttpTransaction> trans( | 6041 scoped_ptr<HttpTransaction> trans( |
6042 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 6042 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
6043 TestCompletionCallback callback; | 6043 TestCompletionCallback callback; |
6044 int rv = trans->Start(&request, callback.callback(), log.bound()); | 6044 int rv = trans->Start(&request, callback.callback(), log.bound()); |
6045 EXPECT_EQ(ERR_IO_PENDING, rv); | 6045 EXPECT_EQ(ERR_IO_PENDING, rv); |
6046 | 6046 |
6047 rv = callback.WaitForResult(); | 6047 rv = callback.WaitForResult(); |
6048 EXPECT_EQ(OK, rv); | 6048 EXPECT_EQ(OK, rv); |
6049 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6049 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6050 | 6050 |
6051 scoped_ptr<HttpTransaction> push_trans( | 6051 scoped_ptr<HttpTransaction> push_trans( |
6052 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 6052 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
6053 rv = push_trans->Start(&push_request, | 6053 rv = push_trans->Start(&push_request, callback.callback(), log.bound()); |
6054 callback.callback(), log.bound()); | |
6055 EXPECT_EQ(ERR_IO_PENDING, rv); | 6054 EXPECT_EQ(ERR_IO_PENDING, rv); |
6056 | 6055 |
6057 rv = callback.WaitForResult(); | 6056 rv = callback.WaitForResult(); |
6058 EXPECT_EQ(OK, rv); | 6057 EXPECT_EQ(OK, rv); |
6059 const HttpResponseInfo* push_response = push_trans->GetResponseInfo(); | 6058 const HttpResponseInfo* push_response = push_trans->GetResponseInfo(); |
6060 | 6059 |
6061 ASSERT_TRUE(response != NULL); | 6060 ASSERT_TRUE(response != NULL); |
6062 EXPECT_TRUE(response->headers->IsKeepAlive()); | 6061 EXPECT_TRUE(response->headers->IsKeepAlive()); |
6063 | 6062 |
6064 EXPECT_EQ(200, response->headers->response_code()); | 6063 EXPECT_EQ(200, response->headers->response_code()); |
6065 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 6064 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
6066 | 6065 |
6067 std::string response_data; | 6066 std::string response_data; |
6068 rv = ReadTransaction(trans.get(), &response_data); | 6067 rv = ReadTransaction(trans.get(), &response_data); |
6069 EXPECT_EQ(OK, rv); | 6068 EXPECT_EQ(OK, rv); |
6070 EXPECT_EQ("hello!", response_data); | 6069 EXPECT_EQ("hello!", response_data); |
6071 | 6070 |
6072 LoadTimingInfo load_timing_info; | 6071 LoadTimingInfo load_timing_info; |
6073 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 6072 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
6074 TestLoadTimingNotReusedWithPac(load_timing_info, | 6073 TestLoadTimingNotReusedWithPac(load_timing_info, |
6075 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 6074 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
6076 | 6075 |
6077 // Verify the pushed stream. | 6076 // Verify the pushed stream. |
6078 EXPECT_TRUE(push_response->headers != NULL); | 6077 EXPECT_TRUE(push_response->headers.get() != NULL); |
6079 EXPECT_EQ(200, push_response->headers->response_code()); | 6078 EXPECT_EQ(200, push_response->headers->response_code()); |
6080 | 6079 |
6081 rv = ReadTransaction(push_trans.get(), &response_data); | 6080 rv = ReadTransaction(push_trans.get(), &response_data); |
6082 EXPECT_EQ(OK, rv); | 6081 EXPECT_EQ(OK, rv); |
6083 EXPECT_EQ("pushed", response_data); | 6082 EXPECT_EQ("pushed", response_data); |
6084 | 6083 |
6085 LoadTimingInfo push_load_timing_info; | 6084 LoadTimingInfo push_load_timing_info; |
6086 EXPECT_TRUE(push_trans->GetLoadTimingInfo(&push_load_timing_info)); | 6085 EXPECT_TRUE(push_trans->GetLoadTimingInfo(&push_load_timing_info)); |
6087 TestLoadTimingReusedWithPac(push_load_timing_info); | 6086 TestLoadTimingReusedWithPac(push_load_timing_info); |
6088 // The transactions should share a socket ID, despite being for different | 6087 // The transactions should share a socket ID, despite being for different |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6147 OrderedSocketData spdy_data( | 6146 OrderedSocketData spdy_data( |
6148 spdy_reads, arraysize(spdy_reads), | 6147 spdy_reads, arraysize(spdy_reads), |
6149 spdy_writes, arraysize(spdy_writes)); | 6148 spdy_writes, arraysize(spdy_writes)); |
6150 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 6149 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
6151 // Negotiate SPDY to the proxy | 6150 // Negotiate SPDY to the proxy |
6152 SSLSocketDataProvider proxy(ASYNC, OK); | 6151 SSLSocketDataProvider proxy(ASYNC, OK); |
6153 proxy.SetNextProto(kProtoSPDY2); | 6152 proxy.SetNextProto(kProtoSPDY2); |
6154 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); | 6153 session_deps_.socket_factory->AddSSLSocketDataProvider(&proxy); |
6155 | 6154 |
6156 scoped_ptr<HttpTransaction> trans( | 6155 scoped_ptr<HttpTransaction> trans( |
6157 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 6156 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
6158 TestCompletionCallback callback; | 6157 TestCompletionCallback callback; |
6159 int rv = trans->Start(&request, callback.callback(), log.bound()); | 6158 int rv = trans->Start(&request, callback.callback(), log.bound()); |
6160 EXPECT_EQ(ERR_IO_PENDING, rv); | 6159 EXPECT_EQ(ERR_IO_PENDING, rv); |
6161 | 6160 |
6162 rv = callback.WaitForResult(); | 6161 rv = callback.WaitForResult(); |
6163 EXPECT_EQ(OK, rv); | 6162 EXPECT_EQ(OK, rv); |
6164 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6163 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6165 | 6164 |
6166 ASSERT_TRUE(response != NULL); | 6165 ASSERT_TRUE(response != NULL); |
6167 EXPECT_TRUE(response->headers->IsKeepAlive()); | 6166 EXPECT_TRUE(response->headers->IsKeepAlive()); |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7007 | 7006 |
7008 int GroupNameTransactionHelper( | 7007 int GroupNameTransactionHelper( |
7009 const std::string& url, | 7008 const std::string& url, |
7010 const scoped_refptr<HttpNetworkSession>& session) { | 7009 const scoped_refptr<HttpNetworkSession>& session) { |
7011 HttpRequestInfo request; | 7010 HttpRequestInfo request; |
7012 request.method = "GET"; | 7011 request.method = "GET"; |
7013 request.url = GURL(url); | 7012 request.url = GURL(url); |
7014 request.load_flags = 0; | 7013 request.load_flags = 0; |
7015 | 7014 |
7016 scoped_ptr<HttpTransaction> trans( | 7015 scoped_ptr<HttpTransaction> trans( |
7017 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7016 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7018 | 7017 |
7019 TestCompletionCallback callback; | 7018 TestCompletionCallback callback; |
7020 | 7019 |
7021 // We do not complete this request, the dtor will clean the transaction up. | 7020 // We do not complete this request, the dtor will clean the transaction up. |
7022 return trans->Start(&request, callback.callback(), BoundNetLog()); | 7021 return trans->Start(&request, callback.callback(), BoundNetLog()); |
7023 } | 7022 } |
7024 | 7023 |
7025 } // namespace | 7024 } // namespace |
7026 | 7025 |
7027 TEST_F(HttpNetworkTransactionSpdy2Test, GroupNameForDirectConnections) { | 7026 TEST_F(HttpNetworkTransactionSpdy2Test, GroupNameForDirectConnections) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7209 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 7208 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
7210 new CaptureGroupNameSSLSocketPool(NULL, NULL); | 7209 new CaptureGroupNameSSLSocketPool(NULL, NULL); |
7211 | 7210 |
7212 MockClientSocketPoolManager* mock_pool_manager = | 7211 MockClientSocketPoolManager* mock_pool_manager = |
7213 new MockClientSocketPoolManager; | 7212 new MockClientSocketPoolManager; |
7214 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool); | 7213 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool); |
7215 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); | 7214 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); |
7216 peer.SetClientSocketPoolManager(mock_pool_manager); | 7215 peer.SetClientSocketPoolManager(mock_pool_manager); |
7217 | 7216 |
7218 scoped_ptr<HttpTransaction> trans( | 7217 scoped_ptr<HttpTransaction> trans( |
7219 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7218 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7220 | 7219 |
7221 EXPECT_EQ(ERR_IO_PENDING, | 7220 EXPECT_EQ(ERR_IO_PENDING, |
7222 GroupNameTransactionHelper(tests[i].url, session)); | 7221 GroupNameTransactionHelper(tests[i].url, session)); |
7223 if (tests[i].ssl) | 7222 if (tests[i].ssl) |
7224 EXPECT_EQ(tests[i].expected_group_name, | 7223 EXPECT_EQ(tests[i].expected_group_name, |
7225 ssl_conn_pool->last_group_name_received()); | 7224 ssl_conn_pool->last_group_name_received()); |
7226 else | 7225 else |
7227 EXPECT_EQ(tests[i].expected_group_name, | 7226 EXPECT_EQ(tests[i].expected_group_name, |
7228 socks_conn_pool->last_group_name_received()); | 7227 socks_conn_pool->last_group_name_received()); |
7229 } | 7228 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7376 | 7375 |
7377 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7376 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7378 EXPECT_EQ(ERR_IO_PENDING, rv); | 7377 EXPECT_EQ(ERR_IO_PENDING, rv); |
7379 | 7378 |
7380 rv = callback.WaitForResult(); | 7379 rv = callback.WaitForResult(); |
7381 EXPECT_EQ(OK, rv); | 7380 EXPECT_EQ(OK, rv); |
7382 | 7381 |
7383 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7382 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7384 ASSERT_TRUE(response != NULL); | 7383 ASSERT_TRUE(response != NULL); |
7385 | 7384 |
7386 EXPECT_TRUE(response->headers != NULL); | 7385 EXPECT_TRUE(response->headers.get() != NULL); |
7387 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7386 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7388 | 7387 |
7389 std::string response_data; | 7388 std::string response_data; |
7390 rv = ReadTransaction(trans.get(), &response_data); | 7389 rv = ReadTransaction(trans.get(), &response_data); |
7391 EXPECT_EQ(OK, rv); | 7390 EXPECT_EQ(OK, rv); |
7392 EXPECT_EQ("", response_data); | 7391 EXPECT_EQ("", response_data); |
7393 } | 7392 } |
7394 | 7393 |
7395 // Make sure that a dropped connection while draining the body for auth | 7394 // Make sure that a dropped connection while draining the body for auth |
7396 // restart does the right thing. | 7395 // restart does the right thing. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7438 MockRead(SYNCHRONOUS, OK), | 7437 MockRead(SYNCHRONOUS, OK), |
7439 }; | 7438 }; |
7440 | 7439 |
7441 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 7440 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
7442 data_writes2, arraysize(data_writes2)); | 7441 data_writes2, arraysize(data_writes2)); |
7443 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 7442 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
7444 | 7443 |
7445 TestCompletionCallback callback1; | 7444 TestCompletionCallback callback1; |
7446 | 7445 |
7447 scoped_ptr<HttpTransaction> trans( | 7446 scoped_ptr<HttpTransaction> trans( |
7448 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7447 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7449 | 7448 |
7450 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 7449 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
7451 EXPECT_EQ(ERR_IO_PENDING, rv); | 7450 EXPECT_EQ(ERR_IO_PENDING, rv); |
7452 | 7451 |
7453 rv = callback1.WaitForResult(); | 7452 rv = callback1.WaitForResult(); |
7454 EXPECT_EQ(OK, rv); | 7453 EXPECT_EQ(OK, rv); |
7455 | 7454 |
7456 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7455 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7457 ASSERT_TRUE(response != NULL); | 7456 ASSERT_TRUE(response != NULL); |
7458 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 7457 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7528 TestCompletionCallback callback; | 7527 TestCompletionCallback callback; |
7529 | 7528 |
7530 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7529 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7531 EXPECT_EQ(ERR_IO_PENDING, rv); | 7530 EXPECT_EQ(ERR_IO_PENDING, rv); |
7532 | 7531 |
7533 EXPECT_EQ(OK, callback.WaitForResult()); | 7532 EXPECT_EQ(OK, callback.WaitForResult()); |
7534 | 7533 |
7535 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7534 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7536 ASSERT_TRUE(response != NULL); | 7535 ASSERT_TRUE(response != NULL); |
7537 | 7536 |
7538 EXPECT_TRUE(response->headers != NULL); | 7537 EXPECT_TRUE(response->headers.get() != NULL); |
7539 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7538 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7540 | 7539 |
7541 std::string response_data; | 7540 std::string response_data; |
7542 rv = ReadTransaction(trans.get(), &response_data); | 7541 rv = ReadTransaction(trans.get(), &response_data); |
7543 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 7542 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
7544 } | 7543 } |
7545 | 7544 |
7546 TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) { | 7545 TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) { |
7547 base::FilePath temp_file_path; | 7546 base::FilePath temp_file_path; |
7548 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 7547 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
(...skipping 29 matching lines...) Expand all Loading... |
7578 | 7577 |
7579 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7578 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7580 EXPECT_EQ(ERR_IO_PENDING, rv); | 7579 EXPECT_EQ(ERR_IO_PENDING, rv); |
7581 | 7580 |
7582 rv = callback.WaitForResult(); | 7581 rv = callback.WaitForResult(); |
7583 EXPECT_EQ(OK, rv); | 7582 EXPECT_EQ(OK, rv); |
7584 | 7583 |
7585 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7584 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7586 ASSERT_TRUE(response != NULL); | 7585 ASSERT_TRUE(response != NULL); |
7587 | 7586 |
7588 EXPECT_TRUE(response->headers != NULL); | 7587 EXPECT_TRUE(response->headers.get() != NULL); |
7589 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7588 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7590 | 7589 |
7591 std::string response_data; | 7590 std::string response_data; |
7592 rv = ReadTransaction(trans.get(), &response_data); | 7591 rv = ReadTransaction(trans.get(), &response_data); |
7593 EXPECT_EQ(OK, rv); | 7592 EXPECT_EQ(OK, rv); |
7594 EXPECT_EQ("hello world", response_data); | 7593 EXPECT_EQ("hello world", response_data); |
7595 | 7594 |
7596 file_util::Delete(temp_file_path, false); | 7595 file_util::Delete(temp_file_path, false); |
7597 } | 7596 } |
7598 | 7597 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7640 TestCompletionCallback callback; | 7639 TestCompletionCallback callback; |
7641 | 7640 |
7642 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7641 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7643 EXPECT_EQ(ERR_IO_PENDING, rv); | 7642 EXPECT_EQ(ERR_IO_PENDING, rv); |
7644 | 7643 |
7645 rv = callback.WaitForResult(); | 7644 rv = callback.WaitForResult(); |
7646 EXPECT_EQ(OK, rv); | 7645 EXPECT_EQ(OK, rv); |
7647 | 7646 |
7648 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7647 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7649 ASSERT_TRUE(response != NULL); | 7648 ASSERT_TRUE(response != NULL); |
7650 EXPECT_TRUE(response->headers != NULL); | 7649 EXPECT_TRUE(response->headers.get() != NULL); |
7651 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7650 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7652 | 7651 |
7653 file_util::Delete(temp_file, false); | 7652 file_util::Delete(temp_file, false); |
7654 } | 7653 } |
7655 | 7654 |
7656 TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) { | 7655 TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) { |
7657 base::FilePath temp_file; | 7656 base::FilePath temp_file; |
7658 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7657 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
7659 std::string temp_file_contents("Unreadable file."); | 7658 std::string temp_file_contents("Unreadable file."); |
7660 std::string unreadable_contents(temp_file_contents.length(), '\0'); | 7659 std::string unreadable_contents(temp_file_contents.length(), '\0'); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7709 TestCompletionCallback callback1; | 7708 TestCompletionCallback callback1; |
7710 | 7709 |
7711 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 7710 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
7712 EXPECT_EQ(ERR_IO_PENDING, rv); | 7711 EXPECT_EQ(ERR_IO_PENDING, rv); |
7713 | 7712 |
7714 rv = callback1.WaitForResult(); | 7713 rv = callback1.WaitForResult(); |
7715 EXPECT_EQ(OK, rv); | 7714 EXPECT_EQ(OK, rv); |
7716 | 7715 |
7717 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7716 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7718 ASSERT_TRUE(response != NULL); | 7717 ASSERT_TRUE(response != NULL); |
7719 ASSERT_TRUE(response->headers != NULL); | 7718 ASSERT_TRUE(response->headers.get() != NULL); |
7720 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); | 7719 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); |
7721 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 7720 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
7722 | 7721 |
7723 // Now make the file unreadable and try again. | 7722 // Now make the file unreadable and try again. |
7724 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 7723 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
7725 | 7724 |
7726 TestCompletionCallback callback2; | 7725 TestCompletionCallback callback2; |
7727 | 7726 |
7728 rv = trans->RestartWithAuth( | 7727 rv = trans->RestartWithAuth( |
7729 AuthCredentials(kFoo, kBar), callback2.callback()); | 7728 AuthCredentials(kFoo, kBar), callback2.callback()); |
7730 EXPECT_EQ(ERR_IO_PENDING, rv); | 7729 EXPECT_EQ(ERR_IO_PENDING, rv); |
7731 | 7730 |
7732 rv = callback2.WaitForResult(); | 7731 rv = callback2.WaitForResult(); |
7733 EXPECT_EQ(OK, rv); | 7732 EXPECT_EQ(OK, rv); |
7734 | 7733 |
7735 response = trans->GetResponseInfo(); | 7734 response = trans->GetResponseInfo(); |
7736 ASSERT_TRUE(response != NULL); | 7735 ASSERT_TRUE(response != NULL); |
7737 EXPECT_TRUE(response->headers != NULL); | 7736 EXPECT_TRUE(response->headers.get() != NULL); |
7738 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7737 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
7739 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7738 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7740 | 7739 |
7741 file_util::Delete(temp_file, false); | 7740 file_util::Delete(temp_file, false); |
7742 } | 7741 } |
7743 | 7742 |
7744 // Tests that changes to Auth realms are treated like auth rejections. | 7743 // Tests that changes to Auth realms are treated like auth rejections. |
7745 TEST_F(HttpNetworkTransactionSpdy2Test, ChangeAuthRealms) { | 7744 TEST_F(HttpNetworkTransactionSpdy2Test, ChangeAuthRealms) { |
7746 | 7745 |
7747 HttpRequestInfo request; | 7746 HttpRequestInfo request; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7911 request.load_flags = 0; | 7910 request.load_flags = 0; |
7912 | 7911 |
7913 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 7912 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
7914 | 7913 |
7915 session_deps_.socket_factory->AddSocketDataProvider(&data); | 7914 session_deps_.socket_factory->AddSocketDataProvider(&data); |
7916 | 7915 |
7917 TestCompletionCallback callback; | 7916 TestCompletionCallback callback; |
7918 | 7917 |
7919 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 7918 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
7920 scoped_ptr<HttpTransaction> trans( | 7919 scoped_ptr<HttpTransaction> trans( |
7921 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7920 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7922 | 7921 |
7923 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7922 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7924 EXPECT_EQ(ERR_IO_PENDING, rv); | 7923 EXPECT_EQ(ERR_IO_PENDING, rv); |
7925 | 7924 |
7926 HostPortPair http_host_port_pair("www.google.com", 80); | 7925 HostPortPair http_host_port_pair("www.google.com", 80); |
7927 const HttpServerProperties& http_server_properties = | 7926 const HttpServerProperties& http_server_properties = |
7928 *session->http_server_properties(); | 7927 *session->http_server_properties(); |
7929 EXPECT_FALSE( | 7928 EXPECT_FALSE( |
7930 http_server_properties.HasAlternateProtocol(http_host_port_pair)); | 7929 http_server_properties.HasAlternateProtocol(http_host_port_pair)); |
7931 | 7930 |
7932 EXPECT_EQ(OK, callback.WaitForResult()); | 7931 EXPECT_EQ(OK, callback.WaitForResult()); |
7933 | 7932 |
7934 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7933 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7935 ASSERT_TRUE(response != NULL); | 7934 ASSERT_TRUE(response != NULL); |
7936 ASSERT_TRUE(response->headers != NULL); | 7935 ASSERT_TRUE(response->headers.get() != NULL); |
7937 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7936 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7938 EXPECT_FALSE(response->was_fetched_via_spdy); | 7937 EXPECT_FALSE(response->was_fetched_via_spdy); |
7939 EXPECT_FALSE(response->was_npn_negotiated); | 7938 EXPECT_FALSE(response->was_npn_negotiated); |
7940 | 7939 |
7941 std::string response_data; | 7940 std::string response_data; |
7942 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7941 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
7943 EXPECT_EQ("hello world", response_data); | 7942 EXPECT_EQ("hello world", response_data); |
7944 | 7943 |
7945 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); | 7944 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); |
7946 const PortAlternateProtocolPair alternate = | 7945 const PortAlternateProtocolPair alternate = |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7981 HttpServerProperties* http_server_properties = | 7980 HttpServerProperties* http_server_properties = |
7982 session->http_server_properties(); | 7981 session->http_server_properties(); |
7983 // Port must be < 1024, or the header will be ignored (since initial port was | 7982 // Port must be < 1024, or the header will be ignored (since initial port was |
7984 // port 80 (another restricted port). | 7983 // port 80 (another restricted port). |
7985 http_server_properties->SetAlternateProtocol( | 7984 http_server_properties->SetAlternateProtocol( |
7986 HostPortPair::FromURL(request.url), | 7985 HostPortPair::FromURL(request.url), |
7987 666 /* port is ignored by MockConnect anyway */, | 7986 666 /* port is ignored by MockConnect anyway */, |
7988 NPN_SPDY_2); | 7987 NPN_SPDY_2); |
7989 | 7988 |
7990 scoped_ptr<HttpTransaction> trans( | 7989 scoped_ptr<HttpTransaction> trans( |
7991 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 7990 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
7992 TestCompletionCallback callback; | 7991 TestCompletionCallback callback; |
7993 | 7992 |
7994 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7993 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7995 EXPECT_EQ(ERR_IO_PENDING, rv); | 7994 EXPECT_EQ(ERR_IO_PENDING, rv); |
7996 EXPECT_EQ(OK, callback.WaitForResult()); | 7995 EXPECT_EQ(OK, callback.WaitForResult()); |
7997 | 7996 |
7998 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7997 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7999 ASSERT_TRUE(response != NULL); | 7998 ASSERT_TRUE(response != NULL); |
8000 ASSERT_TRUE(response->headers != NULL); | 7999 ASSERT_TRUE(response->headers.get() != NULL); |
8001 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8000 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8002 | 8001 |
8003 std::string response_data; | 8002 std::string response_data; |
8004 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8003 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8005 EXPECT_EQ("hello world", response_data); | 8004 EXPECT_EQ("hello world", response_data); |
8006 | 8005 |
8007 ASSERT_TRUE(http_server_properties->HasAlternateProtocol( | 8006 ASSERT_TRUE(http_server_properties->HasAlternateProtocol( |
8008 HostPortPair::FromURL(request.url))); | 8007 HostPortPair::FromURL(request.url))); |
8009 const PortAlternateProtocolPair alternate = | 8008 const PortAlternateProtocolPair alternate = |
8010 http_server_properties->GetAlternateProtocol( | 8009 http_server_properties->GetAlternateProtocol( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8043 | 8042 |
8044 HttpServerProperties* http_server_properties = | 8043 HttpServerProperties* http_server_properties = |
8045 session->http_server_properties(); | 8044 session->http_server_properties(); |
8046 const int kUnrestrictedAlternatePort = 1024; | 8045 const int kUnrestrictedAlternatePort = 1024; |
8047 http_server_properties->SetAlternateProtocol( | 8046 http_server_properties->SetAlternateProtocol( |
8048 HostPortPair::FromURL(restricted_port_request.url), | 8047 HostPortPair::FromURL(restricted_port_request.url), |
8049 kUnrestrictedAlternatePort, | 8048 kUnrestrictedAlternatePort, |
8050 NPN_SPDY_2); | 8049 NPN_SPDY_2); |
8051 | 8050 |
8052 scoped_ptr<HttpTransaction> trans( | 8051 scoped_ptr<HttpTransaction> trans( |
8053 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8052 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8054 TestCompletionCallback callback; | 8053 TestCompletionCallback callback; |
8055 | 8054 |
8056 int rv = trans->Start( | 8055 int rv = trans->Start( |
8057 &restricted_port_request, | 8056 &restricted_port_request, |
8058 callback.callback(), BoundNetLog()); | 8057 callback.callback(), BoundNetLog()); |
8059 EXPECT_EQ(ERR_IO_PENDING, rv); | 8058 EXPECT_EQ(ERR_IO_PENDING, rv); |
8060 // Invalid change to unrestricted port should fail. | 8059 // Invalid change to unrestricted port should fail. |
8061 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); | 8060 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); |
8062 } | 8061 } |
8063 | 8062 |
(...skipping 30 matching lines...) Expand all Loading... |
8094 | 8093 |
8095 HttpServerProperties* http_server_properties = | 8094 HttpServerProperties* http_server_properties = |
8096 session->http_server_properties(); | 8095 session->http_server_properties(); |
8097 const int kUnrestrictedAlternatePort = 1024; | 8096 const int kUnrestrictedAlternatePort = 1024; |
8098 http_server_properties->SetAlternateProtocol( | 8097 http_server_properties->SetAlternateProtocol( |
8099 HostPortPair::FromURL(restricted_port_request.url), | 8098 HostPortPair::FromURL(restricted_port_request.url), |
8100 kUnrestrictedAlternatePort, | 8099 kUnrestrictedAlternatePort, |
8101 NPN_SPDY_3); | 8100 NPN_SPDY_3); |
8102 | 8101 |
8103 scoped_ptr<HttpTransaction> trans( | 8102 scoped_ptr<HttpTransaction> trans( |
8104 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8103 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8105 TestCompletionCallback callback; | 8104 TestCompletionCallback callback; |
8106 | 8105 |
8107 EXPECT_EQ(ERR_IO_PENDING, trans->Start( | 8106 EXPECT_EQ(ERR_IO_PENDING, trans->Start( |
8108 &restricted_port_request, | 8107 &restricted_port_request, |
8109 callback.callback(), BoundNetLog())); | 8108 callback.callback(), BoundNetLog())); |
8110 // Change to unrestricted port should succeed. | 8109 // Change to unrestricted port should succeed. |
8111 EXPECT_EQ(OK, callback.WaitForResult()); | 8110 EXPECT_EQ(OK, callback.WaitForResult()); |
8112 } | 8111 } |
8113 | 8112 |
8114 TEST_F(HttpNetworkTransactionSpdy2Test, | 8113 TEST_F(HttpNetworkTransactionSpdy2Test, |
(...skipping 27 matching lines...) Expand all Loading... |
8142 | 8141 |
8143 HttpServerProperties* http_server_properties = | 8142 HttpServerProperties* http_server_properties = |
8144 session->http_server_properties(); | 8143 session->http_server_properties(); |
8145 const int kRestrictedAlternatePort = 80; | 8144 const int kRestrictedAlternatePort = 80; |
8146 http_server_properties->SetAlternateProtocol( | 8145 http_server_properties->SetAlternateProtocol( |
8147 HostPortPair::FromURL(restricted_port_request.url), | 8146 HostPortPair::FromURL(restricted_port_request.url), |
8148 kRestrictedAlternatePort, | 8147 kRestrictedAlternatePort, |
8149 NPN_SPDY_2); | 8148 NPN_SPDY_2); |
8150 | 8149 |
8151 scoped_ptr<HttpTransaction> trans( | 8150 scoped_ptr<HttpTransaction> trans( |
8152 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8151 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8153 TestCompletionCallback callback; | 8152 TestCompletionCallback callback; |
8154 | 8153 |
8155 int rv = trans->Start( | 8154 int rv = trans->Start( |
8156 &restricted_port_request, | 8155 &restricted_port_request, |
8157 callback.callback(), BoundNetLog()); | 8156 callback.callback(), BoundNetLog()); |
8158 EXPECT_EQ(ERR_IO_PENDING, rv); | 8157 EXPECT_EQ(ERR_IO_PENDING, rv); |
8159 // Valid change to restricted port should pass. | 8158 // Valid change to restricted port should pass. |
8160 EXPECT_EQ(OK, callback.WaitForResult()); | 8159 EXPECT_EQ(OK, callback.WaitForResult()); |
8161 } | 8160 } |
8162 | 8161 |
(...skipping 28 matching lines...) Expand all Loading... |
8191 | 8190 |
8192 HttpServerProperties* http_server_properties = | 8191 HttpServerProperties* http_server_properties = |
8193 session->http_server_properties(); | 8192 session->http_server_properties(); |
8194 const int kRestrictedAlternatePort = 80; | 8193 const int kRestrictedAlternatePort = 80; |
8195 http_server_properties->SetAlternateProtocol( | 8194 http_server_properties->SetAlternateProtocol( |
8196 HostPortPair::FromURL(unrestricted_port_request.url), | 8195 HostPortPair::FromURL(unrestricted_port_request.url), |
8197 kRestrictedAlternatePort, | 8196 kRestrictedAlternatePort, |
8198 NPN_SPDY_2); | 8197 NPN_SPDY_2); |
8199 | 8198 |
8200 scoped_ptr<HttpTransaction> trans( | 8199 scoped_ptr<HttpTransaction> trans( |
8201 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8200 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8202 TestCompletionCallback callback; | 8201 TestCompletionCallback callback; |
8203 | 8202 |
8204 int rv = trans->Start( | 8203 int rv = trans->Start( |
8205 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 8204 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
8206 EXPECT_EQ(ERR_IO_PENDING, rv); | 8205 EXPECT_EQ(ERR_IO_PENDING, rv); |
8207 // Valid change to restricted port should pass. | 8206 // Valid change to restricted port should pass. |
8208 EXPECT_EQ(OK, callback.WaitForResult()); | 8207 EXPECT_EQ(OK, callback.WaitForResult()); |
8209 } | 8208 } |
8210 | 8209 |
8211 TEST_F(HttpNetworkTransactionSpdy2Test, | 8210 TEST_F(HttpNetworkTransactionSpdy2Test, |
(...skipping 27 matching lines...) Expand all Loading... |
8239 | 8238 |
8240 HttpServerProperties* http_server_properties = | 8239 HttpServerProperties* http_server_properties = |
8241 session->http_server_properties(); | 8240 session->http_server_properties(); |
8242 const int kUnrestrictedAlternatePort = 1024; | 8241 const int kUnrestrictedAlternatePort = 1024; |
8243 http_server_properties->SetAlternateProtocol( | 8242 http_server_properties->SetAlternateProtocol( |
8244 HostPortPair::FromURL(unrestricted_port_request.url), | 8243 HostPortPair::FromURL(unrestricted_port_request.url), |
8245 kUnrestrictedAlternatePort, | 8244 kUnrestrictedAlternatePort, |
8246 NPN_SPDY_2); | 8245 NPN_SPDY_2); |
8247 | 8246 |
8248 scoped_ptr<HttpTransaction> trans( | 8247 scoped_ptr<HttpTransaction> trans( |
8249 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8248 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8250 TestCompletionCallback callback; | 8249 TestCompletionCallback callback; |
8251 | 8250 |
8252 int rv = trans->Start( | 8251 int rv = trans->Start( |
8253 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 8252 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
8254 EXPECT_EQ(ERR_IO_PENDING, rv); | 8253 EXPECT_EQ(ERR_IO_PENDING, rv); |
8255 // Valid change to an unrestricted port should pass. | 8254 // Valid change to an unrestricted port should pass. |
8256 EXPECT_EQ(OK, callback.WaitForResult()); | 8255 EXPECT_EQ(OK, callback.WaitForResult()); |
8257 } | 8256 } |
8258 | 8257 |
8259 TEST_F(HttpNetworkTransactionSpdy2Test, | 8258 TEST_F(HttpNetworkTransactionSpdy2Test, |
(...skipping 23 matching lines...) Expand all Loading... |
8283 | 8282 |
8284 HttpServerProperties* http_server_properties = | 8283 HttpServerProperties* http_server_properties = |
8285 session->http_server_properties(); | 8284 session->http_server_properties(); |
8286 const int kUnsafePort = 7; | 8285 const int kUnsafePort = 7; |
8287 http_server_properties->SetAlternateProtocol( | 8286 http_server_properties->SetAlternateProtocol( |
8288 HostPortPair::FromURL(request.url), | 8287 HostPortPair::FromURL(request.url), |
8289 kUnsafePort, | 8288 kUnsafePort, |
8290 NPN_SPDY_2); | 8289 NPN_SPDY_2); |
8291 | 8290 |
8292 scoped_ptr<HttpTransaction> trans( | 8291 scoped_ptr<HttpTransaction> trans( |
8293 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8292 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8294 TestCompletionCallback callback; | 8293 TestCompletionCallback callback; |
8295 | 8294 |
8296 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8295 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8297 EXPECT_EQ(ERR_IO_PENDING, rv); | 8296 EXPECT_EQ(ERR_IO_PENDING, rv); |
8298 // The HTTP request should succeed. | 8297 // The HTTP request should succeed. |
8299 EXPECT_EQ(OK, callback.WaitForResult()); | 8298 EXPECT_EQ(OK, callback.WaitForResult()); |
8300 | 8299 |
8301 // Disable alternate protocol before the asserts. | 8300 // Disable alternate protocol before the asserts. |
8302 HttpStreamFactory::set_use_alternate_protocols(false); | 8301 HttpStreamFactory::set_use_alternate_protocols(false); |
8303 | 8302 |
8304 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8303 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8305 ASSERT_TRUE(response != NULL); | 8304 ASSERT_TRUE(response != NULL); |
8306 ASSERT_TRUE(response->headers != NULL); | 8305 ASSERT_TRUE(response->headers.get() != NULL); |
8307 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8306 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8308 | 8307 |
8309 std::string response_data; | 8308 std::string response_data; |
8310 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8309 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8311 EXPECT_EQ("hello world", response_data); | 8310 EXPECT_EQ("hello world", response_data); |
8312 } | 8311 } |
8313 | 8312 |
8314 TEST_F(HttpNetworkTransactionSpdy2Test, UseAlternateProtocolForNpnSpdy) { | 8313 TEST_F(HttpNetworkTransactionSpdy2Test, UseAlternateProtocolForNpnSpdy) { |
8315 HttpStreamFactory::set_use_alternate_protocols(true); | 8314 HttpStreamFactory::set_use_alternate_protocols(true); |
8316 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 8315 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8359 NULL, 0, NULL, 0); | 8358 NULL, 0, NULL, 0); |
8360 hanging_non_alternate_protocol_socket.set_connect_data( | 8359 hanging_non_alternate_protocol_socket.set_connect_data( |
8361 never_finishing_connect); | 8360 never_finishing_connect); |
8362 session_deps_.socket_factory->AddSocketDataProvider( | 8361 session_deps_.socket_factory->AddSocketDataProvider( |
8363 &hanging_non_alternate_protocol_socket); | 8362 &hanging_non_alternate_protocol_socket); |
8364 | 8363 |
8365 TestCompletionCallback callback; | 8364 TestCompletionCallback callback; |
8366 | 8365 |
8367 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8366 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8368 scoped_ptr<HttpTransaction> trans( | 8367 scoped_ptr<HttpTransaction> trans( |
8369 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8368 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8370 | 8369 |
8371 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8370 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8372 EXPECT_EQ(ERR_IO_PENDING, rv); | 8371 EXPECT_EQ(ERR_IO_PENDING, rv); |
8373 EXPECT_EQ(OK, callback.WaitForResult()); | 8372 EXPECT_EQ(OK, callback.WaitForResult()); |
8374 | 8373 |
8375 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8374 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8376 ASSERT_TRUE(response != NULL); | 8375 ASSERT_TRUE(response != NULL); |
8377 ASSERT_TRUE(response->headers != NULL); | 8376 ASSERT_TRUE(response->headers.get() != NULL); |
8378 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8377 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8379 | 8378 |
8380 std::string response_data; | 8379 std::string response_data; |
8381 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8380 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8382 EXPECT_EQ("hello world", response_data); | 8381 EXPECT_EQ("hello world", response_data); |
8383 | 8382 |
8384 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8383 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8385 | 8384 |
8386 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8385 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8387 EXPECT_EQ(ERR_IO_PENDING, rv); | 8386 EXPECT_EQ(ERR_IO_PENDING, rv); |
8388 EXPECT_EQ(OK, callback.WaitForResult()); | 8387 EXPECT_EQ(OK, callback.WaitForResult()); |
8389 | 8388 |
8390 response = trans->GetResponseInfo(); | 8389 response = trans->GetResponseInfo(); |
8391 ASSERT_TRUE(response != NULL); | 8390 ASSERT_TRUE(response != NULL); |
8392 ASSERT_TRUE(response->headers != NULL); | 8391 ASSERT_TRUE(response->headers.get() != NULL); |
8393 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8392 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8394 EXPECT_TRUE(response->was_fetched_via_spdy); | 8393 EXPECT_TRUE(response->was_fetched_via_spdy); |
8395 EXPECT_TRUE(response->was_npn_negotiated); | 8394 EXPECT_TRUE(response->was_npn_negotiated); |
8396 | 8395 |
8397 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8396 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8398 EXPECT_EQ("hello!", response_data); | 8397 EXPECT_EQ("hello!", response_data); |
8399 } | 8398 } |
8400 | 8399 |
8401 TEST_F(HttpNetworkTransactionSpdy2Test, AlternateProtocolWithSpdyLateBinding) { | 8400 TEST_F(HttpNetworkTransactionSpdy2Test, AlternateProtocolWithSpdyLateBinding) { |
8402 HttpStreamFactory::set_use_alternate_protocols(true); | 8401 HttpStreamFactory::set_use_alternate_protocols(true); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8458 spdy_reads, arraysize(spdy_reads), | 8457 spdy_reads, arraysize(spdy_reads), |
8459 spdy_writes, arraysize(spdy_writes)); | 8458 spdy_writes, arraysize(spdy_writes)); |
8460 // Socket 4 is the successful Alternate-Protocol for transaction 3. | 8459 // Socket 4 is the successful Alternate-Protocol for transaction 3. |
8461 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 8460 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
8462 | 8461 |
8463 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. | 8462 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. |
8464 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket); | 8463 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket); |
8465 | 8464 |
8466 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8465 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8467 TestCompletionCallback callback1; | 8466 TestCompletionCallback callback1; |
8468 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 8467 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
8469 | 8468 |
8470 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); | 8469 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); |
8471 EXPECT_EQ(ERR_IO_PENDING, rv); | 8470 EXPECT_EQ(ERR_IO_PENDING, rv); |
8472 EXPECT_EQ(OK, callback1.WaitForResult()); | 8471 EXPECT_EQ(OK, callback1.WaitForResult()); |
8473 | 8472 |
8474 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 8473 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
8475 ASSERT_TRUE(response != NULL); | 8474 ASSERT_TRUE(response != NULL); |
8476 ASSERT_TRUE(response->headers != NULL); | 8475 ASSERT_TRUE(response->headers.get() != NULL); |
8477 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8476 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8478 | 8477 |
8479 std::string response_data; | 8478 std::string response_data; |
8480 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 8479 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
8481 EXPECT_EQ("hello world", response_data); | 8480 EXPECT_EQ("hello world", response_data); |
8482 | 8481 |
8483 TestCompletionCallback callback2; | 8482 TestCompletionCallback callback2; |
8484 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 8483 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
8485 rv = trans2.Start(&request, callback2.callback(), BoundNetLog()); | 8484 rv = trans2.Start(&request, callback2.callback(), BoundNetLog()); |
8486 EXPECT_EQ(ERR_IO_PENDING, rv); | 8485 EXPECT_EQ(ERR_IO_PENDING, rv); |
8487 | 8486 |
8488 TestCompletionCallback callback3; | 8487 TestCompletionCallback callback3; |
8489 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, session); | 8488 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, session.get()); |
8490 rv = trans3.Start(&request, callback3.callback(), BoundNetLog()); | 8489 rv = trans3.Start(&request, callback3.callback(), BoundNetLog()); |
8491 EXPECT_EQ(ERR_IO_PENDING, rv); | 8490 EXPECT_EQ(ERR_IO_PENDING, rv); |
8492 | 8491 |
8493 EXPECT_EQ(OK, callback2.WaitForResult()); | 8492 EXPECT_EQ(OK, callback2.WaitForResult()); |
8494 EXPECT_EQ(OK, callback3.WaitForResult()); | 8493 EXPECT_EQ(OK, callback3.WaitForResult()); |
8495 | 8494 |
8496 response = trans2.GetResponseInfo(); | 8495 response = trans2.GetResponseInfo(); |
8497 ASSERT_TRUE(response != NULL); | 8496 ASSERT_TRUE(response != NULL); |
8498 ASSERT_TRUE(response->headers != NULL); | 8497 ASSERT_TRUE(response->headers.get() != NULL); |
8499 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8498 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8500 EXPECT_TRUE(response->was_fetched_via_spdy); | 8499 EXPECT_TRUE(response->was_fetched_via_spdy); |
8501 EXPECT_TRUE(response->was_npn_negotiated); | 8500 EXPECT_TRUE(response->was_npn_negotiated); |
8502 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 8501 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
8503 EXPECT_EQ("hello!", response_data); | 8502 EXPECT_EQ("hello!", response_data); |
8504 | 8503 |
8505 response = trans3.GetResponseInfo(); | 8504 response = trans3.GetResponseInfo(); |
8506 ASSERT_TRUE(response != NULL); | 8505 ASSERT_TRUE(response != NULL); |
8507 ASSERT_TRUE(response->headers != NULL); | 8506 ASSERT_TRUE(response->headers.get() != NULL); |
8508 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8507 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8509 EXPECT_TRUE(response->was_fetched_via_spdy); | 8508 EXPECT_TRUE(response->was_fetched_via_spdy); |
8510 EXPECT_TRUE(response->was_npn_negotiated); | 8509 EXPECT_TRUE(response->was_npn_negotiated); |
8511 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); | 8510 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); |
8512 EXPECT_EQ("hello!", response_data); | 8511 EXPECT_EQ("hello!", response_data); |
8513 } | 8512 } |
8514 | 8513 |
8515 TEST_F(HttpNetworkTransactionSpdy2Test, StallAlternateProtocolForNpnSpdy) { | 8514 TEST_F(HttpNetworkTransactionSpdy2Test, StallAlternateProtocolForNpnSpdy) { |
8516 HttpStreamFactory::set_use_alternate_protocols(true); | 8515 HttpStreamFactory::set_use_alternate_protocols(true); |
8517 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 8516 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
(...skipping 27 matching lines...) Expand all Loading... |
8545 session_deps_.socket_factory->AddSocketDataProvider( | 8544 session_deps_.socket_factory->AddSocketDataProvider( |
8546 &hanging_alternate_protocol_socket); | 8545 &hanging_alternate_protocol_socket); |
8547 | 8546 |
8548 // 2nd request is just a copy of the first one, over HTTP again. | 8547 // 2nd request is just a copy of the first one, over HTTP again. |
8549 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 8548 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
8550 | 8549 |
8551 TestCompletionCallback callback; | 8550 TestCompletionCallback callback; |
8552 | 8551 |
8553 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8552 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8554 scoped_ptr<HttpTransaction> trans( | 8553 scoped_ptr<HttpTransaction> trans( |
8555 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8554 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8556 | 8555 |
8557 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8556 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8558 EXPECT_EQ(ERR_IO_PENDING, rv); | 8557 EXPECT_EQ(ERR_IO_PENDING, rv); |
8559 EXPECT_EQ(OK, callback.WaitForResult()); | 8558 EXPECT_EQ(OK, callback.WaitForResult()); |
8560 | 8559 |
8561 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8560 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8562 ASSERT_TRUE(response != NULL); | 8561 ASSERT_TRUE(response != NULL); |
8563 ASSERT_TRUE(response->headers != NULL); | 8562 ASSERT_TRUE(response->headers.get() != NULL); |
8564 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8563 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8565 | 8564 |
8566 std::string response_data; | 8565 std::string response_data; |
8567 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8566 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8568 EXPECT_EQ("hello world", response_data); | 8567 EXPECT_EQ("hello world", response_data); |
8569 | 8568 |
8570 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8569 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8571 | 8570 |
8572 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8571 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8573 EXPECT_EQ(ERR_IO_PENDING, rv); | 8572 EXPECT_EQ(ERR_IO_PENDING, rv); |
8574 EXPECT_EQ(OK, callback.WaitForResult()); | 8573 EXPECT_EQ(OK, callback.WaitForResult()); |
8575 | 8574 |
8576 response = trans->GetResponseInfo(); | 8575 response = trans->GetResponseInfo(); |
8577 ASSERT_TRUE(response != NULL); | 8576 ASSERT_TRUE(response != NULL); |
8578 ASSERT_TRUE(response->headers != NULL); | 8577 ASSERT_TRUE(response->headers.get() != NULL); |
8579 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8578 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8580 EXPECT_FALSE(response->was_fetched_via_spdy); | 8579 EXPECT_FALSE(response->was_fetched_via_spdy); |
8581 EXPECT_FALSE(response->was_npn_negotiated); | 8580 EXPECT_FALSE(response->was_npn_negotiated); |
8582 | 8581 |
8583 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8582 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8584 EXPECT_EQ("hello world", response_data); | 8583 EXPECT_EQ("hello world", response_data); |
8585 } | 8584 } |
8586 | 8585 |
8587 class CapturingProxyResolver : public ProxyResolver { | 8586 class CapturingProxyResolver : public ProxyResolver { |
8588 public: | 8587 public: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8695 NULL, 0, NULL, 0); | 8694 NULL, 0, NULL, 0); |
8696 hanging_non_alternate_protocol_socket.set_connect_data( | 8695 hanging_non_alternate_protocol_socket.set_connect_data( |
8697 never_finishing_connect); | 8696 never_finishing_connect); |
8698 session_deps_.socket_factory->AddSocketDataProvider( | 8697 session_deps_.socket_factory->AddSocketDataProvider( |
8699 &hanging_non_alternate_protocol_socket); | 8698 &hanging_non_alternate_protocol_socket); |
8700 | 8699 |
8701 TestCompletionCallback callback; | 8700 TestCompletionCallback callback; |
8702 | 8701 |
8703 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8702 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8704 scoped_ptr<HttpTransaction> trans( | 8703 scoped_ptr<HttpTransaction> trans( |
8705 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8704 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8706 | 8705 |
8707 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8706 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8708 EXPECT_EQ(ERR_IO_PENDING, rv); | 8707 EXPECT_EQ(ERR_IO_PENDING, rv); |
8709 EXPECT_EQ(OK, callback.WaitForResult()); | 8708 EXPECT_EQ(OK, callback.WaitForResult()); |
8710 | 8709 |
8711 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8710 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8712 ASSERT_TRUE(response != NULL); | 8711 ASSERT_TRUE(response != NULL); |
8713 ASSERT_TRUE(response->headers != NULL); | 8712 ASSERT_TRUE(response->headers.get() != NULL); |
8714 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8713 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8715 EXPECT_FALSE(response->was_fetched_via_spdy); | 8714 EXPECT_FALSE(response->was_fetched_via_spdy); |
8716 EXPECT_FALSE(response->was_npn_negotiated); | 8715 EXPECT_FALSE(response->was_npn_negotiated); |
8717 | 8716 |
8718 std::string response_data; | 8717 std::string response_data; |
8719 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8718 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8720 EXPECT_EQ("hello world", response_data); | 8719 EXPECT_EQ("hello world", response_data); |
8721 | 8720 |
8722 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8721 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8723 | 8722 |
8724 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8723 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8725 EXPECT_EQ(ERR_IO_PENDING, rv); | 8724 EXPECT_EQ(ERR_IO_PENDING, rv); |
8726 EXPECT_EQ(OK, callback.WaitForResult()); | 8725 EXPECT_EQ(OK, callback.WaitForResult()); |
8727 | 8726 |
8728 response = trans->GetResponseInfo(); | 8727 response = trans->GetResponseInfo(); |
8729 ASSERT_TRUE(response != NULL); | 8728 ASSERT_TRUE(response != NULL); |
8730 ASSERT_TRUE(response->headers != NULL); | 8729 ASSERT_TRUE(response->headers.get() != NULL); |
8731 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8730 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8732 EXPECT_TRUE(response->was_fetched_via_spdy); | 8731 EXPECT_TRUE(response->was_fetched_via_spdy); |
8733 EXPECT_TRUE(response->was_npn_negotiated); | 8732 EXPECT_TRUE(response->was_npn_negotiated); |
8734 | 8733 |
8735 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8734 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8736 EXPECT_EQ("hello!", response_data); | 8735 EXPECT_EQ("hello!", response_data); |
8737 ASSERT_EQ(3u, capturing_proxy_resolver->resolved().size()); | 8736 ASSERT_EQ(3u, capturing_proxy_resolver->resolved().size()); |
8738 EXPECT_EQ("http://www.google.com/", | 8737 EXPECT_EQ("http://www.google.com/", |
8739 capturing_proxy_resolver->resolved()[0].spec()); | 8738 capturing_proxy_resolver->resolved()[0].spec()); |
8740 EXPECT_EQ("https://www.google.com/", | 8739 EXPECT_EQ("https://www.google.com/", |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8787 1, // wait for one write to finish before reading. | 8786 1, // wait for one write to finish before reading. |
8788 spdy_reads, arraysize(spdy_reads), | 8787 spdy_reads, arraysize(spdy_reads), |
8789 spdy_writes, arraysize(spdy_writes)); | 8788 spdy_writes, arraysize(spdy_writes)); |
8790 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 8789 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
8791 | 8790 |
8792 TestCompletionCallback callback; | 8791 TestCompletionCallback callback; |
8793 | 8792 |
8794 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8793 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
8795 | 8794 |
8796 scoped_ptr<HttpTransaction> trans( | 8795 scoped_ptr<HttpTransaction> trans( |
8797 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8796 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8798 | 8797 |
8799 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8798 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8800 EXPECT_EQ(ERR_IO_PENDING, rv); | 8799 EXPECT_EQ(ERR_IO_PENDING, rv); |
8801 EXPECT_EQ(OK, callback.WaitForResult()); | 8800 EXPECT_EQ(OK, callback.WaitForResult()); |
8802 | 8801 |
8803 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8802 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8804 ASSERT_TRUE(response != NULL); | 8803 ASSERT_TRUE(response != NULL); |
8805 ASSERT_TRUE(response->headers != NULL); | 8804 ASSERT_TRUE(response->headers.get() != NULL); |
8806 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8805 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8807 | 8806 |
8808 std::string response_data; | 8807 std::string response_data; |
8809 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8808 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8810 EXPECT_EQ("hello world", response_data); | 8809 EXPECT_EQ("hello world", response_data); |
8811 | 8810 |
8812 // Set up an initial SpdySession in the pool to reuse. | 8811 // Set up an initial SpdySession in the pool to reuse. |
8813 HostPortPair host_port_pair("www.google.com", 443); | 8812 HostPortPair host_port_pair("www.google.com", 443); |
8814 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 8813 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
8815 kPrivacyModeDisabled); | 8814 kPrivacyModeDisabled); |
(...skipping 25 matching lines...) Expand all Loading... |
8841 HostPortPair(std::string(), 443), | 8840 HostPortPair(std::string(), 443), |
8842 ssl_config, | 8841 ssl_config, |
8843 context)); | 8842 context)); |
8844 EXPECT_EQ(ERR_IO_PENDING, | 8843 EXPECT_EQ(ERR_IO_PENDING, |
8845 ssl_connection->socket()->Connect(callback.callback())); | 8844 ssl_connection->socket()->Connect(callback.callback())); |
8846 EXPECT_EQ(OK, callback.WaitForResult()); | 8845 EXPECT_EQ(OK, callback.WaitForResult()); |
8847 | 8846 |
8848 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), | 8847 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), |
8849 true, OK)); | 8848 true, OK)); |
8850 | 8849 |
8851 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 8850 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
8852 | 8851 |
8853 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8852 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8854 EXPECT_EQ(ERR_IO_PENDING, rv); | 8853 EXPECT_EQ(ERR_IO_PENDING, rv); |
8855 EXPECT_EQ(OK, callback.WaitForResult()); | 8854 EXPECT_EQ(OK, callback.WaitForResult()); |
8856 | 8855 |
8857 response = trans->GetResponseInfo(); | 8856 response = trans->GetResponseInfo(); |
8858 ASSERT_TRUE(response != NULL); | 8857 ASSERT_TRUE(response != NULL); |
8859 ASSERT_TRUE(response->headers != NULL); | 8858 ASSERT_TRUE(response->headers.get() != NULL); |
8860 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8859 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8861 EXPECT_TRUE(response->was_fetched_via_spdy); | 8860 EXPECT_TRUE(response->was_fetched_via_spdy); |
8862 EXPECT_TRUE(response->was_npn_negotiated); | 8861 EXPECT_TRUE(response->was_npn_negotiated); |
8863 | 8862 |
8864 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8863 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8865 EXPECT_EQ("hello!", response_data); | 8864 EXPECT_EQ("hello!", response_data); |
8866 } | 8865 } |
8867 | 8866 |
8868 // GenerateAuthToken is a mighty big test. | 8867 // GenerateAuthToken is a mighty big test. |
8869 // It tests all permutation of GenerateAuthToken behavior: | 8868 // It tests all permutation of GenerateAuthToken behavior: |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9318 &transport_pool_histograms, | 9317 &transport_pool_histograms, |
9319 session_deps_.host_resolver.get(), | 9318 session_deps_.host_resolver.get(), |
9320 session_deps_.socket_factory.get(), | 9319 session_deps_.socket_factory.get(), |
9321 session_deps_.net_log); | 9320 session_deps_.net_log); |
9322 MockClientSocketPoolManager* mock_pool_manager = | 9321 MockClientSocketPoolManager* mock_pool_manager = |
9323 new MockClientSocketPoolManager; | 9322 new MockClientSocketPoolManager; |
9324 mock_pool_manager->SetTransportSocketPool(transport_pool); | 9323 mock_pool_manager->SetTransportSocketPool(transport_pool); |
9325 session_peer.SetClientSocketPoolManager(mock_pool_manager); | 9324 session_peer.SetClientSocketPoolManager(mock_pool_manager); |
9326 | 9325 |
9327 scoped_ptr<HttpTransaction> trans( | 9326 scoped_ptr<HttpTransaction> trans( |
9328 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9327 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9329 TestCompletionCallback callback; | 9328 TestCompletionCallback callback; |
9330 | 9329 |
9331 const MockWrite kGet( | 9330 const MockWrite kGet( |
9332 "GET / HTTP/1.1\r\n" | 9331 "GET / HTTP/1.1\r\n" |
9333 "Host: www.example.com\r\n" | 9332 "Host: www.example.com\r\n" |
9334 "Connection: keep-alive\r\n\r\n"); | 9333 "Connection: keep-alive\r\n\r\n"); |
9335 const MockWrite kGetAuth( | 9334 const MockWrite kGetAuth( |
9336 "GET / HTTP/1.1\r\n" | 9335 "GET / HTTP/1.1\r\n" |
9337 "Host: www.example.com\r\n" | 9336 "Host: www.example.com\r\n" |
9338 "Connection: keep-alive\r\n" | 9337 "Connection: keep-alive\r\n" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9388 EXPECT_EQ(OK, rv); | 9387 EXPECT_EQ(OK, rv); |
9389 response = trans->GetResponseInfo(); | 9388 response = trans->GetResponseInfo(); |
9390 ASSERT_TRUE(response != NULL); | 9389 ASSERT_TRUE(response != NULL); |
9391 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 9390 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
9392 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9391 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9393 | 9392 |
9394 // In between rounds, another request comes in for the same domain. | 9393 // In between rounds, another request comes in for the same domain. |
9395 // It should not be able to grab the TCP socket that trans has already | 9394 // It should not be able to grab the TCP socket that trans has already |
9396 // claimed. | 9395 // claimed. |
9397 scoped_ptr<HttpTransaction> trans_compete( | 9396 scoped_ptr<HttpTransaction> trans_compete( |
9398 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9397 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9399 TestCompletionCallback callback_compete; | 9398 TestCompletionCallback callback_compete; |
9400 rv = trans_compete->Start( | 9399 rv = trans_compete->Start( |
9401 &request, callback_compete.callback(), BoundNetLog()); | 9400 &request, callback_compete.callback(), BoundNetLog()); |
9402 EXPECT_EQ(ERR_IO_PENDING, rv); | 9401 EXPECT_EQ(ERR_IO_PENDING, rv); |
9403 // callback_compete.WaitForResult at this point would stall forever, | 9402 // callback_compete.WaitForResult at this point would stall forever, |
9404 // since the HttpNetworkTransaction does not release the request back to | 9403 // since the HttpNetworkTransaction does not release the request back to |
9405 // the pool until after authentication completes. | 9404 // the pool until after authentication completes. |
9406 | 9405 |
9407 // Second round of authentication. | 9406 // Second round of authentication. |
9408 auth_handler->SetGenerateExpectation(false, OK); | 9407 auth_handler->SetGenerateExpectation(false, OK); |
(...skipping 24 matching lines...) Expand all Loading... |
9433 rv = callback.WaitForResult(); | 9432 rv = callback.WaitForResult(); |
9434 EXPECT_EQ(OK, rv); | 9433 EXPECT_EQ(OK, rv); |
9435 response = trans->GetResponseInfo(); | 9434 response = trans->GetResponseInfo(); |
9436 ASSERT_TRUE(response != NULL); | 9435 ASSERT_TRUE(response != NULL); |
9437 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 9436 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
9438 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9437 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9439 | 9438 |
9440 // Read the body since the fourth round was successful. This will also | 9439 // Read the body since the fourth round was successful. This will also |
9441 // release the socket back to the pool. | 9440 // release the socket back to the pool. |
9442 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); | 9441 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); |
9443 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 9442 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9444 if (rv == ERR_IO_PENDING) | 9443 if (rv == ERR_IO_PENDING) |
9445 rv = callback.WaitForResult(); | 9444 rv = callback.WaitForResult(); |
9446 EXPECT_EQ(3, rv); | 9445 EXPECT_EQ(3, rv); |
9447 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 9446 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9448 EXPECT_EQ(0, rv); | 9447 EXPECT_EQ(0, rv); |
9449 // There are still 0 idle sockets, since the trans_compete transaction | 9448 // There are still 0 idle sockets, since the trans_compete transaction |
9450 // will be handed it immediately after trans releases it to the group. | 9449 // will be handed it immediately after trans releases it to the group. |
9451 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9450 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9452 | 9451 |
9453 // The competing request can now finish. Wait for the headers and then | 9452 // The competing request can now finish. Wait for the headers and then |
9454 // read the body. | 9453 // read the body. |
9455 rv = callback_compete.WaitForResult(); | 9454 rv = callback_compete.WaitForResult(); |
9456 EXPECT_EQ(OK, rv); | 9455 EXPECT_EQ(OK, rv); |
9457 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback()); | 9456 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9458 if (rv == ERR_IO_PENDING) | 9457 if (rv == ERR_IO_PENDING) |
9459 rv = callback.WaitForResult(); | 9458 rv = callback.WaitForResult(); |
9460 EXPECT_EQ(3, rv); | 9459 EXPECT_EQ(3, rv); |
9461 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback()); | 9460 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); |
9462 EXPECT_EQ(0, rv); | 9461 EXPECT_EQ(0, rv); |
9463 | 9462 |
9464 // Finally, the socket is released to the group. | 9463 // Finally, the socket is released to the group. |
9465 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 9464 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
9466 } | 9465 } |
9467 | 9466 |
9468 // This tests the case that a request is issued via http instead of spdy after | 9467 // This tests the case that a request is issued via http instead of spdy after |
9469 // npn is negotiated. | 9468 // npn is negotiated. |
9470 TEST_F(HttpNetworkTransactionSpdy2Test, NpnWithHttpOverSSL) { | 9469 TEST_F(HttpNetworkTransactionSpdy2Test, NpnWithHttpOverSSL) { |
9471 HttpStreamFactory::set_use_alternate_protocols(true); | 9470 HttpStreamFactory::set_use_alternate_protocols(true); |
(...skipping 25 matching lines...) Expand all Loading... |
9497 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9496 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9498 | 9497 |
9499 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 9498 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
9500 data_writes, arraysize(data_writes)); | 9499 data_writes, arraysize(data_writes)); |
9501 session_deps_.socket_factory->AddSocketDataProvider(&data); | 9500 session_deps_.socket_factory->AddSocketDataProvider(&data); |
9502 | 9501 |
9503 TestCompletionCallback callback; | 9502 TestCompletionCallback callback; |
9504 | 9503 |
9505 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9504 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
9506 scoped_ptr<HttpTransaction> trans( | 9505 scoped_ptr<HttpTransaction> trans( |
9507 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9506 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9508 | 9507 |
9509 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9508 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9510 | 9509 |
9511 EXPECT_EQ(ERR_IO_PENDING, rv); | 9510 EXPECT_EQ(ERR_IO_PENDING, rv); |
9512 EXPECT_EQ(OK, callback.WaitForResult()); | 9511 EXPECT_EQ(OK, callback.WaitForResult()); |
9513 | 9512 |
9514 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9513 const HttpResponseInfo* response = trans->GetResponseInfo(); |
9515 ASSERT_TRUE(response != NULL); | 9514 ASSERT_TRUE(response != NULL); |
9516 ASSERT_TRUE(response->headers != NULL); | 9515 ASSERT_TRUE(response->headers.get() != NULL); |
9517 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9516 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
9518 | 9517 |
9519 std::string response_data; | 9518 std::string response_data; |
9520 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9519 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
9521 EXPECT_EQ("hello world", response_data); | 9520 EXPECT_EQ("hello world", response_data); |
9522 | 9521 |
9523 EXPECT_FALSE(response->was_fetched_via_spdy); | 9522 EXPECT_FALSE(response->was_fetched_via_spdy); |
9524 EXPECT_TRUE(response->was_npn_negotiated); | 9523 EXPECT_TRUE(response->was_npn_negotiated); |
9525 } | 9524 } |
9526 | 9525 |
(...skipping 24 matching lines...) Expand all Loading... |
9551 DelayedSocketData spdy_data( | 9550 DelayedSocketData spdy_data( |
9552 0, // don't wait in this case, immediate hangup. | 9551 0, // don't wait in this case, immediate hangup. |
9553 spdy_reads, arraysize(spdy_reads), | 9552 spdy_reads, arraysize(spdy_reads), |
9554 spdy_writes, arraysize(spdy_writes)); | 9553 spdy_writes, arraysize(spdy_writes)); |
9555 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 9554 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
9556 | 9555 |
9557 TestCompletionCallback callback; | 9556 TestCompletionCallback callback; |
9558 | 9557 |
9559 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9558 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
9560 scoped_ptr<HttpTransaction> trans( | 9559 scoped_ptr<HttpTransaction> trans( |
9561 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9560 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9562 | 9561 |
9563 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9562 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9564 EXPECT_EQ(ERR_IO_PENDING, rv); | 9563 EXPECT_EQ(ERR_IO_PENDING, rv); |
9565 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 9564 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
9566 } | 9565 } |
9567 | 9566 |
9568 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyAlternateProtocolThroughProxy) { | 9567 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyAlternateProtocolThroughProxy) { |
9569 // This test ensures that the URL passed into the proxy is upgraded | 9568 // This test ensures that the URL passed into the proxy is upgraded |
9570 // to https when doing an Alternate Protocol upgrade. | 9569 // to https when doing an Alternate Protocol upgrade. |
9571 HttpStreamFactory::set_use_alternate_protocols(true); | 9570 HttpStreamFactory::set_use_alternate_protocols(true); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9681 session_deps_.socket_factory->AddSocketDataProvider(&data_1); | 9680 session_deps_.socket_factory->AddSocketDataProvider(&data_1); |
9682 session_deps_.socket_factory->AddSocketDataProvider(&data_2); | 9681 session_deps_.socket_factory->AddSocketDataProvider(&data_2); |
9683 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9682 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9684 session_deps_.socket_factory->AddSocketDataProvider( | 9683 session_deps_.socket_factory->AddSocketDataProvider( |
9685 &hanging_non_alternate_protocol_socket); | 9684 &hanging_non_alternate_protocol_socket); |
9686 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9685 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
9687 | 9686 |
9688 // First round should work and provide the Alternate-Protocol state. | 9687 // First round should work and provide the Alternate-Protocol state. |
9689 TestCompletionCallback callback_1; | 9688 TestCompletionCallback callback_1; |
9690 scoped_ptr<HttpTransaction> trans_1( | 9689 scoped_ptr<HttpTransaction> trans_1( |
9691 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9690 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9692 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); | 9691 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); |
9693 EXPECT_EQ(ERR_IO_PENDING, rv); | 9692 EXPECT_EQ(ERR_IO_PENDING, rv); |
9694 EXPECT_EQ(OK, callback_1.WaitForResult()); | 9693 EXPECT_EQ(OK, callback_1.WaitForResult()); |
9695 | 9694 |
9696 // Second round should attempt a tunnel connect and get an auth challenge. | 9695 // Second round should attempt a tunnel connect and get an auth challenge. |
9697 TestCompletionCallback callback_2; | 9696 TestCompletionCallback callback_2; |
9698 scoped_ptr<HttpTransaction> trans_2( | 9697 scoped_ptr<HttpTransaction> trans_2( |
9699 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9698 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9700 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); | 9699 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); |
9701 EXPECT_EQ(ERR_IO_PENDING, rv); | 9700 EXPECT_EQ(ERR_IO_PENDING, rv); |
9702 EXPECT_EQ(OK, callback_2.WaitForResult()); | 9701 EXPECT_EQ(OK, callback_2.WaitForResult()); |
9703 const HttpResponseInfo* response = trans_2->GetResponseInfo(); | 9702 const HttpResponseInfo* response = trans_2->GetResponseInfo(); |
9704 ASSERT_TRUE(response != NULL); | 9703 ASSERT_TRUE(response != NULL); |
9705 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 9704 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
9706 | 9705 |
9707 // Restart with auth. Tunnel should work and response received. | 9706 // Restart with auth. Tunnel should work and response received. |
9708 TestCompletionCallback callback_3; | 9707 TestCompletionCallback callback_3; |
9709 rv = trans_2->RestartWithAuth( | 9708 rv = trans_2->RestartWithAuth( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9787 MockRead(SYNCHRONOUS, OK), | 9786 MockRead(SYNCHRONOUS, OK), |
9788 }; | 9787 }; |
9789 | 9788 |
9790 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 9789 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
9791 data_writes1, arraysize(data_writes1)); | 9790 data_writes1, arraysize(data_writes1)); |
9792 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 9791 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
9793 | 9792 |
9794 TestCompletionCallback callback1; | 9793 TestCompletionCallback callback1; |
9795 | 9794 |
9796 scoped_ptr<HttpTransaction> trans( | 9795 scoped_ptr<HttpTransaction> trans( |
9797 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9796 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9798 | 9797 |
9799 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 9798 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
9800 EXPECT_EQ(ERR_IO_PENDING, rv); | 9799 EXPECT_EQ(ERR_IO_PENDING, rv); |
9801 | 9800 |
9802 rv = callback1.WaitForResult(); | 9801 rv = callback1.WaitForResult(); |
9803 EXPECT_EQ(OK, rv); | 9802 EXPECT_EQ(OK, rv); |
9804 | 9803 |
9805 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9804 const HttpResponseInfo* response = trans->GetResponseInfo(); |
9806 ASSERT_TRUE(response != NULL); | 9805 ASSERT_TRUE(response != NULL); |
9807 | 9806 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9851 | 9850 |
9852 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 9851 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
9853 data_writes1, arraysize(data_writes1)); | 9852 data_writes1, arraysize(data_writes1)); |
9854 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 9853 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
9855 SSLSocketDataProvider ssl(ASYNC, OK); | 9854 SSLSocketDataProvider ssl(ASYNC, OK); |
9856 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9855 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9857 | 9856 |
9858 TestCompletionCallback callback1; | 9857 TestCompletionCallback callback1; |
9859 | 9858 |
9860 scoped_ptr<HttpTransaction> trans( | 9859 scoped_ptr<HttpTransaction> trans( |
9861 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9860 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9862 | 9861 |
9863 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 9862 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
9864 EXPECT_EQ(ERR_IO_PENDING, rv); | 9863 EXPECT_EQ(ERR_IO_PENDING, rv); |
9865 | 9864 |
9866 rv = callback1.WaitForResult(); | 9865 rv = callback1.WaitForResult(); |
9867 EXPECT_EQ(OK, rv); | 9866 EXPECT_EQ(OK, rv); |
9868 net::CapturingNetLog::CapturedEntryList entries; | 9867 net::CapturingNetLog::CapturedEntryList entries; |
9869 log.GetEntries(&entries); | 9868 log.GetEntries(&entries); |
9870 size_t pos = ExpectLogContainsSomewhere( | 9869 size_t pos = ExpectLogContainsSomewhere( |
9871 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 9870 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9921 | 9920 |
9922 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 9921 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
9923 data_writes1, arraysize(data_writes1)); | 9922 data_writes1, arraysize(data_writes1)); |
9924 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 9923 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
9925 SSLSocketDataProvider ssl(ASYNC, OK); | 9924 SSLSocketDataProvider ssl(ASYNC, OK); |
9926 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 9925 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
9927 | 9926 |
9928 TestCompletionCallback callback1; | 9927 TestCompletionCallback callback1; |
9929 | 9928 |
9930 scoped_ptr<HttpTransaction> trans( | 9929 scoped_ptr<HttpTransaction> trans( |
9931 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 9930 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9932 | 9931 |
9933 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 9932 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
9934 EXPECT_EQ(ERR_IO_PENDING, rv); | 9933 EXPECT_EQ(ERR_IO_PENDING, rv); |
9935 | 9934 |
9936 rv = callback1.WaitForResult(); | 9935 rv = callback1.WaitForResult(); |
9937 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 9936 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
9938 net::CapturingNetLog::CapturedEntryList entries; | 9937 net::CapturingNetLog::CapturedEntryList entries; |
9939 log.GetEntries(&entries); | 9938 log.GetEntries(&entries); |
9940 size_t pos = ExpectLogContainsSomewhere( | 9939 size_t pos = ExpectLogContainsSomewhere( |
9941 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 9940 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9998 | 9997 |
9999 HttpRequestInfo request; | 9998 HttpRequestInfo request; |
10000 request.method = "GET"; | 9999 request.method = "GET"; |
10001 request.url = GURL("https://www.google.com/"); | 10000 request.url = GURL("https://www.google.com/"); |
10002 request.load_flags = 0; | 10001 request.load_flags = 0; |
10003 | 10002 |
10004 // This is the important line that marks this as a preconnect. | 10003 // This is the important line that marks this as a preconnect. |
10005 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; | 10004 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; |
10006 | 10005 |
10007 scoped_ptr<HttpTransaction> trans( | 10006 scoped_ptr<HttpTransaction> trans( |
10008 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10007 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10009 | 10008 |
10010 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10009 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
10011 EXPECT_EQ(ERR_IO_PENDING, rv); | 10010 EXPECT_EQ(ERR_IO_PENDING, rv); |
10012 EXPECT_EQ(OK, callback.WaitForResult()); | 10011 EXPECT_EQ(OK, callback.WaitForResult()); |
10013 } | 10012 } |
10014 | 10013 |
10015 // Given a net error, cause that error to be returned from the first Write() | 10014 // Given a net error, cause that error to be returned from the first Write() |
10016 // call and verify that the HttpTransaction fails with that error. | 10015 // call and verify that the HttpTransaction fails with that error. |
10017 void HttpNetworkTransactionSpdy2Test::CheckErrorIsPassedBack( | 10016 void HttpNetworkTransactionSpdy2Test::CheckErrorIsPassedBack( |
10018 int error, IoMode mode) { | 10017 int error, IoMode mode) { |
10019 net::HttpRequestInfo request_info; | 10018 net::HttpRequestInfo request_info; |
10020 request_info.url = GURL("https://www.example.com/"); | 10019 request_info.url = GURL("https://www.example.com/"); |
10021 request_info.method = "GET"; | 10020 request_info.method = "GET"; |
10022 request_info.load_flags = net::LOAD_NORMAL; | 10021 request_info.load_flags = net::LOAD_NORMAL; |
10023 | 10022 |
10024 SSLSocketDataProvider ssl_data(mode, OK); | 10023 SSLSocketDataProvider ssl_data(mode, OK); |
10025 net::MockWrite data_writes[] = { | 10024 net::MockWrite data_writes[] = { |
10026 net::MockWrite(mode, error), | 10025 net::MockWrite(mode, error), |
10027 }; | 10026 }; |
10028 net::StaticSocketDataProvider data(NULL, 0, | 10027 net::StaticSocketDataProvider data(NULL, 0, |
10029 data_writes, arraysize(data_writes)); | 10028 data_writes, arraysize(data_writes)); |
10030 session_deps_.socket_factory->AddSocketDataProvider(&data); | 10029 session_deps_.socket_factory->AddSocketDataProvider(&data); |
10031 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data); | 10030 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data); |
10032 | 10031 |
10033 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10032 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10034 scoped_ptr<HttpTransaction> trans( | 10033 scoped_ptr<HttpTransaction> trans( |
10035 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10034 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10036 | 10035 |
10037 TestCompletionCallback callback; | 10036 TestCompletionCallback callback; |
10038 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10037 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10039 if (rv == net::ERR_IO_PENDING) | 10038 if (rv == net::ERR_IO_PENDING) |
10040 rv = callback.WaitForResult(); | 10039 rv = callback.WaitForResult(); |
10041 ASSERT_EQ(error, rv); | 10040 ASSERT_EQ(error, rv); |
10042 } | 10041 } |
10043 | 10042 |
10044 TEST_F(HttpNetworkTransactionSpdy2Test, SSLWriteCertError) { | 10043 TEST_F(HttpNetworkTransactionSpdy2Test, SSLWriteCertError) { |
10045 // Just check a grab bag of cert errors. | 10044 // Just check a grab bag of cert errors. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10119 | 10118 |
10120 // Need one more if TLSv1.2 is enabled. | 10119 // Need one more if TLSv1.2 is enabled. |
10121 SSLSocketDataProvider ssl_data5(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 10120 SSLSocketDataProvider ssl_data5(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
10122 ssl_data5.cert_request_info = cert_request.get(); | 10121 ssl_data5.cert_request_info = cert_request.get(); |
10123 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); | 10122 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
10124 net::StaticSocketDataProvider data5(NULL, 0, NULL, 0); | 10123 net::StaticSocketDataProvider data5(NULL, 0, NULL, 0); |
10125 session_deps_.socket_factory->AddSocketDataProvider(&data5); | 10124 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
10126 | 10125 |
10127 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10126 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10128 scoped_ptr<HttpTransaction> trans( | 10127 scoped_ptr<HttpTransaction> trans( |
10129 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10128 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10130 | 10129 |
10131 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 10130 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
10132 TestCompletionCallback callback; | 10131 TestCompletionCallback callback; |
10133 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10132 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10134 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10133 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10135 | 10134 |
10136 // Complete the SSL handshake, which should abort due to requiring a | 10135 // Complete the SSL handshake, which should abort due to requiring a |
10137 // client certificate. | 10136 // client certificate. |
10138 rv = callback.WaitForResult(); | 10137 rv = callback.WaitForResult(); |
10139 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 10138 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10240 // Need one more if TLSv1.2 is enabled. | 10239 // Need one more if TLSv1.2 is enabled. |
10241 SSLSocketDataProvider ssl_data5(ASYNC, net::OK); | 10240 SSLSocketDataProvider ssl_data5(ASYNC, net::OK); |
10242 ssl_data5.cert_request_info = cert_request.get(); | 10241 ssl_data5.cert_request_info = cert_request.get(); |
10243 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); | 10242 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
10244 net::StaticSocketDataProvider data5( | 10243 net::StaticSocketDataProvider data5( |
10245 data2_reads, arraysize(data2_reads), NULL, 0); | 10244 data2_reads, arraysize(data2_reads), NULL, 0); |
10246 session_deps_.socket_factory->AddSocketDataProvider(&data5); | 10245 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
10247 | 10246 |
10248 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10247 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10249 scoped_ptr<HttpTransaction> trans( | 10248 scoped_ptr<HttpTransaction> trans( |
10250 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10249 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10251 | 10250 |
10252 // Begin the initial SSL handshake. | 10251 // Begin the initial SSL handshake. |
10253 TestCompletionCallback callback; | 10252 TestCompletionCallback callback; |
10254 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10253 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10255 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10254 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10256 | 10255 |
10257 // Complete the SSL handshake, which should abort due to requiring a | 10256 // Complete the SSL handshake, which should abort due to requiring a |
10258 // client certificate. | 10257 // client certificate. |
10259 rv = callback.WaitForResult(); | 10258 rv = callback.WaitForResult(); |
10260 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 10259 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10333 requests[0].load_flags = net::LOAD_NORMAL; | 10332 requests[0].load_flags = net::LOAD_NORMAL; |
10334 | 10333 |
10335 requests[1].url = GURL("http://www.example.com/"); | 10334 requests[1].url = GURL("http://www.example.com/"); |
10336 requests[1].method = "GET"; | 10335 requests[1].method = "GET"; |
10337 requests[1].load_flags = net::LOAD_NORMAL; | 10336 requests[1].load_flags = net::LOAD_NORMAL; |
10338 | 10337 |
10339 for (size_t i = 0; i < arraysize(requests); ++i) { | 10338 for (size_t i = 0; i < arraysize(requests); ++i) { |
10340 session_deps_.socket_factory->ResetNextMockIndexes(); | 10339 session_deps_.socket_factory->ResetNextMockIndexes(); |
10341 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10340 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10342 scoped_ptr<HttpNetworkTransaction> trans( | 10341 scoped_ptr<HttpNetworkTransaction> trans( |
10343 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10342 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
10344 | 10343 |
10345 // Begin the SSL handshake with the proxy. | 10344 // Begin the SSL handshake with the proxy. |
10346 TestCompletionCallback callback; | 10345 TestCompletionCallback callback; |
10347 int rv = trans->Start( | 10346 int rv = trans->Start( |
10348 &requests[i], callback.callback(), net::BoundNetLog()); | 10347 &requests[i], callback.callback(), net::BoundNetLog()); |
10349 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10348 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10350 | 10349 |
10351 // Complete the SSL handshake, which should abort due to requiring a | 10350 // Complete the SSL handshake, which should abort due to requiring a |
10352 // client certificate. | 10351 // client certificate. |
10353 rv = callback.WaitForResult(); | 10352 rv = callback.WaitForResult(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10434 connect, | 10433 connect, |
10435 spdy_reads, arraysize(spdy_reads), | 10434 spdy_reads, arraysize(spdy_reads), |
10436 spdy_writes, arraysize(spdy_writes)); | 10435 spdy_writes, arraysize(spdy_writes)); |
10437 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10436 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
10438 | 10437 |
10439 TestCompletionCallback callback; | 10438 TestCompletionCallback callback; |
10440 HttpRequestInfo request1; | 10439 HttpRequestInfo request1; |
10441 request1.method = "GET"; | 10440 request1.method = "GET"; |
10442 request1.url = GURL("https://www.google.com/"); | 10441 request1.url = GURL("https://www.google.com/"); |
10443 request1.load_flags = 0; | 10442 request1.load_flags = 0; |
10444 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 10443 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
10445 | 10444 |
10446 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 10445 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
10447 EXPECT_EQ(ERR_IO_PENDING, rv); | 10446 EXPECT_EQ(ERR_IO_PENDING, rv); |
10448 EXPECT_EQ(OK, callback.WaitForResult()); | 10447 EXPECT_EQ(OK, callback.WaitForResult()); |
10449 | 10448 |
10450 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 10449 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
10451 ASSERT_TRUE(response != NULL); | 10450 ASSERT_TRUE(response != NULL); |
10452 ASSERT_TRUE(response->headers != NULL); | 10451 ASSERT_TRUE(response->headers.get() != NULL); |
10453 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10452 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10454 | 10453 |
10455 std::string response_data; | 10454 std::string response_data; |
10456 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 10455 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
10457 EXPECT_EQ("hello!", response_data); | 10456 EXPECT_EQ("hello!", response_data); |
10458 | 10457 |
10459 // Preload www.gmail.com into HostCache. | 10458 // Preload www.gmail.com into HostCache. |
10460 HostPortPair host_port("www.gmail.com", 443); | 10459 HostPortPair host_port("www.gmail.com", 443); |
10461 HostResolver::RequestInfo resolve_info(host_port); | 10460 HostResolver::RequestInfo resolve_info(host_port); |
10462 AddressList ignored; | 10461 AddressList ignored; |
10463 rv = session_deps_.host_resolver->Resolve(resolve_info, &ignored, | 10462 rv = session_deps_.host_resolver->Resolve(resolve_info, &ignored, |
10464 callback.callback(), NULL, | 10463 callback.callback(), NULL, |
10465 BoundNetLog()); | 10464 BoundNetLog()); |
10466 EXPECT_EQ(ERR_IO_PENDING, rv); | 10465 EXPECT_EQ(ERR_IO_PENDING, rv); |
10467 rv = callback.WaitForResult(); | 10466 rv = callback.WaitForResult(); |
10468 EXPECT_EQ(OK, rv); | 10467 EXPECT_EQ(OK, rv); |
10469 | 10468 |
10470 HttpRequestInfo request2; | 10469 HttpRequestInfo request2; |
10471 request2.method = "GET"; | 10470 request2.method = "GET"; |
10472 request2.url = GURL("https://www.gmail.com/"); | 10471 request2.url = GURL("https://www.gmail.com/"); |
10473 request2.load_flags = 0; | 10472 request2.load_flags = 0; |
10474 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 10473 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
10475 | 10474 |
10476 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 10475 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
10477 EXPECT_EQ(ERR_IO_PENDING, rv); | 10476 EXPECT_EQ(ERR_IO_PENDING, rv); |
10478 EXPECT_EQ(OK, callback.WaitForResult()); | 10477 EXPECT_EQ(OK, callback.WaitForResult()); |
10479 | 10478 |
10480 response = trans2.GetResponseInfo(); | 10479 response = trans2.GetResponseInfo(); |
10481 ASSERT_TRUE(response != NULL); | 10480 ASSERT_TRUE(response != NULL); |
10482 ASSERT_TRUE(response->headers != NULL); | 10481 ASSERT_TRUE(response->headers.get() != NULL); |
10483 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10482 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10484 EXPECT_TRUE(response->was_fetched_via_spdy); | 10483 EXPECT_TRUE(response->was_fetched_via_spdy); |
10485 EXPECT_TRUE(response->was_npn_negotiated); | 10484 EXPECT_TRUE(response->was_npn_negotiated); |
10486 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 10485 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
10487 EXPECT_EQ("hello!", response_data); | 10486 EXPECT_EQ("hello!", response_data); |
10488 } | 10487 } |
10489 #undef MAYBE_UseIPConnectionPooling | 10488 #undef MAYBE_UseIPConnectionPooling |
10490 | 10489 |
10491 TEST_F(HttpNetworkTransactionSpdy2Test, UseIPConnectionPoolingAfterResolution) { | 10490 TEST_F(HttpNetworkTransactionSpdy2Test, UseIPConnectionPoolingAfterResolution) { |
10492 HttpStreamFactory::set_use_alternate_protocols(true); | 10491 HttpStreamFactory::set_use_alternate_protocols(true); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10530 connect, | 10529 connect, |
10531 spdy_reads, arraysize(spdy_reads), | 10530 spdy_reads, arraysize(spdy_reads), |
10532 spdy_writes, arraysize(spdy_writes)); | 10531 spdy_writes, arraysize(spdy_writes)); |
10533 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10532 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
10534 | 10533 |
10535 TestCompletionCallback callback; | 10534 TestCompletionCallback callback; |
10536 HttpRequestInfo request1; | 10535 HttpRequestInfo request1; |
10537 request1.method = "GET"; | 10536 request1.method = "GET"; |
10538 request1.url = GURL("https://www.google.com/"); | 10537 request1.url = GURL("https://www.google.com/"); |
10539 request1.load_flags = 0; | 10538 request1.load_flags = 0; |
10540 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 10539 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
10541 | 10540 |
10542 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 10541 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
10543 EXPECT_EQ(ERR_IO_PENDING, rv); | 10542 EXPECT_EQ(ERR_IO_PENDING, rv); |
10544 EXPECT_EQ(OK, callback.WaitForResult()); | 10543 EXPECT_EQ(OK, callback.WaitForResult()); |
10545 | 10544 |
10546 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 10545 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
10547 ASSERT_TRUE(response != NULL); | 10546 ASSERT_TRUE(response != NULL); |
10548 ASSERT_TRUE(response->headers != NULL); | 10547 ASSERT_TRUE(response->headers.get() != NULL); |
10549 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10548 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10550 | 10549 |
10551 std::string response_data; | 10550 std::string response_data; |
10552 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 10551 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
10553 EXPECT_EQ("hello!", response_data); | 10552 EXPECT_EQ("hello!", response_data); |
10554 | 10553 |
10555 HttpRequestInfo request2; | 10554 HttpRequestInfo request2; |
10556 request2.method = "GET"; | 10555 request2.method = "GET"; |
10557 request2.url = GURL("https://www.gmail.com/"); | 10556 request2.url = GURL("https://www.gmail.com/"); |
10558 request2.load_flags = 0; | 10557 request2.load_flags = 0; |
10559 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 10558 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
10560 | 10559 |
10561 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 10560 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
10562 EXPECT_EQ(ERR_IO_PENDING, rv); | 10561 EXPECT_EQ(ERR_IO_PENDING, rv); |
10563 EXPECT_EQ(OK, callback.WaitForResult()); | 10562 EXPECT_EQ(OK, callback.WaitForResult()); |
10564 | 10563 |
10565 response = trans2.GetResponseInfo(); | 10564 response = trans2.GetResponseInfo(); |
10566 ASSERT_TRUE(response != NULL); | 10565 ASSERT_TRUE(response != NULL); |
10567 ASSERT_TRUE(response->headers != NULL); | 10566 ASSERT_TRUE(response->headers.get() != NULL); |
10568 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10567 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10569 EXPECT_TRUE(response->was_fetched_via_spdy); | 10568 EXPECT_TRUE(response->was_fetched_via_spdy); |
10570 EXPECT_TRUE(response->was_npn_negotiated); | 10569 EXPECT_TRUE(response->was_npn_negotiated); |
10571 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 10570 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
10572 EXPECT_EQ("hello!", response_data); | 10571 EXPECT_EQ("hello!", response_data); |
10573 } | 10572 } |
10574 | 10573 |
10575 class OneTimeCachingHostResolver : public net::HostResolver { | 10574 class OneTimeCachingHostResolver : public net::HostResolver { |
10576 public: | 10575 public: |
10577 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) | 10576 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10666 connect, | 10665 connect, |
10667 spdy_reads, arraysize(spdy_reads), | 10666 spdy_reads, arraysize(spdy_reads), |
10668 spdy_writes, arraysize(spdy_writes)); | 10667 spdy_writes, arraysize(spdy_writes)); |
10669 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10668 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
10670 | 10669 |
10671 TestCompletionCallback callback; | 10670 TestCompletionCallback callback; |
10672 HttpRequestInfo request1; | 10671 HttpRequestInfo request1; |
10673 request1.method = "GET"; | 10672 request1.method = "GET"; |
10674 request1.url = GURL("https://www.google.com/"); | 10673 request1.url = GURL("https://www.google.com/"); |
10675 request1.load_flags = 0; | 10674 request1.load_flags = 0; |
10676 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session); | 10675 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
10677 | 10676 |
10678 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 10677 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
10679 EXPECT_EQ(ERR_IO_PENDING, rv); | 10678 EXPECT_EQ(ERR_IO_PENDING, rv); |
10680 EXPECT_EQ(OK, callback.WaitForResult()); | 10679 EXPECT_EQ(OK, callback.WaitForResult()); |
10681 | 10680 |
10682 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 10681 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
10683 ASSERT_TRUE(response != NULL); | 10682 ASSERT_TRUE(response != NULL); |
10684 ASSERT_TRUE(response->headers != NULL); | 10683 ASSERT_TRUE(response->headers.get() != NULL); |
10685 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10684 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10686 | 10685 |
10687 std::string response_data; | 10686 std::string response_data; |
10688 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 10687 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
10689 EXPECT_EQ("hello!", response_data); | 10688 EXPECT_EQ("hello!", response_data); |
10690 | 10689 |
10691 // Preload cache entries into HostCache. | 10690 // Preload cache entries into HostCache. |
10692 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); | 10691 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); |
10693 AddressList ignored; | 10692 AddressList ignored; |
10694 rv = host_resolver.Resolve(resolve_info, &ignored, callback.callback(), | 10693 rv = host_resolver.Resolve(resolve_info, &ignored, callback.callback(), |
10695 NULL, BoundNetLog()); | 10694 NULL, BoundNetLog()); |
10696 EXPECT_EQ(ERR_IO_PENDING, rv); | 10695 EXPECT_EQ(ERR_IO_PENDING, rv); |
10697 rv = callback.WaitForResult(); | 10696 rv = callback.WaitForResult(); |
10698 EXPECT_EQ(OK, rv); | 10697 EXPECT_EQ(OK, rv); |
10699 | 10698 |
10700 HttpRequestInfo request2; | 10699 HttpRequestInfo request2; |
10701 request2.method = "GET"; | 10700 request2.method = "GET"; |
10702 request2.url = GURL("https://www.gmail.com/"); | 10701 request2.url = GURL("https://www.gmail.com/"); |
10703 request2.load_flags = 0; | 10702 request2.load_flags = 0; |
10704 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session); | 10703 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
10705 | 10704 |
10706 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 10705 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
10707 EXPECT_EQ(ERR_IO_PENDING, rv); | 10706 EXPECT_EQ(ERR_IO_PENDING, rv); |
10708 EXPECT_EQ(OK, callback.WaitForResult()); | 10707 EXPECT_EQ(OK, callback.WaitForResult()); |
10709 | 10708 |
10710 response = trans2.GetResponseInfo(); | 10709 response = trans2.GetResponseInfo(); |
10711 ASSERT_TRUE(response != NULL); | 10710 ASSERT_TRUE(response != NULL); |
10712 ASSERT_TRUE(response->headers != NULL); | 10711 ASSERT_TRUE(response->headers.get() != NULL); |
10713 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10712 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
10714 EXPECT_TRUE(response->was_fetched_via_spdy); | 10713 EXPECT_TRUE(response->was_fetched_via_spdy); |
10715 EXPECT_TRUE(response->was_npn_negotiated); | 10714 EXPECT_TRUE(response->was_npn_negotiated); |
10716 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 10715 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
10717 EXPECT_EQ("hello!", response_data); | 10716 EXPECT_EQ("hello!", response_data); |
10718 } | 10717 } |
10719 #undef MAYBE_UseIPConnectionPoolingWithHostCacheExpiration | 10718 #undef MAYBE_UseIPConnectionPoolingWithHostCacheExpiration |
10720 | 10719 |
10721 TEST_F(HttpNetworkTransactionSpdy2Test, ReadPipelineEvictionFallback) { | 10720 TEST_F(HttpNetworkTransactionSpdy2Test, ReadPipelineEvictionFallback) { |
10722 MockRead data_reads1[] = { | 10721 MockRead data_reads1[] = { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10815 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 10814 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
10816 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 10815 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
10817 | 10816 |
10818 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10817 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10819 | 10818 |
10820 // Start the first transaction to set up the SpdySession | 10819 // Start the first transaction to set up the SpdySession |
10821 HttpRequestInfo request1; | 10820 HttpRequestInfo request1; |
10822 request1.method = "GET"; | 10821 request1.method = "GET"; |
10823 request1.url = GURL(https_url); | 10822 request1.url = GURL(https_url); |
10824 request1.load_flags = 0; | 10823 request1.load_flags = 0; |
10825 HttpNetworkTransaction trans1(LOWEST, session); | 10824 HttpNetworkTransaction trans1(LOWEST, session.get()); |
10826 TestCompletionCallback callback1; | 10825 TestCompletionCallback callback1; |
10827 EXPECT_EQ(ERR_IO_PENDING, | 10826 EXPECT_EQ(ERR_IO_PENDING, |
10828 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 10827 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
10829 base::MessageLoop::current()->RunUntilIdle(); | 10828 base::MessageLoop::current()->RunUntilIdle(); |
10830 | 10829 |
10831 EXPECT_EQ(OK, callback1.WaitForResult()); | 10830 EXPECT_EQ(OK, callback1.WaitForResult()); |
10832 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 10831 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
10833 | 10832 |
10834 // Now, start the HTTP request | 10833 // Now, start the HTTP request |
10835 HttpRequestInfo request2; | 10834 HttpRequestInfo request2; |
10836 request2.method = "GET"; | 10835 request2.method = "GET"; |
10837 request2.url = GURL(http_url); | 10836 request2.url = GURL(http_url); |
10838 request2.load_flags = 0; | 10837 request2.load_flags = 0; |
10839 HttpNetworkTransaction trans2(MEDIUM, session); | 10838 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
10840 TestCompletionCallback callback2; | 10839 TestCompletionCallback callback2; |
10841 EXPECT_EQ(ERR_IO_PENDING, | 10840 EXPECT_EQ(ERR_IO_PENDING, |
10842 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10841 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
10843 base::MessageLoop::current()->RunUntilIdle(); | 10842 base::MessageLoop::current()->RunUntilIdle(); |
10844 | 10843 |
10845 EXPECT_EQ(OK, callback2.WaitForResult()); | 10844 EXPECT_EQ(OK, callback2.WaitForResult()); |
10846 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10845 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
10847 } | 10846 } |
10848 | 10847 |
10849 TEST_F(HttpNetworkTransactionSpdy2Test, DoNotUseSpdySessionForHttpOverTunnel) { | 10848 TEST_F(HttpNetworkTransactionSpdy2Test, DoNotUseSpdySessionForHttpOverTunnel) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10908 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1); | 10907 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1); |
10909 | 10908 |
10910 scoped_refptr<HttpNetworkSession> session( | 10909 scoped_refptr<HttpNetworkSession> session( |
10911 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); | 10910 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); |
10912 | 10911 |
10913 // Start the first transaction to set up the SpdySession | 10912 // Start the first transaction to set up the SpdySession |
10914 HttpRequestInfo request1; | 10913 HttpRequestInfo request1; |
10915 request1.method = "GET"; | 10914 request1.method = "GET"; |
10916 request1.url = GURL(https_url); | 10915 request1.url = GURL(https_url); |
10917 request1.load_flags = 0; | 10916 request1.load_flags = 0; |
10918 HttpNetworkTransaction trans1(LOWEST, session); | 10917 HttpNetworkTransaction trans1(LOWEST, session.get()); |
10919 TestCompletionCallback callback1; | 10918 TestCompletionCallback callback1; |
10920 EXPECT_EQ(ERR_IO_PENDING, | 10919 EXPECT_EQ(ERR_IO_PENDING, |
10921 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 10920 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
10922 base::MessageLoop::current()->RunUntilIdle(); | 10921 base::MessageLoop::current()->RunUntilIdle(); |
10923 data1.RunFor(4); | 10922 data1.RunFor(4); |
10924 | 10923 |
10925 EXPECT_EQ(OK, callback1.WaitForResult()); | 10924 EXPECT_EQ(OK, callback1.WaitForResult()); |
10926 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 10925 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
10927 | 10926 |
10928 LoadTimingInfo load_timing_info1; | 10927 LoadTimingInfo load_timing_info1; |
10929 EXPECT_TRUE(trans1.GetLoadTimingInfo(&load_timing_info1)); | 10928 EXPECT_TRUE(trans1.GetLoadTimingInfo(&load_timing_info1)); |
10930 TestLoadTimingNotReusedWithPac(load_timing_info1, | 10929 TestLoadTimingNotReusedWithPac(load_timing_info1, |
10931 CONNECT_TIMING_HAS_SSL_TIMES); | 10930 CONNECT_TIMING_HAS_SSL_TIMES); |
10932 | 10931 |
10933 // Now, start the HTTP request | 10932 // Now, start the HTTP request |
10934 HttpRequestInfo request2; | 10933 HttpRequestInfo request2; |
10935 request2.method = "GET"; | 10934 request2.method = "GET"; |
10936 request2.url = GURL(http_url); | 10935 request2.url = GURL(http_url); |
10937 request2.load_flags = 0; | 10936 request2.load_flags = 0; |
10938 HttpNetworkTransaction trans2(MEDIUM, session); | 10937 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
10939 TestCompletionCallback callback2; | 10938 TestCompletionCallback callback2; |
10940 EXPECT_EQ(ERR_IO_PENDING, | 10939 EXPECT_EQ(ERR_IO_PENDING, |
10941 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10940 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
10942 base::MessageLoop::current()->RunUntilIdle(); | 10941 base::MessageLoop::current()->RunUntilIdle(); |
10943 data1.RunFor(3); | 10942 data1.RunFor(3); |
10944 | 10943 |
10945 EXPECT_EQ(OK, callback2.WaitForResult()); | 10944 EXPECT_EQ(OK, callback2.WaitForResult()); |
10946 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10945 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
10947 | 10946 |
10948 LoadTimingInfo load_timing_info2; | 10947 LoadTimingInfo load_timing_info2; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10991 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 10990 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
10992 session_deps_.socket_factory->AddSocketDataProvider(&data); | 10991 session_deps_.socket_factory->AddSocketDataProvider(&data); |
10993 | 10992 |
10994 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10993 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10995 | 10994 |
10996 // Start the first transaction to set up the SpdySession | 10995 // Start the first transaction to set up the SpdySession |
10997 HttpRequestInfo request1; | 10996 HttpRequestInfo request1; |
10998 request1.method = "GET"; | 10997 request1.method = "GET"; |
10999 request1.url = GURL(https_url); | 10998 request1.url = GURL(https_url); |
11000 request1.load_flags = 0; | 10999 request1.load_flags = 0; |
11001 HttpNetworkTransaction trans1(LOWEST, session); | 11000 HttpNetworkTransaction trans1(LOWEST, session.get()); |
11002 TestCompletionCallback callback1; | 11001 TestCompletionCallback callback1; |
11003 EXPECT_EQ(ERR_IO_PENDING, | 11002 EXPECT_EQ(ERR_IO_PENDING, |
11004 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 11003 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
11005 base::MessageLoop::current()->RunUntilIdle(); | 11004 base::MessageLoop::current()->RunUntilIdle(); |
11006 | 11005 |
11007 EXPECT_EQ(OK, callback1.WaitForResult()); | 11006 EXPECT_EQ(OK, callback1.WaitForResult()); |
11008 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 11007 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
11009 | 11008 |
11010 // Now, start the HTTP request | 11009 // Now, start the HTTP request |
11011 HttpRequestInfo request2; | 11010 HttpRequestInfo request2; |
11012 request2.method = "GET"; | 11011 request2.method = "GET"; |
11013 request2.url = GURL(http_url); | 11012 request2.url = GURL(http_url); |
11014 request2.load_flags = 0; | 11013 request2.load_flags = 0; |
11015 HttpNetworkTransaction trans2(MEDIUM, session); | 11014 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
11016 TestCompletionCallback callback2; | 11015 TestCompletionCallback callback2; |
11017 EXPECT_EQ(ERR_IO_PENDING, | 11016 EXPECT_EQ(ERR_IO_PENDING, |
11018 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11017 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11019 base::MessageLoop::current()->RunUntilIdle(); | 11018 base::MessageLoop::current()->RunUntilIdle(); |
11020 | 11019 |
11021 EXPECT_EQ(OK, callback2.WaitForResult()); | 11020 EXPECT_EQ(OK, callback2.WaitForResult()); |
11022 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11021 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11023 } | 11022 } |
11024 | 11023 |
11025 // Test that in the case where we have a SPDY session to a SPDY proxy | 11024 // Test that in the case where we have a SPDY session to a SPDY proxy |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11123 session_deps_.host_resolver->rules()->AddRule("proxy", ip_addr); | 11122 session_deps_.host_resolver->rules()->AddRule("proxy", ip_addr); |
11124 | 11123 |
11125 scoped_refptr<HttpNetworkSession> session( | 11124 scoped_refptr<HttpNetworkSession> session( |
11126 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); | 11125 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); |
11127 | 11126 |
11128 // Start the first transaction to set up the SpdySession | 11127 // Start the first transaction to set up the SpdySession |
11129 HttpRequestInfo request1; | 11128 HttpRequestInfo request1; |
11130 request1.method = "GET"; | 11129 request1.method = "GET"; |
11131 request1.url = GURL(url1); | 11130 request1.url = GURL(url1); |
11132 request1.load_flags = 0; | 11131 request1.load_flags = 0; |
11133 HttpNetworkTransaction trans1(LOWEST, session); | 11132 HttpNetworkTransaction trans1(LOWEST, session.get()); |
11134 TestCompletionCallback callback1; | 11133 TestCompletionCallback callback1; |
11135 ASSERT_EQ(ERR_IO_PENDING, | 11134 ASSERT_EQ(ERR_IO_PENDING, |
11136 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 11135 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
11137 data1->RunFor(3); | 11136 data1->RunFor(3); |
11138 | 11137 |
11139 ASSERT_TRUE(callback1.have_result()); | 11138 ASSERT_TRUE(callback1.have_result()); |
11140 EXPECT_EQ(OK, callback1.WaitForResult()); | 11139 EXPECT_EQ(OK, callback1.WaitForResult()); |
11141 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 11140 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
11142 | 11141 |
11143 // Now, start the HTTP request | 11142 // Now, start the HTTP request |
11144 HttpRequestInfo request2; | 11143 HttpRequestInfo request2; |
11145 request2.method = "GET"; | 11144 request2.method = "GET"; |
11146 request2.url = GURL(url2); | 11145 request2.url = GURL(url2); |
11147 request2.load_flags = 0; | 11146 request2.load_flags = 0; |
11148 HttpNetworkTransaction trans2(MEDIUM, session); | 11147 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
11149 TestCompletionCallback callback2; | 11148 TestCompletionCallback callback2; |
11150 EXPECT_EQ(ERR_IO_PENDING, | 11149 EXPECT_EQ(ERR_IO_PENDING, |
11151 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11150 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11152 base::MessageLoop::current()->RunUntilIdle(); | 11151 base::MessageLoop::current()->RunUntilIdle(); |
11153 data2->RunFor(3); | 11152 data2->RunFor(3); |
11154 | 11153 |
11155 ASSERT_TRUE(callback2.have_result()); | 11154 ASSERT_TRUE(callback2.have_result()); |
11156 EXPECT_EQ(OK, callback2.WaitForResult()); | 11155 EXPECT_EQ(OK, callback2.WaitForResult()); |
11157 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11156 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11158 } | 11157 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11204 | 11203 |
11205 scoped_refptr<HttpNetworkSession> session( | 11204 scoped_refptr<HttpNetworkSession> session( |
11206 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); | 11205 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_)); |
11207 | 11206 |
11208 // Start the first transaction to set up the SpdySession and verify that | 11207 // Start the first transaction to set up the SpdySession and verify that |
11209 // connection was closed. | 11208 // connection was closed. |
11210 HttpRequestInfo request1; | 11209 HttpRequestInfo request1; |
11211 request1.method = "GET"; | 11210 request1.method = "GET"; |
11212 request1.url = GURL(https_url); | 11211 request1.url = GURL(https_url); |
11213 request1.load_flags = 0; | 11212 request1.load_flags = 0; |
11214 HttpNetworkTransaction trans1(MEDIUM, session); | 11213 HttpNetworkTransaction trans1(MEDIUM, session.get()); |
11215 TestCompletionCallback callback1; | 11214 TestCompletionCallback callback1; |
11216 EXPECT_EQ(ERR_IO_PENDING, | 11215 EXPECT_EQ(ERR_IO_PENDING, |
11217 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 11216 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
11218 base::MessageLoop::current()->RunUntilIdle(); | 11217 base::MessageLoop::current()->RunUntilIdle(); |
11219 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback1.WaitForResult()); | 11218 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback1.WaitForResult()); |
11220 | 11219 |
11221 // Now, start the second request and make sure it succeeds. | 11220 // Now, start the second request and make sure it succeeds. |
11222 HttpRequestInfo request2; | 11221 HttpRequestInfo request2; |
11223 request2.method = "GET"; | 11222 request2.method = "GET"; |
11224 request2.url = GURL(https_url); | 11223 request2.url = GURL(https_url); |
11225 request2.load_flags = 0; | 11224 request2.load_flags = 0; |
11226 HttpNetworkTransaction trans2(MEDIUM, session); | 11225 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
11227 TestCompletionCallback callback2; | 11226 TestCompletionCallback callback2; |
11228 EXPECT_EQ(ERR_IO_PENDING, | 11227 EXPECT_EQ(ERR_IO_PENDING, |
11229 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11228 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11230 base::MessageLoop::current()->RunUntilIdle(); | 11229 base::MessageLoop::current()->RunUntilIdle(); |
11231 data2->RunFor(3); | 11230 data2->RunFor(3); |
11232 | 11231 |
11233 ASSERT_TRUE(callback2.have_result()); | 11232 ASSERT_TRUE(callback2.have_result()); |
11234 EXPECT_EQ(OK, callback2.WaitForResult()); | 11233 EXPECT_EQ(OK, callback2.WaitForResult()); |
11235 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11234 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11236 } | 11235 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11313 host_port_pair_a, ProxyServer::Direct(), kPrivacyModeDisabled); | 11312 host_port_pair_a, ProxyServer::Direct(), kPrivacyModeDisabled); |
11314 EXPECT_FALSE( | 11313 EXPECT_FALSE( |
11315 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11314 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11316 | 11315 |
11317 TestCompletionCallback callback; | 11316 TestCompletionCallback callback; |
11318 HttpRequestInfo request1; | 11317 HttpRequestInfo request1; |
11319 request1.method = "GET"; | 11318 request1.method = "GET"; |
11320 request1.url = GURL("https://www.a.com/"); | 11319 request1.url = GURL("https://www.a.com/"); |
11321 request1.load_flags = 0; | 11320 request1.load_flags = 0; |
11322 scoped_ptr<HttpNetworkTransaction> trans( | 11321 scoped_ptr<HttpNetworkTransaction> trans( |
11323 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 11322 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
11324 | 11323 |
11325 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 11324 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
11326 EXPECT_EQ(ERR_IO_PENDING, rv); | 11325 EXPECT_EQ(ERR_IO_PENDING, rv); |
11327 EXPECT_EQ(OK, callback.WaitForResult()); | 11326 EXPECT_EQ(OK, callback.WaitForResult()); |
11328 | 11327 |
11329 const HttpResponseInfo* response = trans->GetResponseInfo(); | 11328 const HttpResponseInfo* response = trans->GetResponseInfo(); |
11330 ASSERT_TRUE(response != NULL); | 11329 ASSERT_TRUE(response != NULL); |
11331 ASSERT_TRUE(response->headers != NULL); | 11330 ASSERT_TRUE(response->headers.get() != NULL); |
11332 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11331 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
11333 EXPECT_TRUE(response->was_fetched_via_spdy); | 11332 EXPECT_TRUE(response->was_fetched_via_spdy); |
11334 EXPECT_TRUE(response->was_npn_negotiated); | 11333 EXPECT_TRUE(response->was_npn_negotiated); |
11335 | 11334 |
11336 std::string response_data; | 11335 std::string response_data; |
11337 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11336 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
11338 EXPECT_EQ("hello!", response_data); | 11337 EXPECT_EQ("hello!", response_data); |
11339 trans.reset(); | 11338 trans.reset(); |
11340 EXPECT_TRUE( | 11339 EXPECT_TRUE( |
11341 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11340 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11342 | 11341 |
11343 HostPortPair host_port_pair_b("www.b.com", 443); | 11342 HostPortPair host_port_pair_b("www.b.com", 443); |
11344 SpdySessionKey spdy_session_key_b( | 11343 SpdySessionKey spdy_session_key_b( |
11345 host_port_pair_b, ProxyServer::Direct(), kPrivacyModeDisabled); | 11344 host_port_pair_b, ProxyServer::Direct(), kPrivacyModeDisabled); |
11346 EXPECT_FALSE( | 11345 EXPECT_FALSE( |
11347 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11346 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11348 HttpRequestInfo request2; | 11347 HttpRequestInfo request2; |
11349 request2.method = "GET"; | 11348 request2.method = "GET"; |
11350 request2.url = GURL("https://www.b.com/"); | 11349 request2.url = GURL("https://www.b.com/"); |
11351 request2.load_flags = 0; | 11350 request2.load_flags = 0; |
11352 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 11351 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
11353 | 11352 |
11354 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); | 11353 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); |
11355 EXPECT_EQ(ERR_IO_PENDING, rv); | 11354 EXPECT_EQ(ERR_IO_PENDING, rv); |
11356 EXPECT_EQ(OK, callback.WaitForResult()); | 11355 EXPECT_EQ(OK, callback.WaitForResult()); |
11357 | 11356 |
11358 response = trans->GetResponseInfo(); | 11357 response = trans->GetResponseInfo(); |
11359 ASSERT_TRUE(response != NULL); | 11358 ASSERT_TRUE(response != NULL); |
11360 ASSERT_TRUE(response->headers != NULL); | 11359 ASSERT_TRUE(response->headers.get() != NULL); |
11361 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11360 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
11362 EXPECT_TRUE(response->was_fetched_via_spdy); | 11361 EXPECT_TRUE(response->was_fetched_via_spdy); |
11363 EXPECT_TRUE(response->was_npn_negotiated); | 11362 EXPECT_TRUE(response->was_npn_negotiated); |
11364 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11363 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
11365 EXPECT_EQ("hello!", response_data); | 11364 EXPECT_EQ("hello!", response_data); |
11366 EXPECT_FALSE( | 11365 EXPECT_FALSE( |
11367 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11366 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11368 EXPECT_TRUE( | 11367 EXPECT_TRUE( |
11369 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11368 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11370 | 11369 |
11371 HostPortPair host_port_pair_a1("www.a.com", 80); | 11370 HostPortPair host_port_pair_a1("www.a.com", 80); |
11372 SpdySessionKey spdy_session_key_a1( | 11371 SpdySessionKey spdy_session_key_a1( |
11373 host_port_pair_a1, ProxyServer::Direct(), kPrivacyModeDisabled); | 11372 host_port_pair_a1, ProxyServer::Direct(), kPrivacyModeDisabled); |
11374 EXPECT_FALSE( | 11373 EXPECT_FALSE( |
11375 session->spdy_session_pool()->HasSession(spdy_session_key_a1)); | 11374 session->spdy_session_pool()->HasSession(spdy_session_key_a1)); |
11376 HttpRequestInfo request3; | 11375 HttpRequestInfo request3; |
11377 request3.method = "GET"; | 11376 request3.method = "GET"; |
11378 request3.url = GURL("http://www.a.com/"); | 11377 request3.url = GURL("http://www.a.com/"); |
11379 request3.load_flags = 0; | 11378 request3.load_flags = 0; |
11380 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 11379 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
11381 | 11380 |
11382 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); | 11381 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); |
11383 EXPECT_EQ(ERR_IO_PENDING, rv); | 11382 EXPECT_EQ(ERR_IO_PENDING, rv); |
11384 EXPECT_EQ(OK, callback.WaitForResult()); | 11383 EXPECT_EQ(OK, callback.WaitForResult()); |
11385 | 11384 |
11386 response = trans->GetResponseInfo(); | 11385 response = trans->GetResponseInfo(); |
11387 ASSERT_TRUE(response != NULL); | 11386 ASSERT_TRUE(response != NULL); |
11388 ASSERT_TRUE(response->headers != NULL); | 11387 ASSERT_TRUE(response->headers.get() != NULL); |
11389 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11388 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
11390 EXPECT_FALSE(response->was_fetched_via_spdy); | 11389 EXPECT_FALSE(response->was_fetched_via_spdy); |
11391 EXPECT_FALSE(response->was_npn_negotiated); | 11390 EXPECT_FALSE(response->was_npn_negotiated); |
11392 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11391 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
11393 EXPECT_EQ("hello!", response_data); | 11392 EXPECT_EQ("hello!", response_data); |
11394 EXPECT_FALSE( | 11393 EXPECT_FALSE( |
11395 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11394 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11396 EXPECT_FALSE( | 11395 EXPECT_FALSE( |
11397 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11396 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11398 | 11397 |
11399 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 11398 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
11400 } | 11399 } |
11401 | 11400 |
11402 } // namespace net | 11401 } // namespace net |
OLD | NEW |