| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // successfully established before the error. | 383 // successfully established before the error. |
| 384 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); | 384 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); |
| 385 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 385 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
| 386 | 386 |
| 387 if (out.rv != OK) | 387 if (out.rv != OK) |
| 388 return out; | 388 return out; |
| 389 | 389 |
| 390 const HttpResponseInfo* response = trans->GetResponseInfo(); | 390 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 391 // Can't use ASSERT_* inside helper functions like this, so | 391 // Can't use ASSERT_* inside helper functions like this, so |
| 392 // return an error. | 392 // return an error. |
| 393 if (response == NULL || response->headers.get() == NULL) { | 393 if (!response || !response->headers) { |
| 394 out.rv = ERR_UNEXPECTED; | 394 out.rv = ERR_UNEXPECTED; |
| 395 return out; | 395 return out; |
| 396 } | 396 } |
| 397 out.status_line = response->headers->GetStatusLine(); | 397 out.status_line = response->headers->GetStatusLine(); |
| 398 | 398 |
| 399 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 399 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
| 400 EXPECT_EQ(80, response->socket_address.port()); | 400 EXPECT_EQ(80, response->socket_address.port()); |
| 401 | 401 |
| 402 bool got_endpoint = | 402 bool got_endpoint = |
| 403 trans->GetRemoteEndpoint(&out.remote_endpoint_after_start); | 403 trans->GetRemoteEndpoint(&out.remote_endpoint_after_start); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1040 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 1041 | 1041 |
| 1042 TestCompletionCallback callback; | 1042 TestCompletionCallback callback; |
| 1043 | 1043 |
| 1044 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1044 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1045 EXPECT_EQ(ERR_IO_PENDING, rv); | 1045 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1046 | 1046 |
| 1047 EXPECT_EQ(OK, callback.WaitForResult()); | 1047 EXPECT_EQ(OK, callback.WaitForResult()); |
| 1048 | 1048 |
| 1049 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1049 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1050 ASSERT_TRUE(response != NULL && response->headers.get() != NULL); | 1050 ASSERT_TRUE(response); |
| 1051 ASSERT_TRUE(response->headers); |
| 1051 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); | 1052 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); |
| 1052 std::string url; | 1053 std::string url; |
| 1053 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 1054 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
| 1054 EXPECT_EQ("http://good.com/", url); | 1055 EXPECT_EQ("http://good.com/", url); |
| 1055 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1056 EXPECT_TRUE(response->proxy_server.IsEmpty()); |
| 1056 } | 1057 } |
| 1057 | 1058 |
| 1058 // Checks that two distinct Location headers result in an error. | 1059 // Checks that two distinct Location headers result in an error. |
| 1059 TEST_P(HttpNetworkTransactionTest, TwoDistinctLocationHeaders) { | 1060 TEST_P(HttpNetworkTransactionTest, TwoDistinctLocationHeaders) { |
| 1060 MockRead data_reads[] = { | 1061 MockRead data_reads[] = { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 | 1105 |
| 1105 TestCompletionCallback callback1; | 1106 TestCompletionCallback callback1; |
| 1106 | 1107 |
| 1107 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1108 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1108 EXPECT_EQ(ERR_IO_PENDING, rv); | 1109 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1109 | 1110 |
| 1110 rv = callback1.WaitForResult(); | 1111 rv = callback1.WaitForResult(); |
| 1111 EXPECT_EQ(OK, rv); | 1112 EXPECT_EQ(OK, rv); |
| 1112 | 1113 |
| 1113 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1114 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1114 ASSERT_TRUE(response != NULL); | 1115 ASSERT_TRUE(response); |
| 1115 | 1116 |
| 1116 // Check that the headers got parsed. | 1117 // Check that the headers got parsed. |
| 1117 EXPECT_TRUE(response->headers.get() != NULL); | 1118 EXPECT_TRUE(response->headers); |
| 1118 EXPECT_EQ(1234, response->headers->GetContentLength()); | 1119 EXPECT_EQ(1234, response->headers->GetContentLength()); |
| 1119 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); | 1120 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); |
| 1120 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1121 EXPECT_TRUE(response->proxy_server.IsEmpty()); |
| 1121 EXPECT_FALSE(proxy_headers_handler.observed_before_proxy_headers_sent()); | 1122 EXPECT_FALSE(proxy_headers_handler.observed_before_proxy_headers_sent()); |
| 1122 | 1123 |
| 1123 std::string server_header; | 1124 std::string server_header; |
| 1124 size_t iter = 0; | 1125 size_t iter = 0; |
| 1125 bool has_server_header = response->headers->EnumerateHeader( | 1126 bool has_server_header = response->headers->EnumerateHeader( |
| 1126 &iter, "Server", &server_header); | 1127 &iter, "Server", &server_header); |
| 1127 EXPECT_TRUE(has_server_header); | 1128 EXPECT_TRUE(has_server_header); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 | 1164 |
| 1164 TestCompletionCallback callback; | 1165 TestCompletionCallback callback; |
| 1165 | 1166 |
| 1166 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1167 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1167 EXPECT_EQ(ERR_IO_PENDING, rv); | 1168 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1168 | 1169 |
| 1169 rv = callback.WaitForResult(); | 1170 rv = callback.WaitForResult(); |
| 1170 EXPECT_EQ(OK, rv); | 1171 EXPECT_EQ(OK, rv); |
| 1171 | 1172 |
| 1172 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1173 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1173 ASSERT_TRUE(response != NULL); | 1174 ASSERT_TRUE(response); |
| 1174 | 1175 |
| 1175 EXPECT_TRUE(response->headers.get() != NULL); | 1176 EXPECT_TRUE(response->headers); |
| 1176 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1177 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 1177 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1178 EXPECT_TRUE(response->proxy_server.IsEmpty()); |
| 1178 | 1179 |
| 1179 std::string response_data; | 1180 std::string response_data; |
| 1180 rv = ReadTransaction(trans.get(), &response_data); | 1181 rv = ReadTransaction(trans.get(), &response_data); |
| 1181 EXPECT_EQ(OK, rv); | 1182 EXPECT_EQ(OK, rv); |
| 1182 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1183 EXPECT_EQ(kExpectedResponseData[i], response_data); |
| 1183 } | 1184 } |
| 1184 } | 1185 } |
| 1185 | 1186 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1210 | 1211 |
| 1211 TestCompletionCallback callback; | 1212 TestCompletionCallback callback; |
| 1212 | 1213 |
| 1213 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1214 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1214 EXPECT_EQ(ERR_IO_PENDING, rv); | 1215 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1215 | 1216 |
| 1216 rv = callback.WaitForResult(); | 1217 rv = callback.WaitForResult(); |
| 1217 EXPECT_EQ(OK, rv); | 1218 EXPECT_EQ(OK, rv); |
| 1218 | 1219 |
| 1219 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1220 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1220 ASSERT_TRUE(response != NULL); | 1221 ASSERT_TRUE(response); |
| 1221 | 1222 |
| 1222 EXPECT_TRUE(response->headers.get() != NULL); | 1223 EXPECT_TRUE(response->headers); |
| 1223 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 1224 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 1224 | 1225 |
| 1225 std::string response_data; | 1226 std::string response_data; |
| 1226 rv = ReadTransaction(trans.get(), &response_data); | 1227 rv = ReadTransaction(trans.get(), &response_data); |
| 1227 EXPECT_EQ(OK, rv); | 1228 EXPECT_EQ(OK, rv); |
| 1228 EXPECT_EQ("hello world", response_data); | 1229 EXPECT_EQ("hello world", response_data); |
| 1229 } | 1230 } |
| 1230 | 1231 |
| 1231 // This test is almost the same as Ignores100 above, but the response contains | 1232 // This test is almost the same as Ignores100 above, but the response contains |
| 1232 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is | 1233 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1252 | 1253 |
| 1253 TestCompletionCallback callback; | 1254 TestCompletionCallback callback; |
| 1254 | 1255 |
| 1255 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1256 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1256 EXPECT_EQ(ERR_IO_PENDING, rv); | 1257 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1257 | 1258 |
| 1258 rv = callback.WaitForResult(); | 1259 rv = callback.WaitForResult(); |
| 1259 EXPECT_EQ(OK, rv); | 1260 EXPECT_EQ(OK, rv); |
| 1260 | 1261 |
| 1261 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1262 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1262 ASSERT_TRUE(response != NULL); | 1263 ASSERT_TRUE(response); |
| 1263 | 1264 |
| 1264 EXPECT_TRUE(response->headers.get() != NULL); | 1265 EXPECT_TRUE(response->headers); |
| 1265 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1266 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 1266 | 1267 |
| 1267 std::string response_data; | 1268 std::string response_data; |
| 1268 rv = ReadTransaction(trans.get(), &response_data); | 1269 rv = ReadTransaction(trans.get(), &response_data); |
| 1269 EXPECT_EQ(OK, rv); | 1270 EXPECT_EQ(OK, rv); |
| 1270 EXPECT_EQ("hello world", response_data); | 1271 EXPECT_EQ("hello world", response_data); |
| 1271 } | 1272 } |
| 1272 | 1273 |
| 1273 TEST_P(HttpNetworkTransactionTest, Incomplete100ThenEOF) { | 1274 TEST_P(HttpNetworkTransactionTest, Incomplete100ThenEOF) { |
| 1274 HttpRequestInfo request; | 1275 HttpRequestInfo request; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 1397 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 1397 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 1398 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
| 1398 if (i == 0) { | 1399 if (i == 0) { |
| 1399 first_socket_log_id = load_timing_info.socket_log_id; | 1400 first_socket_log_id = load_timing_info.socket_log_id; |
| 1400 } else { | 1401 } else { |
| 1401 // The second request should be using a new socket. | 1402 // The second request should be using a new socket. |
| 1402 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); | 1403 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); |
| 1403 } | 1404 } |
| 1404 | 1405 |
| 1405 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1406 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1406 ASSERT_TRUE(response != NULL); | 1407 ASSERT_TRUE(response); |
| 1407 | 1408 |
| 1408 EXPECT_TRUE(response->headers.get() != NULL); | 1409 EXPECT_TRUE(response->headers); |
| 1409 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1410 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 1410 | 1411 |
| 1411 std::string response_data; | 1412 std::string response_data; |
| 1412 rv = ReadTransaction(trans.get(), &response_data); | 1413 rv = ReadTransaction(trans.get(), &response_data); |
| 1413 EXPECT_EQ(OK, rv); | 1414 EXPECT_EQ(OK, rv); |
| 1414 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1415 EXPECT_EQ(kExpectedResponseData[i], response_data); |
| 1415 } | 1416 } |
| 1416 } | 1417 } |
| 1417 | 1418 |
| 1418 void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( | 1419 void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 rv = callback.WaitForResult(); | 1514 rv = callback.WaitForResult(); |
| 1514 EXPECT_EQ(OK, rv); | 1515 EXPECT_EQ(OK, rv); |
| 1515 | 1516 |
| 1516 LoadTimingInfo load_timing_info; | 1517 LoadTimingInfo load_timing_info; |
| 1517 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 1518 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 1518 TestLoadTimingNotReused( | 1519 TestLoadTimingNotReused( |
| 1519 load_timing_info, | 1520 load_timing_info, |
| 1520 CONNECT_TIMING_HAS_DNS_TIMES|CONNECT_TIMING_HAS_SSL_TIMES); | 1521 CONNECT_TIMING_HAS_DNS_TIMES|CONNECT_TIMING_HAS_SSL_TIMES); |
| 1521 | 1522 |
| 1522 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1523 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1523 ASSERT_TRUE(response != NULL); | 1524 ASSERT_TRUE(response); |
| 1524 | 1525 |
| 1525 EXPECT_TRUE(response->headers.get() != NULL); | 1526 EXPECT_TRUE(response->headers); |
| 1526 if (response->was_fetched_via_spdy) { | 1527 if (response->was_fetched_via_spdy) { |
| 1527 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 1528 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 1528 } else { | 1529 } else { |
| 1529 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1530 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 1530 } | 1531 } |
| 1531 | 1532 |
| 1532 std::string response_data; | 1533 std::string response_data; |
| 1533 rv = ReadTransaction(trans.get(), &response_data); | 1534 rv = ReadTransaction(trans.get(), &response_data); |
| 1534 EXPECT_EQ(OK, rv); | 1535 EXPECT_EQ(OK, rv); |
| 1535 EXPECT_EQ(kHttpData, response_data); | 1536 EXPECT_EQ(kHttpData, response_data); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 EXPECT_EQ(ERR_IO_PENDING, rv); | 1702 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1702 base::MessageLoop::current()->RunUntilIdle(); | 1703 base::MessageLoop::current()->RunUntilIdle(); |
| 1703 | 1704 |
| 1704 // Should have deferred for network start. | 1705 // Should have deferred for network start. |
| 1705 EXPECT_TRUE(net_start_handler.observed_before_network_start()); | 1706 EXPECT_TRUE(net_start_handler.observed_before_network_start()); |
| 1706 EXPECT_EQ(LOAD_STATE_WAITING_FOR_DELEGATE, trans->GetLoadState()); | 1707 EXPECT_EQ(LOAD_STATE_WAITING_FOR_DELEGATE, trans->GetLoadState()); |
| 1707 | 1708 |
| 1708 trans->ResumeNetworkStart(); | 1709 trans->ResumeNetworkStart(); |
| 1709 rv = callback.WaitForResult(); | 1710 rv = callback.WaitForResult(); |
| 1710 EXPECT_EQ(OK, rv); | 1711 EXPECT_EQ(OK, rv); |
| 1711 EXPECT_TRUE(trans->GetResponseInfo() != NULL); | 1712 EXPECT_TRUE(trans->GetResponseInfo()); |
| 1712 | 1713 |
| 1713 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1714 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
| 1714 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 1715 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
| 1715 if (rv == ERR_IO_PENDING) | 1716 if (rv == ERR_IO_PENDING) |
| 1716 rv = callback.WaitForResult(); | 1717 rv = callback.WaitForResult(); |
| 1717 EXPECT_EQ(5, rv); | 1718 EXPECT_EQ(5, rv); |
| 1718 trans.reset(); | 1719 trans.reset(); |
| 1719 } | 1720 } |
| 1720 | 1721 |
| 1721 // Test that network use can be deferred and canceled. | 1722 // Test that network use can be deferred and canceled. |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 LoadTimingInfo load_timing_info1; | 2038 LoadTimingInfo load_timing_info1; |
| 2038 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info1)); | 2039 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info1)); |
| 2039 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_DNS_TIMES); | 2040 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_DNS_TIMES); |
| 2040 | 2041 |
| 2041 int64_t writes_size1 = CountWriteBytes(data_writes1, arraysize(data_writes1)); | 2042 int64_t writes_size1 = CountWriteBytes(data_writes1, arraysize(data_writes1)); |
| 2042 EXPECT_EQ(writes_size1, trans->GetTotalSentBytes()); | 2043 EXPECT_EQ(writes_size1, trans->GetTotalSentBytes()); |
| 2043 int64_t reads_size1 = CountReadBytes(data_reads1, arraysize(data_reads1)); | 2044 int64_t reads_size1 = CountReadBytes(data_reads1, arraysize(data_reads1)); |
| 2044 EXPECT_EQ(reads_size1, trans->GetTotalReceivedBytes()); | 2045 EXPECT_EQ(reads_size1, trans->GetTotalReceivedBytes()); |
| 2045 | 2046 |
| 2046 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2047 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2047 ASSERT_TRUE(response != NULL); | 2048 ASSERT_TRUE(response); |
| 2048 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 2049 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 2049 | 2050 |
| 2050 TestCompletionCallback callback2; | 2051 TestCompletionCallback callback2; |
| 2051 | 2052 |
| 2052 rv = trans->RestartWithAuth( | 2053 rv = trans->RestartWithAuth( |
| 2053 AuthCredentials(kFoo, kBar), callback2.callback()); | 2054 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2054 EXPECT_EQ(ERR_IO_PENDING, rv); | 2055 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2055 | 2056 |
| 2056 rv = callback2.WaitForResult(); | 2057 rv = callback2.WaitForResult(); |
| 2057 EXPECT_EQ(OK, rv); | 2058 EXPECT_EQ(OK, rv); |
| 2058 | 2059 |
| 2059 LoadTimingInfo load_timing_info2; | 2060 LoadTimingInfo load_timing_info2; |
| 2060 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info2)); | 2061 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info2)); |
| 2061 TestLoadTimingNotReused(load_timing_info2, CONNECT_TIMING_HAS_DNS_TIMES); | 2062 TestLoadTimingNotReused(load_timing_info2, CONNECT_TIMING_HAS_DNS_TIMES); |
| 2062 // The load timing after restart should have a new socket ID, and times after | 2063 // The load timing after restart should have a new socket ID, and times after |
| 2063 // those of the first load timing. | 2064 // those of the first load timing. |
| 2064 EXPECT_LE(load_timing_info1.receive_headers_end, | 2065 EXPECT_LE(load_timing_info1.receive_headers_end, |
| 2065 load_timing_info2.connect_timing.connect_start); | 2066 load_timing_info2.connect_timing.connect_start); |
| 2066 EXPECT_NE(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 2067 EXPECT_NE(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
| 2067 | 2068 |
| 2068 int64_t writes_size2 = CountWriteBytes(data_writes2, arraysize(data_writes2)); | 2069 int64_t writes_size2 = CountWriteBytes(data_writes2, arraysize(data_writes2)); |
| 2069 EXPECT_EQ(writes_size1 + writes_size2, trans->GetTotalSentBytes()); | 2070 EXPECT_EQ(writes_size1 + writes_size2, trans->GetTotalSentBytes()); |
| 2070 int64_t reads_size2 = CountReadBytes(data_reads2, arraysize(data_reads2)); | 2071 int64_t reads_size2 = CountReadBytes(data_reads2, arraysize(data_reads2)); |
| 2071 EXPECT_EQ(reads_size1 + reads_size2, trans->GetTotalReceivedBytes()); | 2072 EXPECT_EQ(reads_size1 + reads_size2, trans->GetTotalReceivedBytes()); |
| 2072 | 2073 |
| 2073 response = trans->GetResponseInfo(); | 2074 response = trans->GetResponseInfo(); |
| 2074 ASSERT_TRUE(response != NULL); | 2075 ASSERT_TRUE(response); |
| 2075 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2076 EXPECT_FALSE(response->auth_challenge); |
| 2076 EXPECT_EQ(100, response->headers->GetContentLength()); | 2077 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 2077 } | 2078 } |
| 2078 | 2079 |
| 2079 // Test the request-challenge-retry sequence for basic auth. | 2080 // Test the request-challenge-retry sequence for basic auth. |
| 2080 // (basic auth is the easiest to mock, because it has no randomness). | 2081 // (basic auth is the easiest to mock, because it has no randomness). |
| 2081 TEST_P(HttpNetworkTransactionTest, BasicAuthWithAddressChange) { | 2082 TEST_P(HttpNetworkTransactionTest, BasicAuthWithAddressChange) { |
| 2082 HttpRequestInfo request; | 2083 HttpRequestInfo request; |
| 2083 request.method = "GET"; | 2084 request.method = "GET"; |
| 2084 request.url = GURL("http://www.example.org/"); | 2085 request.url = GURL("http://www.example.org/"); |
| 2085 request.load_flags = 0; | 2086 request.load_flags = 0; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 load_timing_info2.connect_timing.connect_start); | 2178 load_timing_info2.connect_timing.connect_start); |
| 2178 EXPECT_NE(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 2179 EXPECT_NE(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
| 2179 | 2180 |
| 2180 int64_t writes_size2 = CountWriteBytes(data_writes2, arraysize(data_writes2)); | 2181 int64_t writes_size2 = CountWriteBytes(data_writes2, arraysize(data_writes2)); |
| 2181 EXPECT_EQ(writes_size1 + writes_size2, trans->GetTotalSentBytes()); | 2182 EXPECT_EQ(writes_size1 + writes_size2, trans->GetTotalSentBytes()); |
| 2182 int64_t reads_size2 = CountReadBytes(data_reads2, arraysize(data_reads2)); | 2183 int64_t reads_size2 = CountReadBytes(data_reads2, arraysize(data_reads2)); |
| 2183 EXPECT_EQ(reads_size1 + reads_size2, trans->GetTotalReceivedBytes()); | 2184 EXPECT_EQ(reads_size1 + reads_size2, trans->GetTotalReceivedBytes()); |
| 2184 | 2185 |
| 2185 response = trans->GetResponseInfo(); | 2186 response = trans->GetResponseInfo(); |
| 2186 ASSERT_TRUE(response); | 2187 ASSERT_TRUE(response); |
| 2187 EXPECT_FALSE(response->auth_challenge.get()); | 2188 EXPECT_FALSE(response->auth_challenge); |
| 2188 EXPECT_EQ(100, response->headers->GetContentLength()); | 2189 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 2189 | 2190 |
| 2190 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); | 2191 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); |
| 2191 ASSERT_FALSE(endpoint.address().empty()); | 2192 ASSERT_FALSE(endpoint.address().empty()); |
| 2192 EXPECT_EQ("127.0.0.2:80", endpoint.ToString()); | 2193 EXPECT_EQ("127.0.0.2:80", endpoint.ToString()); |
| 2193 } | 2194 } |
| 2194 | 2195 |
| 2195 TEST_P(HttpNetworkTransactionTest, DoNotSendAuth) { | 2196 TEST_P(HttpNetworkTransactionTest, DoNotSendAuth) { |
| 2196 HttpRequestInfo request; | 2197 HttpRequestInfo request; |
| 2197 request.method = "GET"; | 2198 request.method = "GET"; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2228 | 2229 |
| 2229 rv = callback.WaitForResult(); | 2230 rv = callback.WaitForResult(); |
| 2230 EXPECT_EQ(0, rv); | 2231 EXPECT_EQ(0, rv); |
| 2231 | 2232 |
| 2232 int64_t writes_size = CountWriteBytes(data_writes, arraysize(data_writes)); | 2233 int64_t writes_size = CountWriteBytes(data_writes, arraysize(data_writes)); |
| 2233 EXPECT_EQ(writes_size, trans->GetTotalSentBytes()); | 2234 EXPECT_EQ(writes_size, trans->GetTotalSentBytes()); |
| 2234 int64_t reads_size = CountReadBytes(data_reads, arraysize(data_reads)); | 2235 int64_t reads_size = CountReadBytes(data_reads, arraysize(data_reads)); |
| 2235 EXPECT_EQ(reads_size, trans->GetTotalReceivedBytes()); | 2236 EXPECT_EQ(reads_size, trans->GetTotalReceivedBytes()); |
| 2236 | 2237 |
| 2237 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2238 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2238 ASSERT_TRUE(response != NULL); | 2239 ASSERT_TRUE(response); |
| 2239 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2240 EXPECT_FALSE(response->auth_challenge); |
| 2240 } | 2241 } |
| 2241 | 2242 |
| 2242 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 2243 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| 2243 // connection. | 2244 // connection. |
| 2244 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAlive) { | 2245 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAlive) { |
| 2245 // On the second pass, the body read of the auth challenge is synchronous, so | 2246 // On the second pass, the body read of the auth challenge is synchronous, so |
| 2246 // IsConnectedAndIdle returns false. The socket should still be drained and | 2247 // IsConnectedAndIdle returns false. The socket should still be drained and |
| 2247 // reused. See http://crbug.com/544255. | 2248 // reused. See http://crbug.com/544255. |
| 2248 for (int i = 0; i < 2; ++i) { | 2249 for (int i = 0; i < 2; ++i) { |
| 2249 HttpRequestInfo request; | 2250 HttpRequestInfo request; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2387 | 2388 |
| 2388 std::unique_ptr<HttpTransaction> trans( | 2389 std::unique_ptr<HttpTransaction> trans( |
| 2389 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 2390 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 2390 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 2391 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 2391 EXPECT_EQ(ERR_IO_PENDING, rv); | 2392 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2392 | 2393 |
| 2393 rv = callback1.WaitForResult(); | 2394 rv = callback1.WaitForResult(); |
| 2394 EXPECT_EQ(OK, rv); | 2395 EXPECT_EQ(OK, rv); |
| 2395 | 2396 |
| 2396 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2397 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2397 ASSERT_TRUE(response != NULL); | 2398 ASSERT_TRUE(response); |
| 2398 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 2399 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 2399 | 2400 |
| 2400 TestCompletionCallback callback2; | 2401 TestCompletionCallback callback2; |
| 2401 | 2402 |
| 2402 rv = trans->RestartWithAuth( | 2403 rv = trans->RestartWithAuth( |
| 2403 AuthCredentials(kFoo, kBar), callback2.callback()); | 2404 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2404 EXPECT_EQ(ERR_IO_PENDING, rv); | 2405 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2405 | 2406 |
| 2406 rv = callback2.WaitForResult(); | 2407 rv = callback2.WaitForResult(); |
| 2407 EXPECT_EQ(OK, rv); | 2408 EXPECT_EQ(OK, rv); |
| 2408 | 2409 |
| 2409 response = trans->GetResponseInfo(); | 2410 response = trans->GetResponseInfo(); |
| 2410 ASSERT_TRUE(response != NULL); | 2411 ASSERT_TRUE(response); |
| 2411 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2412 EXPECT_FALSE(response->auth_challenge); |
| 2412 EXPECT_EQ(5, response->headers->GetContentLength()); | 2413 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 2413 } | 2414 } |
| 2414 | 2415 |
| 2415 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 2416 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| 2416 // connection and with a large response body to drain. | 2417 // connection and with a large response body to drain. |
| 2417 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { | 2418 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { |
| 2418 HttpRequestInfo request; | 2419 HttpRequestInfo request; |
| 2419 request.method = "GET"; | 2420 request.method = "GET"; |
| 2420 request.url = GURL("http://www.example.org/"); | 2421 request.url = GURL("http://www.example.org/"); |
| 2421 request.load_flags = 0; | 2422 request.load_flags = 0; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2473 | 2474 |
| 2474 std::unique_ptr<HttpTransaction> trans( | 2475 std::unique_ptr<HttpTransaction> trans( |
| 2475 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 2476 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 2476 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 2477 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 2477 EXPECT_EQ(ERR_IO_PENDING, rv); | 2478 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2478 | 2479 |
| 2479 rv = callback1.WaitForResult(); | 2480 rv = callback1.WaitForResult(); |
| 2480 EXPECT_EQ(OK, rv); | 2481 EXPECT_EQ(OK, rv); |
| 2481 | 2482 |
| 2482 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2483 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2483 ASSERT_TRUE(response != NULL); | 2484 ASSERT_TRUE(response); |
| 2484 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 2485 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 2485 | 2486 |
| 2486 TestCompletionCallback callback2; | 2487 TestCompletionCallback callback2; |
| 2487 | 2488 |
| 2488 rv = trans->RestartWithAuth( | 2489 rv = trans->RestartWithAuth( |
| 2489 AuthCredentials(kFoo, kBar), callback2.callback()); | 2490 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2490 EXPECT_EQ(ERR_IO_PENDING, rv); | 2491 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2491 | 2492 |
| 2492 rv = callback2.WaitForResult(); | 2493 rv = callback2.WaitForResult(); |
| 2493 EXPECT_EQ(OK, rv); | 2494 EXPECT_EQ(OK, rv); |
| 2494 | 2495 |
| 2495 response = trans->GetResponseInfo(); | 2496 response = trans->GetResponseInfo(); |
| 2496 ASSERT_TRUE(response != NULL); | 2497 ASSERT_TRUE(response); |
| 2497 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2498 EXPECT_FALSE(response->auth_challenge); |
| 2498 EXPECT_EQ(5, response->headers->GetContentLength()); | 2499 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 2499 } | 2500 } |
| 2500 | 2501 |
| 2501 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 2502 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| 2502 // connection, but the server gets impatient and closes the connection. | 2503 // connection, but the server gets impatient and closes the connection. |
| 2503 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { | 2504 TEST_P(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { |
| 2504 HttpRequestInfo request; | 2505 HttpRequestInfo request; |
| 2505 request.method = "GET"; | 2506 request.method = "GET"; |
| 2506 request.url = GURL("http://www.example.org/"); | 2507 request.url = GURL("http://www.example.org/"); |
| 2507 request.load_flags = 0; | 2508 request.load_flags = 0; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 | 2563 |
| 2563 std::unique_ptr<HttpTransaction> trans( | 2564 std::unique_ptr<HttpTransaction> trans( |
| 2564 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 2565 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 2565 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 2566 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 2566 EXPECT_EQ(ERR_IO_PENDING, rv); | 2567 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2567 | 2568 |
| 2568 rv = callback1.WaitForResult(); | 2569 rv = callback1.WaitForResult(); |
| 2569 EXPECT_EQ(OK, rv); | 2570 EXPECT_EQ(OK, rv); |
| 2570 | 2571 |
| 2571 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2572 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2572 ASSERT_TRUE(response != NULL); | 2573 ASSERT_TRUE(response); |
| 2573 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 2574 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 2574 | 2575 |
| 2575 TestCompletionCallback callback2; | 2576 TestCompletionCallback callback2; |
| 2576 | 2577 |
| 2577 rv = trans->RestartWithAuth( | 2578 rv = trans->RestartWithAuth( |
| 2578 AuthCredentials(kFoo, kBar), callback2.callback()); | 2579 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2579 EXPECT_EQ(ERR_IO_PENDING, rv); | 2580 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2580 | 2581 |
| 2581 rv = callback2.WaitForResult(); | 2582 rv = callback2.WaitForResult(); |
| 2582 EXPECT_EQ(OK, rv); | 2583 EXPECT_EQ(OK, rv); |
| 2583 | 2584 |
| 2584 response = trans->GetResponseInfo(); | 2585 response = trans->GetResponseInfo(); |
| 2585 ASSERT_TRUE(response != NULL); | 2586 ASSERT_TRUE(response); |
| 2586 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2587 EXPECT_FALSE(response->auth_challenge); |
| 2587 EXPECT_EQ(5, response->headers->GetContentLength()); | 2588 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 2588 } | 2589 } |
| 2589 | 2590 |
| 2590 // Test the request-challenge-retry sequence for basic auth, over a connection | 2591 // Test the request-challenge-retry sequence for basic auth, over a connection |
| 2591 // that requires a restart when setting up an SSL tunnel. | 2592 // that requires a restart when setting up an SSL tunnel. |
| 2592 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAliveHttp10) { | 2593 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAliveHttp10) { |
| 2593 HttpRequestInfo request; | 2594 HttpRequestInfo request; |
| 2594 request.method = "GET"; | 2595 request.method = "GET"; |
| 2595 request.url = GURL("https://www.example.org/"); | 2596 request.url = GURL("https://www.example.org/"); |
| 2596 // when the no authentication data flag is set. | 2597 // when the no authentication data flag is set. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2664 TestNetLogEntry::List entries; | 2665 TestNetLogEntry::List entries; |
| 2665 log.GetEntries(&entries); | 2666 log.GetEntries(&entries); |
| 2666 size_t pos = ExpectLogContainsSomewhere( | 2667 size_t pos = ExpectLogContainsSomewhere( |
| 2667 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2668 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 2668 NetLog::PHASE_NONE); | 2669 NetLog::PHASE_NONE); |
| 2669 ExpectLogContainsSomewhere( | 2670 ExpectLogContainsSomewhere( |
| 2670 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2671 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 2671 NetLog::PHASE_NONE); | 2672 NetLog::PHASE_NONE); |
| 2672 | 2673 |
| 2673 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2674 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2674 ASSERT_TRUE(response != NULL); | 2675 ASSERT_TRUE(response); |
| 2675 EXPECT_FALSE(response->headers->IsKeepAlive()); | 2676 EXPECT_FALSE(response->headers->IsKeepAlive()); |
| 2676 ASSERT_FALSE(response->headers.get() == NULL); | 2677 ASSERT_TRUE(response->headers); |
| 2677 EXPECT_EQ(407, response->headers->response_code()); | 2678 EXPECT_EQ(407, response->headers->response_code()); |
| 2678 EXPECT_TRUE(HttpVersion(1, 0) == response->headers->GetHttpVersion()); | 2679 EXPECT_TRUE(HttpVersion(1, 0) == response->headers->GetHttpVersion()); |
| 2679 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2680 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2680 | 2681 |
| 2681 LoadTimingInfo load_timing_info; | 2682 LoadTimingInfo load_timing_info; |
| 2682 // CONNECT requests and responses are handled at the connect job level, so | 2683 // CONNECT requests and responses are handled at the connect job level, so |
| 2683 // the transaction does not yet have a connection. | 2684 // the transaction does not yet have a connection. |
| 2684 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); | 2685 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 2685 | 2686 |
| 2686 TestCompletionCallback callback2; | 2687 TestCompletionCallback callback2; |
| 2687 | 2688 |
| 2688 rv = | 2689 rv = |
| 2689 trans->RestartWithAuth(AuthCredentials(kFoo, kBar), callback2.callback()); | 2690 trans->RestartWithAuth(AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2690 EXPECT_EQ(ERR_IO_PENDING, rv); | 2691 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2691 | 2692 |
| 2692 rv = callback2.WaitForResult(); | 2693 rv = callback2.WaitForResult(); |
| 2693 EXPECT_EQ(OK, rv); | 2694 EXPECT_EQ(OK, rv); |
| 2694 | 2695 |
| 2695 response = trans->GetResponseInfo(); | 2696 response = trans->GetResponseInfo(); |
| 2696 ASSERT_TRUE(response != NULL); | 2697 ASSERT_TRUE(response); |
| 2697 | 2698 |
| 2698 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2699 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 2699 EXPECT_EQ(200, response->headers->response_code()); | 2700 EXPECT_EQ(200, response->headers->response_code()); |
| 2700 EXPECT_EQ(5, response->headers->GetContentLength()); | 2701 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 2701 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2702 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2702 | 2703 |
| 2703 // The password prompt info should not be set. | 2704 // The password prompt info should not be set. |
| 2704 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2705 EXPECT_FALSE(response->auth_challenge); |
| 2705 | 2706 |
| 2706 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2707 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 2707 TestLoadTimingNotReusedWithPac(load_timing_info, | 2708 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 2708 CONNECT_TIMING_HAS_SSL_TIMES); | 2709 CONNECT_TIMING_HAS_SSL_TIMES); |
| 2709 | 2710 |
| 2710 trans.reset(); | 2711 trans.reset(); |
| 2711 session->CloseAllConnections(); | 2712 session->CloseAllConnections(); |
| 2712 } | 2713 } |
| 2713 | 2714 |
| 2714 // Test the request-challenge-retry sequence for basic auth, over a connection | 2715 // Test the request-challenge-retry sequence for basic auth, over a connection |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2788 log.GetEntries(&entries); | 2789 log.GetEntries(&entries); |
| 2789 size_t pos = ExpectLogContainsSomewhere( | 2790 size_t pos = ExpectLogContainsSomewhere( |
| 2790 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2791 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 2791 NetLog::PHASE_NONE); | 2792 NetLog::PHASE_NONE); |
| 2792 ExpectLogContainsSomewhere( | 2793 ExpectLogContainsSomewhere( |
| 2793 entries, pos, | 2794 entries, pos, |
| 2794 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2795 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 2795 NetLog::PHASE_NONE); | 2796 NetLog::PHASE_NONE); |
| 2796 | 2797 |
| 2797 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2798 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2798 ASSERT_TRUE(response != NULL); | 2799 ASSERT_TRUE(response); |
| 2799 EXPECT_FALSE(response->headers->IsKeepAlive()); | 2800 EXPECT_FALSE(response->headers->IsKeepAlive()); |
| 2800 ASSERT_FALSE(response->headers.get() == NULL); | 2801 ASSERT_TRUE(response->headers); |
| 2801 EXPECT_EQ(407, response->headers->response_code()); | 2802 EXPECT_EQ(407, response->headers->response_code()); |
| 2802 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2803 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2803 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2804 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2804 | 2805 |
| 2805 LoadTimingInfo load_timing_info; | 2806 LoadTimingInfo load_timing_info; |
| 2806 // CONNECT requests and responses are handled at the connect job level, so | 2807 // CONNECT requests and responses are handled at the connect job level, so |
| 2807 // the transaction does not yet have a connection. | 2808 // the transaction does not yet have a connection. |
| 2808 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); | 2809 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 2809 | 2810 |
| 2810 TestCompletionCallback callback2; | 2811 TestCompletionCallback callback2; |
| 2811 | 2812 |
| 2812 rv = trans->RestartWithAuth( | 2813 rv = trans->RestartWithAuth( |
| 2813 AuthCredentials(kFoo, kBar), callback2.callback()); | 2814 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2814 EXPECT_EQ(ERR_IO_PENDING, rv); | 2815 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2815 | 2816 |
| 2816 rv = callback2.WaitForResult(); | 2817 rv = callback2.WaitForResult(); |
| 2817 EXPECT_EQ(OK, rv); | 2818 EXPECT_EQ(OK, rv); |
| 2818 | 2819 |
| 2819 response = trans->GetResponseInfo(); | 2820 response = trans->GetResponseInfo(); |
| 2820 ASSERT_TRUE(response != NULL); | 2821 ASSERT_TRUE(response); |
| 2821 | 2822 |
| 2822 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2823 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 2823 EXPECT_EQ(200, response->headers->response_code()); | 2824 EXPECT_EQ(200, response->headers->response_code()); |
| 2824 EXPECT_EQ(5, response->headers->GetContentLength()); | 2825 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 2825 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2826 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2826 | 2827 |
| 2827 // The password prompt info should not be set. | 2828 // The password prompt info should not be set. |
| 2828 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2829 EXPECT_FALSE(response->auth_challenge); |
| 2829 | 2830 |
| 2830 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 2831 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 2831 TestLoadTimingNotReusedWithPac(load_timing_info, | 2832 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 2832 CONNECT_TIMING_HAS_SSL_TIMES); | 2833 CONNECT_TIMING_HAS_SSL_TIMES); |
| 2833 | 2834 |
| 2834 trans.reset(); | 2835 trans.reset(); |
| 2835 session->CloseAllConnections(); | 2836 session->CloseAllConnections(); |
| 2836 } | 2837 } |
| 2837 | 2838 |
| 2838 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 2839 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3582 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3583 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3583 EXPECT_EQ(OK, callback.GetResult(rv)); | 3584 EXPECT_EQ(OK, callback.GetResult(rv)); |
| 3584 | 3585 |
| 3585 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3586 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3586 ASSERT_TRUE(response); | 3587 ASSERT_TRUE(response); |
| 3587 ASSERT_TRUE(response->headers); | 3588 ASSERT_TRUE(response->headers); |
| 3588 EXPECT_FALSE(response->headers->IsKeepAlive()); | 3589 EXPECT_FALSE(response->headers->IsKeepAlive()); |
| 3589 EXPECT_EQ(407, response->headers->response_code()); | 3590 EXPECT_EQ(407, response->headers->response_code()); |
| 3590 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 3591 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 3591 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3592 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 3592 EXPECT_FALSE(response->auth_challenge.get()); | 3593 EXPECT_FALSE(response->auth_challenge); |
| 3593 | 3594 |
| 3594 LoadTimingInfo load_timing_info; | 3595 LoadTimingInfo load_timing_info; |
| 3595 // CONNECT requests and responses are handled at the connect job level, so | 3596 // CONNECT requests and responses are handled at the connect job level, so |
| 3596 // the transaction does not yet have a connection. | 3597 // the transaction does not yet have a connection. |
| 3597 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); | 3598 EXPECT_FALSE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 3598 | 3599 |
| 3599 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); | 3600 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); |
| 3600 EXPECT_EQ(OK, callback.GetResult(rv)); | 3601 EXPECT_EQ(OK, callback.GetResult(rv)); |
| 3601 response = trans->GetResponseInfo(); | 3602 response = trans->GetResponseInfo(); |
| 3602 ASSERT_TRUE(response); | 3603 ASSERT_TRUE(response); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3721 | 3722 |
| 3722 response = trans->GetResponseInfo(); | 3723 response = trans->GetResponseInfo(); |
| 3723 ASSERT_TRUE(response); | 3724 ASSERT_TRUE(response); |
| 3724 ASSERT_TRUE(response->headers); | 3725 ASSERT_TRUE(response->headers); |
| 3725 EXPECT_TRUE(response->headers->IsKeepAlive()); | 3726 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 3726 EXPECT_EQ(200, response->headers->response_code()); | 3727 EXPECT_EQ(200, response->headers->response_code()); |
| 3727 EXPECT_EQ(5, response->headers->GetContentLength()); | 3728 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 3728 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 3729 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 3729 | 3730 |
| 3730 // The password prompt info should not be set. | 3731 // The password prompt info should not be set. |
| 3731 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3732 EXPECT_FALSE(response->auth_challenge); |
| 3732 | 3733 |
| 3733 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 3734 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 3734 TestLoadTimingNotReusedWithPac(load_timing_info, | 3735 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 3735 CONNECT_TIMING_HAS_SSL_TIMES); | 3736 CONNECT_TIMING_HAS_SSL_TIMES); |
| 3736 | 3737 |
| 3737 trans.reset(); | 3738 trans.reset(); |
| 3738 session->CloseAllConnections(); | 3739 session->CloseAllConnections(); |
| 3739 } | 3740 } |
| 3740 | 3741 |
| 3741 // Test a proxy auth scheme that allows default credentials and a proxy server | 3742 // Test a proxy auth scheme that allows default credentials and a proxy server |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3995 std::unique_ptr<HttpTransaction> trans1( | 3996 std::unique_ptr<HttpTransaction> trans1( |
| 3996 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 3997 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 3997 | 3998 |
| 3998 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 3999 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
| 3999 EXPECT_EQ(ERR_IO_PENDING, rv); | 4000 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4000 | 4001 |
| 4001 rv = callback1.WaitForResult(); | 4002 rv = callback1.WaitForResult(); |
| 4002 EXPECT_EQ(OK, rv); | 4003 EXPECT_EQ(OK, rv); |
| 4003 | 4004 |
| 4004 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 4005 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 4005 ASSERT_TRUE(response1 != NULL); | 4006 ASSERT_TRUE(response1); |
| 4006 ASSERT_TRUE(response1->headers.get() != NULL); | 4007 ASSERT_TRUE(response1->headers); |
| 4007 EXPECT_EQ(1, response1->headers->GetContentLength()); | 4008 EXPECT_EQ(1, response1->headers->GetContentLength()); |
| 4008 | 4009 |
| 4009 LoadTimingInfo load_timing_info1; | 4010 LoadTimingInfo load_timing_info1; |
| 4010 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 4011 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
| 4011 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); | 4012 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); |
| 4012 | 4013 |
| 4013 trans1.reset(); | 4014 trans1.reset(); |
| 4014 | 4015 |
| 4015 TestCompletionCallback callback2; | 4016 TestCompletionCallback callback2; |
| 4016 std::unique_ptr<HttpTransaction> trans2( | 4017 std::unique_ptr<HttpTransaction> trans2( |
| 4017 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4018 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4018 | 4019 |
| 4019 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 4020 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
| 4020 EXPECT_EQ(ERR_IO_PENDING, rv); | 4021 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4021 | 4022 |
| 4022 rv = callback2.WaitForResult(); | 4023 rv = callback2.WaitForResult(); |
| 4023 EXPECT_EQ(OK, rv); | 4024 EXPECT_EQ(OK, rv); |
| 4024 | 4025 |
| 4025 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 4026 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 4026 ASSERT_TRUE(response2 != NULL); | 4027 ASSERT_TRUE(response2); |
| 4027 ASSERT_TRUE(response2->headers.get() != NULL); | 4028 ASSERT_TRUE(response2->headers); |
| 4028 EXPECT_EQ(2, response2->headers->GetContentLength()); | 4029 EXPECT_EQ(2, response2->headers->GetContentLength()); |
| 4029 | 4030 |
| 4030 LoadTimingInfo load_timing_info2; | 4031 LoadTimingInfo load_timing_info2; |
| 4031 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 4032 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
| 4032 TestLoadTimingReused(load_timing_info2); | 4033 TestLoadTimingReused(load_timing_info2); |
| 4033 | 4034 |
| 4034 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 4035 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
| 4035 | 4036 |
| 4036 trans2.reset(); | 4037 trans2.reset(); |
| 4037 session->CloseAllConnections(); | 4038 session->CloseAllConnections(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4093 std::unique_ptr<HttpTransaction> trans1( | 4094 std::unique_ptr<HttpTransaction> trans1( |
| 4094 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4095 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4095 | 4096 |
| 4096 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 4097 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
| 4097 EXPECT_EQ(ERR_IO_PENDING, rv); | 4098 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4098 | 4099 |
| 4099 rv = callback1.WaitForResult(); | 4100 rv = callback1.WaitForResult(); |
| 4100 EXPECT_EQ(OK, rv); | 4101 EXPECT_EQ(OK, rv); |
| 4101 | 4102 |
| 4102 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 4103 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 4103 ASSERT_TRUE(response1 != NULL); | 4104 ASSERT_TRUE(response1); |
| 4104 ASSERT_TRUE(response1->headers.get() != NULL); | 4105 ASSERT_TRUE(response1->headers); |
| 4105 EXPECT_EQ(1, response1->headers->GetContentLength()); | 4106 EXPECT_EQ(1, response1->headers->GetContentLength()); |
| 4106 | 4107 |
| 4107 LoadTimingInfo load_timing_info1; | 4108 LoadTimingInfo load_timing_info1; |
| 4108 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 4109 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
| 4109 TestLoadTimingNotReusedWithPac(load_timing_info1, | 4110 TestLoadTimingNotReusedWithPac(load_timing_info1, |
| 4110 CONNECT_TIMING_HAS_SSL_TIMES); | 4111 CONNECT_TIMING_HAS_SSL_TIMES); |
| 4111 | 4112 |
| 4112 trans1.reset(); | 4113 trans1.reset(); |
| 4113 | 4114 |
| 4114 TestCompletionCallback callback2; | 4115 TestCompletionCallback callback2; |
| 4115 std::unique_ptr<HttpTransaction> trans2( | 4116 std::unique_ptr<HttpTransaction> trans2( |
| 4116 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4117 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4117 | 4118 |
| 4118 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 4119 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
| 4119 EXPECT_EQ(ERR_IO_PENDING, rv); | 4120 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4120 | 4121 |
| 4121 rv = callback2.WaitForResult(); | 4122 rv = callback2.WaitForResult(); |
| 4122 EXPECT_EQ(OK, rv); | 4123 EXPECT_EQ(OK, rv); |
| 4123 | 4124 |
| 4124 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 4125 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 4125 ASSERT_TRUE(response2 != NULL); | 4126 ASSERT_TRUE(response2); |
| 4126 ASSERT_TRUE(response2->headers.get() != NULL); | 4127 ASSERT_TRUE(response2->headers); |
| 4127 EXPECT_EQ(2, response2->headers->GetContentLength()); | 4128 EXPECT_EQ(2, response2->headers->GetContentLength()); |
| 4128 | 4129 |
| 4129 LoadTimingInfo load_timing_info2; | 4130 LoadTimingInfo load_timing_info2; |
| 4130 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 4131 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
| 4131 TestLoadTimingReusedWithPac(load_timing_info2); | 4132 TestLoadTimingReusedWithPac(load_timing_info2); |
| 4132 | 4133 |
| 4133 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 4134 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
| 4134 | 4135 |
| 4135 trans2.reset(); | 4136 trans2.reset(); |
| 4136 session->CloseAllConnections(); | 4137 session->CloseAllConnections(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4179 | 4180 |
| 4180 rv = callback1.WaitForResult(); | 4181 rv = callback1.WaitForResult(); |
| 4181 EXPECT_EQ(OK, rv); | 4182 EXPECT_EQ(OK, rv); |
| 4182 | 4183 |
| 4183 LoadTimingInfo load_timing_info; | 4184 LoadTimingInfo load_timing_info; |
| 4184 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 4185 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 4185 TestLoadTimingNotReused(load_timing_info, | 4186 TestLoadTimingNotReused(load_timing_info, |
| 4186 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 4187 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 4187 | 4188 |
| 4188 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4189 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4189 ASSERT_TRUE(response != NULL); | 4190 ASSERT_TRUE(response); |
| 4190 | 4191 |
| 4191 EXPECT_TRUE(response->headers->IsKeepAlive()); | 4192 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 4192 EXPECT_EQ(200, response->headers->response_code()); | 4193 EXPECT_EQ(200, response->headers->response_code()); |
| 4193 EXPECT_EQ(100, response->headers->GetContentLength()); | 4194 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4194 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 4195 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 4195 | 4196 |
| 4196 // The password prompt info should not be set. | 4197 // The password prompt info should not be set. |
| 4197 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4198 EXPECT_FALSE(response->auth_challenge); |
| 4198 } | 4199 } |
| 4199 | 4200 |
| 4200 // Test a SPDY get through an HTTPS Proxy. | 4201 // Test a SPDY get through an HTTPS Proxy. |
| 4201 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGet) { | 4202 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGet) { |
| 4202 HttpRequestInfo request; | 4203 HttpRequestInfo request; |
| 4203 request.method = "GET"; | 4204 request.method = "GET"; |
| 4204 request.url = GURL("http://www.example.org/"); | 4205 request.url = GURL("http://www.example.org/"); |
| 4205 request.load_flags = 0; | 4206 request.load_flags = 0; |
| 4206 | 4207 |
| 4207 // Configure against https proxy server "proxy:70". | 4208 // Configure against https proxy server "proxy:70". |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4241 | 4242 |
| 4242 rv = callback1.WaitForResult(); | 4243 rv = callback1.WaitForResult(); |
| 4243 EXPECT_EQ(OK, rv); | 4244 EXPECT_EQ(OK, rv); |
| 4244 | 4245 |
| 4245 LoadTimingInfo load_timing_info; | 4246 LoadTimingInfo load_timing_info; |
| 4246 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 4247 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 4247 TestLoadTimingNotReused(load_timing_info, | 4248 TestLoadTimingNotReused(load_timing_info, |
| 4248 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 4249 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 4249 | 4250 |
| 4250 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4251 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4251 ASSERT_TRUE(response != NULL); | 4252 ASSERT_TRUE(response); |
| 4252 ASSERT_TRUE(response->headers.get() != NULL); | 4253 ASSERT_TRUE(response->headers); |
| 4253 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 4254 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 4254 | 4255 |
| 4255 std::string response_data; | 4256 std::string response_data; |
| 4256 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4257 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 4257 EXPECT_EQ(kUploadData, response_data); | 4258 EXPECT_EQ(kUploadData, response_data); |
| 4258 } | 4259 } |
| 4259 | 4260 |
| 4260 // Verifies that a session which races and wins against the owning transaction | 4261 // Verifies that a session which races and wins against the owning transaction |
| 4261 // (completing prior to host resolution), doesn't fail the transaction. | 4262 // (completing prior to host resolution), doesn't fail the transaction. |
| 4262 // Regression test for crbug.com/334413. | 4263 // Regression test for crbug.com/334413. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4314 | 4315 |
| 4315 // Unstall the resolution begun by the transaction. | 4316 // Unstall the resolution begun by the transaction. |
| 4316 session_deps_.host_resolver->set_ondemand_mode(true); | 4317 session_deps_.host_resolver->set_ondemand_mode(true); |
| 4317 session_deps_.host_resolver->ResolveAllPending(); | 4318 session_deps_.host_resolver->ResolveAllPending(); |
| 4318 | 4319 |
| 4319 EXPECT_FALSE(callback1.have_result()); | 4320 EXPECT_FALSE(callback1.have_result()); |
| 4320 rv = callback1.WaitForResult(); | 4321 rv = callback1.WaitForResult(); |
| 4321 EXPECT_EQ(OK, rv); | 4322 EXPECT_EQ(OK, rv); |
| 4322 | 4323 |
| 4323 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4324 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4324 ASSERT_TRUE(response != NULL); | 4325 ASSERT_TRUE(response); |
| 4325 ASSERT_TRUE(response->headers.get() != NULL); | 4326 ASSERT_TRUE(response->headers); |
| 4326 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 4327 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 4327 | 4328 |
| 4328 std::string response_data; | 4329 std::string response_data; |
| 4329 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4330 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 4330 EXPECT_EQ(kUploadData, response_data); | 4331 EXPECT_EQ(kUploadData, response_data); |
| 4331 } | 4332 } |
| 4332 | 4333 |
| 4333 // Test a SPDY get through an HTTPS Proxy. | 4334 // Test a SPDY get through an HTTPS Proxy. |
| 4334 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) { | 4335 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) { |
| 4335 HttpRequestInfo request; | 4336 HttpRequestInfo request; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4397 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4398 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4398 | 4399 |
| 4399 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 4400 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 4400 EXPECT_EQ(ERR_IO_PENDING, rv); | 4401 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4401 | 4402 |
| 4402 rv = callback1.WaitForResult(); | 4403 rv = callback1.WaitForResult(); |
| 4403 EXPECT_EQ(OK, rv); | 4404 EXPECT_EQ(OK, rv); |
| 4404 | 4405 |
| 4405 const HttpResponseInfo* const response = trans->GetResponseInfo(); | 4406 const HttpResponseInfo* const response = trans->GetResponseInfo(); |
| 4406 | 4407 |
| 4407 ASSERT_TRUE(response != NULL); | 4408 ASSERT_TRUE(response); |
| 4408 ASSERT_TRUE(response->headers.get() != NULL); | 4409 ASSERT_TRUE(response->headers); |
| 4409 EXPECT_EQ(407, response->headers->response_code()); | 4410 EXPECT_EQ(407, response->headers->response_code()); |
| 4410 EXPECT_TRUE(response->was_fetched_via_spdy); | 4411 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4411 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 4412 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 4412 | 4413 |
| 4413 TestCompletionCallback callback2; | 4414 TestCompletionCallback callback2; |
| 4414 | 4415 |
| 4415 rv = trans->RestartWithAuth( | 4416 rv = trans->RestartWithAuth( |
| 4416 AuthCredentials(kFoo, kBar), callback2.callback()); | 4417 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 4417 EXPECT_EQ(ERR_IO_PENDING, rv); | 4418 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4418 | 4419 |
| 4419 rv = callback2.WaitForResult(); | 4420 rv = callback2.WaitForResult(); |
| 4420 EXPECT_EQ(OK, rv); | 4421 EXPECT_EQ(OK, rv); |
| 4421 | 4422 |
| 4422 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 4423 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
| 4423 | 4424 |
| 4424 ASSERT_TRUE(response_restart != NULL); | 4425 ASSERT_TRUE(response_restart); |
| 4425 ASSERT_TRUE(response_restart->headers.get() != NULL); | 4426 ASSERT_TRUE(response_restart->headers); |
| 4426 EXPECT_EQ(200, response_restart->headers->response_code()); | 4427 EXPECT_EQ(200, response_restart->headers->response_code()); |
| 4427 // The password prompt info should not be set. | 4428 // The password prompt info should not be set. |
| 4428 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 4429 EXPECT_FALSE(response_restart->auth_challenge); |
| 4429 } | 4430 } |
| 4430 | 4431 |
| 4431 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. | 4432 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. |
| 4432 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectHttps) { | 4433 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectHttps) { |
| 4433 HttpRequestInfo request; | 4434 HttpRequestInfo request; |
| 4434 request.method = "GET"; | 4435 request.method = "GET"; |
| 4435 request.url = GURL("https://www.example.org/"); | 4436 request.url = GURL("https://www.example.org/"); |
| 4436 request.load_flags = 0; | 4437 request.load_flags = 0; |
| 4437 | 4438 |
| 4438 // Configure against https proxy server "proxy:70". | 4439 // Configure against https proxy server "proxy:70". |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4496 EXPECT_EQ(ERR_IO_PENDING, rv); | 4497 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4497 | 4498 |
| 4498 rv = callback1.WaitForResult(); | 4499 rv = callback1.WaitForResult(); |
| 4499 ASSERT_EQ(OK, rv); | 4500 ASSERT_EQ(OK, rv); |
| 4500 | 4501 |
| 4501 LoadTimingInfo load_timing_info; | 4502 LoadTimingInfo load_timing_info; |
| 4502 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 4503 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 4503 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 4504 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
| 4504 | 4505 |
| 4505 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4506 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4506 ASSERT_TRUE(response != NULL); | 4507 ASSERT_TRUE(response); |
| 4507 ASSERT_TRUE(response->headers.get() != NULL); | 4508 ASSERT_TRUE(response->headers); |
| 4508 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4509 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 4509 | 4510 |
| 4510 std::string response_data; | 4511 std::string response_data; |
| 4511 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4512 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 4512 EXPECT_EQ("1234567890", response_data); | 4513 EXPECT_EQ("1234567890", response_data); |
| 4513 } | 4514 } |
| 4514 | 4515 |
| 4515 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. | 4516 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. |
| 4516 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectSpdy) { | 4517 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectSpdy) { |
| 4517 SpdyTestUtil spdy_util_wrapped(GetProtocol(), GetDependenciesFromPriority()); | 4518 SpdyTestUtil spdy_util_wrapped(GetProtocol(), GetDependenciesFromPriority()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4590 // Now allow the read of the response to complete. | 4591 // Now allow the read of the response to complete. |
| 4591 spdy_data.Resume(); | 4592 spdy_data.Resume(); |
| 4592 rv = callback1.WaitForResult(); | 4593 rv = callback1.WaitForResult(); |
| 4593 EXPECT_EQ(OK, rv); | 4594 EXPECT_EQ(OK, rv); |
| 4594 | 4595 |
| 4595 LoadTimingInfo load_timing_info; | 4596 LoadTimingInfo load_timing_info; |
| 4596 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 4597 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 4597 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 4598 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
| 4598 | 4599 |
| 4599 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4600 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4600 ASSERT_TRUE(response != NULL); | 4601 ASSERT_TRUE(response); |
| 4601 ASSERT_TRUE(response->headers.get() != NULL); | 4602 ASSERT_TRUE(response->headers); |
| 4602 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 4603 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 4603 | 4604 |
| 4604 std::string response_data; | 4605 std::string response_data; |
| 4605 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4606 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 4606 EXPECT_EQ(kUploadData, response_data); | 4607 EXPECT_EQ(kUploadData, response_data); |
| 4607 } | 4608 } |
| 4608 | 4609 |
| 4609 // Test a SPDY CONNECT failure through an HTTPS Proxy. | 4610 // Test a SPDY CONNECT failure through an HTTPS Proxy. |
| 4610 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectFailure) { | 4611 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectFailure) { |
| 4611 HttpRequestInfo request; | 4612 HttpRequestInfo request; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4769 std::unique_ptr<HttpTransaction> trans( | 4770 std::unique_ptr<HttpTransaction> trans( |
| 4770 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4771 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4771 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 4772 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
| 4772 EXPECT_EQ(OK, callback.GetResult(rv)); | 4773 EXPECT_EQ(OK, callback.GetResult(rv)); |
| 4773 | 4774 |
| 4774 LoadTimingInfo load_timing_info; | 4775 LoadTimingInfo load_timing_info; |
| 4775 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 4776 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 4776 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 4777 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
| 4777 | 4778 |
| 4778 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4779 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4779 ASSERT_TRUE(response != NULL); | 4780 ASSERT_TRUE(response); |
| 4780 ASSERT_TRUE(response->headers.get() != NULL); | 4781 ASSERT_TRUE(response->headers); |
| 4781 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4782 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 4782 | 4783 |
| 4783 std::string response_data; | 4784 std::string response_data; |
| 4784 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); | 4785 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); |
| 4785 rv = trans->Read(buf.get(), 256, callback.callback()); | 4786 rv = trans->Read(buf.get(), 256, callback.callback()); |
| 4786 EXPECT_EQ(1, callback.GetResult(rv)); | 4787 EXPECT_EQ(1, callback.GetResult(rv)); |
| 4787 | 4788 |
| 4788 std::unique_ptr<HttpTransaction> trans2( | 4789 std::unique_ptr<HttpTransaction> trans2( |
| 4789 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4790 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4790 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 4791 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4894 EXPECT_EQ(ERR_IO_PENDING, rv); | 4895 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4895 | 4896 |
| 4896 rv = callback.WaitForResult(); | 4897 rv = callback.WaitForResult(); |
| 4897 EXPECT_EQ(OK, rv); | 4898 EXPECT_EQ(OK, rv); |
| 4898 | 4899 |
| 4899 LoadTimingInfo load_timing_info; | 4900 LoadTimingInfo load_timing_info; |
| 4900 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 4901 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 4901 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 4902 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
| 4902 | 4903 |
| 4903 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4904 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4904 ASSERT_TRUE(response != NULL); | 4905 ASSERT_TRUE(response); |
| 4905 ASSERT_TRUE(response->headers.get() != NULL); | 4906 ASSERT_TRUE(response->headers); |
| 4906 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4907 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 4907 | 4908 |
| 4908 std::string response_data; | 4909 std::string response_data; |
| 4909 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); | 4910 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); |
| 4910 EXPECT_EQ(1, trans->Read(buf.get(), 256, callback.callback())); | 4911 EXPECT_EQ(1, trans->Read(buf.get(), 256, callback.callback())); |
| 4911 trans.reset(); | 4912 trans.reset(); |
| 4912 | 4913 |
| 4913 std::unique_ptr<HttpTransaction> trans2( | 4914 std::unique_ptr<HttpTransaction> trans2( |
| 4914 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4915 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4915 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 4916 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4996 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4997 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 4997 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 4998 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
| 4998 EXPECT_EQ(OK, callback.GetResult(rv)); | 4999 EXPECT_EQ(OK, callback.GetResult(rv)); |
| 4999 | 5000 |
| 5000 LoadTimingInfo load_timing_info; | 5001 LoadTimingInfo load_timing_info; |
| 5001 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 5002 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 5002 TestLoadTimingNotReused(load_timing_info, | 5003 TestLoadTimingNotReused(load_timing_info, |
| 5003 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 5004 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 5004 | 5005 |
| 5005 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5006 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5006 ASSERT_TRUE(response != NULL); | 5007 ASSERT_TRUE(response); |
| 5007 ASSERT_TRUE(response->headers.get() != NULL); | 5008 ASSERT_TRUE(response->headers); |
| 5008 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 5009 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 5009 | 5010 |
| 5010 std::string response_data; | 5011 std::string response_data; |
| 5011 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); | 5012 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); |
| 5012 rv = trans->Read(buf.get(), 256, callback.callback()); | 5013 rv = trans->Read(buf.get(), 256, callback.callback()); |
| 5013 EXPECT_EQ(1, callback.GetResult(rv)); | 5014 EXPECT_EQ(1, callback.GetResult(rv)); |
| 5014 // Delete the first request, so the second one can reuse the socket. | 5015 // Delete the first request, so the second one can reuse the socket. |
| 5015 trans.reset(); | 5016 trans.reset(); |
| 5016 | 5017 |
| 5017 std::unique_ptr<HttpTransaction> trans2( | 5018 std::unique_ptr<HttpTransaction> trans2( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5091 | 5092 |
| 5092 rv = callback1.WaitForResult(); | 5093 rv = callback1.WaitForResult(); |
| 5093 EXPECT_EQ(OK, rv); | 5094 EXPECT_EQ(OK, rv); |
| 5094 | 5095 |
| 5095 LoadTimingInfo load_timing_info; | 5096 LoadTimingInfo load_timing_info; |
| 5096 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 5097 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 5097 TestLoadTimingNotReused(load_timing_info, | 5098 TestLoadTimingNotReused(load_timing_info, |
| 5098 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 5099 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 5099 | 5100 |
| 5100 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5101 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5101 ASSERT_TRUE(response != NULL); | 5102 ASSERT_TRUE(response); |
| 5102 ASSERT_FALSE(response->headers.get() == NULL); | 5103 ASSERT_TRUE(response->headers); |
| 5103 EXPECT_EQ(407, response->headers->response_code()); | 5104 EXPECT_EQ(407, response->headers->response_code()); |
| 5104 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 5105 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 5105 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 5106 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 5106 | 5107 |
| 5107 TestCompletionCallback callback2; | 5108 TestCompletionCallback callback2; |
| 5108 | 5109 |
| 5109 rv = trans->RestartWithAuth( | 5110 rv = trans->RestartWithAuth( |
| 5110 AuthCredentials(kFoo, kBar), callback2.callback()); | 5111 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 5111 EXPECT_EQ(ERR_IO_PENDING, rv); | 5112 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5112 | 5113 |
| 5113 rv = callback2.WaitForResult(); | 5114 rv = callback2.WaitForResult(); |
| 5114 EXPECT_EQ(OK, rv); | 5115 EXPECT_EQ(OK, rv); |
| 5115 | 5116 |
| 5116 load_timing_info = LoadTimingInfo(); | 5117 load_timing_info = LoadTimingInfo(); |
| 5117 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 5118 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 5118 // Retrying with HTTP AUTH is considered to be reusing a socket. | 5119 // Retrying with HTTP AUTH is considered to be reusing a socket. |
| 5119 TestLoadTimingReused(load_timing_info); | 5120 TestLoadTimingReused(load_timing_info); |
| 5120 | 5121 |
| 5121 response = trans->GetResponseInfo(); | 5122 response = trans->GetResponseInfo(); |
| 5122 ASSERT_TRUE(response != NULL); | 5123 ASSERT_TRUE(response); |
| 5123 | 5124 |
| 5124 EXPECT_TRUE(response->headers->IsKeepAlive()); | 5125 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 5125 EXPECT_EQ(200, response->headers->response_code()); | 5126 EXPECT_EQ(200, response->headers->response_code()); |
| 5126 EXPECT_EQ(100, response->headers->GetContentLength()); | 5127 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 5127 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 5128 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 5128 | 5129 |
| 5129 // The password prompt info should not be set. | 5130 // The password prompt info should not be set. |
| 5130 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 5131 EXPECT_FALSE(response->auth_challenge); |
| 5131 } | 5132 } |
| 5132 | 5133 |
| 5133 void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( | 5134 void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( |
| 5134 const MockRead& status, int expected_status) { | 5135 const MockRead& status, int expected_status) { |
| 5135 HttpRequestInfo request; | 5136 HttpRequestInfo request; |
| 5136 request.method = "GET"; | 5137 request.method = "GET"; |
| 5137 request.url = GURL("https://www.example.org/"); | 5138 request.url = GURL("https://www.example.org/"); |
| 5138 request.load_flags = 0; | 5139 request.load_flags = 0; |
| 5139 | 5140 |
| 5140 // Configure against proxy server "myproxy:70". | 5141 // Configure against proxy server "myproxy:70". |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5434 | 5435 |
| 5435 TestCompletionCallback callback1; | 5436 TestCompletionCallback callback1; |
| 5436 | 5437 |
| 5437 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 5438 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 5438 EXPECT_EQ(ERR_IO_PENDING, rv); | 5439 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5439 | 5440 |
| 5440 rv = callback1.WaitForResult(); | 5441 rv = callback1.WaitForResult(); |
| 5441 EXPECT_EQ(OK, rv); | 5442 EXPECT_EQ(OK, rv); |
| 5442 | 5443 |
| 5443 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5444 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5444 ASSERT_TRUE(response != NULL); | 5445 ASSERT_TRUE(response); |
| 5445 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 5446 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 5446 | 5447 |
| 5447 TestCompletionCallback callback2; | 5448 TestCompletionCallback callback2; |
| 5448 | 5449 |
| 5449 rv = trans->RestartWithAuth( | 5450 rv = trans->RestartWithAuth( |
| 5450 AuthCredentials(kFoo, kBar), callback2.callback()); | 5451 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 5451 EXPECT_EQ(ERR_IO_PENDING, rv); | 5452 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5452 | 5453 |
| 5453 rv = callback2.WaitForResult(); | 5454 rv = callback2.WaitForResult(); |
| 5454 EXPECT_EQ(OK, rv); | 5455 EXPECT_EQ(OK, rv); |
| 5455 | 5456 |
| 5456 response = trans->GetResponseInfo(); | 5457 response = trans->GetResponseInfo(); |
| 5457 ASSERT_TRUE(response != NULL); | 5458 ASSERT_TRUE(response); |
| 5458 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 5459 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 5459 | 5460 |
| 5460 TestCompletionCallback callback3; | 5461 TestCompletionCallback callback3; |
| 5461 | 5462 |
| 5462 rv = trans->RestartWithAuth( | 5463 rv = trans->RestartWithAuth( |
| 5463 AuthCredentials(kFoo2, kBar2), callback3.callback()); | 5464 AuthCredentials(kFoo2, kBar2), callback3.callback()); |
| 5464 EXPECT_EQ(ERR_IO_PENDING, rv); | 5465 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5465 | 5466 |
| 5466 rv = callback3.WaitForResult(); | 5467 rv = callback3.WaitForResult(); |
| 5467 EXPECT_EQ(OK, rv); | 5468 EXPECT_EQ(OK, rv); |
| 5468 | 5469 |
| 5469 response = trans->GetResponseInfo(); | 5470 response = trans->GetResponseInfo(); |
| 5470 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 5471 EXPECT_FALSE(response->auth_challenge); |
| 5471 EXPECT_EQ(100, response->headers->GetContentLength()); | 5472 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 5472 } | 5473 } |
| 5473 | 5474 |
| 5474 // For the NTLM implementation using SSPI, we skip the NTLM tests since we | 5475 // For the NTLM implementation using SSPI, we skip the NTLM tests since we |
| 5475 // can't hook into its internals to cause it to generate predictable NTLM | 5476 // can't hook into its internals to cause it to generate predictable NTLM |
| 5476 // authorization headers. | 5477 // authorization headers. |
| 5477 #if defined(NTLM_PORTABLE) | 5478 #if defined(NTLM_PORTABLE) |
| 5478 // The NTLM authentication unit tests were generated by capturing the HTTP | 5479 // The NTLM authentication unit tests were generated by capturing the HTTP |
| 5479 // requests and responses using Fiddler 2 and inspecting the generated random | 5480 // requests and responses using Fiddler 2 and inspecting the generated random |
| 5480 // bytes in the debugger. | 5481 // bytes in the debugger. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5572 | 5573 |
| 5573 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 5574 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 5574 EXPECT_EQ(ERR_IO_PENDING, rv); | 5575 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5575 | 5576 |
| 5576 rv = callback1.WaitForResult(); | 5577 rv = callback1.WaitForResult(); |
| 5577 EXPECT_EQ(OK, rv); | 5578 EXPECT_EQ(OK, rv); |
| 5578 | 5579 |
| 5579 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 5580 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 5580 | 5581 |
| 5581 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5582 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5582 ASSERT_FALSE(response == NULL); | 5583 ASSERT_TRUE(response); |
| 5583 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 5584 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
| 5584 | 5585 |
| 5585 TestCompletionCallback callback2; | 5586 TestCompletionCallback callback2; |
| 5586 | 5587 |
| 5587 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), | 5588 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), |
| 5588 callback2.callback()); | 5589 callback2.callback()); |
| 5589 EXPECT_EQ(ERR_IO_PENDING, rv); | 5590 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5590 | 5591 |
| 5591 rv = callback2.WaitForResult(); | 5592 rv = callback2.WaitForResult(); |
| 5592 EXPECT_EQ(OK, rv); | 5593 EXPECT_EQ(OK, rv); |
| 5593 | 5594 |
| 5594 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 5595 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 5595 | 5596 |
| 5596 response = trans->GetResponseInfo(); | 5597 response = trans->GetResponseInfo(); |
| 5597 ASSERT_TRUE(response != NULL); | 5598 ASSERT_TRUE(response); |
| 5598 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 5599 EXPECT_FALSE(response->auth_challenge); |
| 5599 | 5600 |
| 5600 TestCompletionCallback callback3; | 5601 TestCompletionCallback callback3; |
| 5601 | 5602 |
| 5602 rv = trans->RestartWithAuth(AuthCredentials(), callback3.callback()); | 5603 rv = trans->RestartWithAuth(AuthCredentials(), callback3.callback()); |
| 5603 EXPECT_EQ(ERR_IO_PENDING, rv); | 5604 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5604 | 5605 |
| 5605 rv = callback3.WaitForResult(); | 5606 rv = callback3.WaitForResult(); |
| 5606 EXPECT_EQ(OK, rv); | 5607 EXPECT_EQ(OK, rv); |
| 5607 | 5608 |
| 5608 response = trans->GetResponseInfo(); | 5609 response = trans->GetResponseInfo(); |
| 5609 ASSERT_TRUE(response != NULL); | 5610 ASSERT_TRUE(response); |
| 5610 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 5611 EXPECT_FALSE(response->auth_challenge); |
| 5611 EXPECT_EQ(13, response->headers->GetContentLength()); | 5612 EXPECT_EQ(13, response->headers->GetContentLength()); |
| 5612 } | 5613 } |
| 5613 | 5614 |
| 5614 // Enter a wrong password, and then the correct one. | 5615 // Enter a wrong password, and then the correct one. |
| 5615 TEST_P(HttpNetworkTransactionTest, NTLMAuth2) { | 5616 TEST_P(HttpNetworkTransactionTest, NTLMAuth2) { |
| 5616 HttpRequestInfo request; | 5617 HttpRequestInfo request; |
| 5617 request.method = "GET"; | 5618 request.method = "GET"; |
| 5618 request.url = GURL("http://172.22.68.17/kids/login.aspx"); | 5619 request.url = GURL("http://172.22.68.17/kids/login.aspx"); |
| 5619 request.load_flags = 0; | 5620 request.load_flags = 0; |
| 5620 | 5621 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5752 | 5753 |
| 5753 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 5754 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 5754 EXPECT_EQ(ERR_IO_PENDING, rv); | 5755 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5755 | 5756 |
| 5756 rv = callback1.WaitForResult(); | 5757 rv = callback1.WaitForResult(); |
| 5757 EXPECT_EQ(OK, rv); | 5758 EXPECT_EQ(OK, rv); |
| 5758 | 5759 |
| 5759 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 5760 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 5760 | 5761 |
| 5761 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5762 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5762 ASSERT_TRUE(response != NULL); | 5763 ASSERT_TRUE(response); |
| 5763 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 5764 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
| 5764 | 5765 |
| 5765 TestCompletionCallback callback2; | 5766 TestCompletionCallback callback2; |
| 5766 | 5767 |
| 5767 // Enter the wrong password. | 5768 // Enter the wrong password. |
| 5768 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kWrongPassword), | 5769 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kWrongPassword), |
| 5769 callback2.callback()); | 5770 callback2.callback()); |
| 5770 EXPECT_EQ(ERR_IO_PENDING, rv); | 5771 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5771 | 5772 |
| 5772 rv = callback2.WaitForResult(); | 5773 rv = callback2.WaitForResult(); |
| 5773 EXPECT_EQ(OK, rv); | 5774 EXPECT_EQ(OK, rv); |
| 5774 | 5775 |
| 5775 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 5776 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 5776 TestCompletionCallback callback3; | 5777 TestCompletionCallback callback3; |
| 5777 rv = trans->RestartWithAuth(AuthCredentials(), callback3.callback()); | 5778 rv = trans->RestartWithAuth(AuthCredentials(), callback3.callback()); |
| 5778 EXPECT_EQ(ERR_IO_PENDING, rv); | 5779 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5779 rv = callback3.WaitForResult(); | 5780 rv = callback3.WaitForResult(); |
| 5780 EXPECT_EQ(OK, rv); | 5781 EXPECT_EQ(OK, rv); |
| 5781 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 5782 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 5782 | 5783 |
| 5783 response = trans->GetResponseInfo(); | 5784 response = trans->GetResponseInfo(); |
| 5784 ASSERT_FALSE(response == NULL); | 5785 ASSERT_TRUE(response); |
| 5785 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 5786 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
| 5786 | 5787 |
| 5787 TestCompletionCallback callback4; | 5788 TestCompletionCallback callback4; |
| 5788 | 5789 |
| 5789 // Now enter the right password. | 5790 // Now enter the right password. |
| 5790 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), | 5791 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), |
| 5791 callback4.callback()); | 5792 callback4.callback()); |
| 5792 EXPECT_EQ(ERR_IO_PENDING, rv); | 5793 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5793 | 5794 |
| 5794 rv = callback4.WaitForResult(); | 5795 rv = callback4.WaitForResult(); |
| 5795 EXPECT_EQ(OK, rv); | 5796 EXPECT_EQ(OK, rv); |
| 5796 | 5797 |
| 5797 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 5798 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 5798 | 5799 |
| 5799 TestCompletionCallback callback5; | 5800 TestCompletionCallback callback5; |
| 5800 | 5801 |
| 5801 // One more roundtrip | 5802 // One more roundtrip |
| 5802 rv = trans->RestartWithAuth(AuthCredentials(), callback5.callback()); | 5803 rv = trans->RestartWithAuth(AuthCredentials(), callback5.callback()); |
| 5803 EXPECT_EQ(ERR_IO_PENDING, rv); | 5804 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5804 | 5805 |
| 5805 rv = callback5.WaitForResult(); | 5806 rv = callback5.WaitForResult(); |
| 5806 EXPECT_EQ(OK, rv); | 5807 EXPECT_EQ(OK, rv); |
| 5807 | 5808 |
| 5808 response = trans->GetResponseInfo(); | 5809 response = trans->GetResponseInfo(); |
| 5809 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 5810 EXPECT_FALSE(response->auth_challenge); |
| 5810 EXPECT_EQ(13, response->headers->GetContentLength()); | 5811 EXPECT_EQ(13, response->headers->GetContentLength()); |
| 5811 } | 5812 } |
| 5812 #endif // NTLM_PORTABLE | 5813 #endif // NTLM_PORTABLE |
| 5813 | 5814 |
| 5814 // Test reading a server response which has only headers, and no body. | 5815 // Test reading a server response which has only headers, and no body. |
| 5815 // After some maximum number of bytes is consumed, the transaction should | 5816 // After some maximum number of bytes is consumed, the transaction should |
| 5816 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. | 5817 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. |
| 5817 TEST_P(HttpNetworkTransactionTest, LargeHeadersNoBody) { | 5818 TEST_P(HttpNetworkTransactionTest, LargeHeadersNoBody) { |
| 5818 HttpRequestInfo request; | 5819 HttpRequestInfo request; |
| 5819 request.method = "GET"; | 5820 request.method = "GET"; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5932 | 5933 |
| 5933 TestCompletionCallback callback; | 5934 TestCompletionCallback callback; |
| 5934 | 5935 |
| 5935 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5936 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5936 EXPECT_EQ(ERR_IO_PENDING, rv); | 5937 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5937 | 5938 |
| 5938 rv = callback.WaitForResult(); | 5939 rv = callback.WaitForResult(); |
| 5939 EXPECT_EQ(OK, rv); | 5940 EXPECT_EQ(OK, rv); |
| 5940 | 5941 |
| 5941 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5942 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5942 ASSERT_TRUE(response != NULL); | 5943 ASSERT_TRUE(response); |
| 5943 | 5944 |
| 5944 EXPECT_TRUE(response->headers.get() != NULL); | 5945 EXPECT_TRUE(response->headers); |
| 5945 std::string status_line = response->headers->GetStatusLine(); | 5946 std::string status_line = response->headers->GetStatusLine(); |
| 5946 EXPECT_EQ("HTTP/1.1 200 OK", status_line); | 5947 EXPECT_EQ("HTTP/1.1 200 OK", status_line); |
| 5947 | 5948 |
| 5948 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 5949 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
| 5949 | 5950 |
| 5950 std::string response_data; | 5951 std::string response_data; |
| 5951 rv = ReadTransaction(trans.get(), &response_data); | 5952 rv = ReadTransaction(trans.get(), &response_data); |
| 5952 EXPECT_EQ(OK, rv); | 5953 EXPECT_EQ(OK, rv); |
| 5953 EXPECT_EQ("hello world", response_data); | 5954 EXPECT_EQ("hello world", response_data); |
| 5954 | 5955 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5994 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 5995 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 5995 std::unique_ptr<HttpTransaction> trans( | 5996 std::unique_ptr<HttpTransaction> trans( |
| 5996 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 5997 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 5997 | 5998 |
| 5998 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5999 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5999 | 6000 |
| 6000 EXPECT_EQ(ERR_IO_PENDING, rv); | 6001 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6001 EXPECT_EQ(OK, callback.WaitForResult()); | 6002 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6002 | 6003 |
| 6003 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6004 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6004 ASSERT_TRUE(response != NULL); | 6005 ASSERT_TRUE(response); |
| 6005 ASSERT_TRUE(response->headers.get() != NULL); | 6006 ASSERT_TRUE(response->headers); |
| 6006 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6007 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6007 | 6008 |
| 6008 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6009 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
| 6009 | 6010 |
| 6010 std::string response_data; | 6011 std::string response_data; |
| 6011 rv = ReadTransaction(trans.get(), &response_data); | 6012 rv = ReadTransaction(trans.get(), &response_data); |
| 6012 EXPECT_EQ(OK, rv); | 6013 EXPECT_EQ(OK, rv); |
| 6013 EXPECT_EQ("hello world", response_data); | 6014 EXPECT_EQ("hello world", response_data); |
| 6014 | 6015 |
| 6015 // Empty the current queue. This is necessary because idle sockets are | 6016 // Empty the current queue. This is necessary because idle sockets are |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6060 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 6061 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 6061 std::unique_ptr<HttpTransaction> trans( | 6062 std::unique_ptr<HttpTransaction> trans( |
| 6062 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 6063 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 6063 | 6064 |
| 6064 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6065 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6065 | 6066 |
| 6066 EXPECT_EQ(ERR_IO_PENDING, rv); | 6067 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6067 EXPECT_EQ(OK, callback.WaitForResult()); | 6068 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6068 | 6069 |
| 6069 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6070 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6070 ASSERT_TRUE(response != NULL); | 6071 ASSERT_TRUE(response); |
| 6071 ASSERT_TRUE(response->headers.get() != NULL); | 6072 ASSERT_TRUE(response->headers); |
| 6072 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6073 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6073 | 6074 |
| 6074 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6075 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
| 6075 | 6076 |
| 6076 std::string response_data; | 6077 std::string response_data; |
| 6077 rv = ReadTransaction(trans.get(), &response_data); | 6078 rv = ReadTransaction(trans.get(), &response_data); |
| 6078 EXPECT_EQ(OK, rv); | 6079 EXPECT_EQ(OK, rv); |
| 6079 EXPECT_EQ("hello world", response_data); | 6080 EXPECT_EQ("hello world", response_data); |
| 6080 | 6081 |
| 6081 // Empty the current queue. This is necessary because idle sockets are | 6082 // Empty the current queue. This is necessary because idle sockets are |
| 6082 // added to the connection pool asynchronously with a PostTask. | 6083 // added to the connection pool asynchronously with a PostTask. |
| 6083 base::MessageLoop::current()->RunUntilIdle(); | 6084 base::MessageLoop::current()->RunUntilIdle(); |
| 6084 | 6085 |
| 6085 // We now check to make sure the socket was added back to the pool. | 6086 // We now check to make sure the socket was added back to the pool. |
| 6086 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); | 6087 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
| 6087 | 6088 |
| 6088 // Now start the second transaction, which should reuse the previous socket. | 6089 // Now start the second transaction, which should reuse the previous socket. |
| 6089 | 6090 |
| 6090 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 6091 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 6091 | 6092 |
| 6092 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6093 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6093 | 6094 |
| 6094 EXPECT_EQ(ERR_IO_PENDING, rv); | 6095 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6095 EXPECT_EQ(OK, callback.WaitForResult()); | 6096 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6096 | 6097 |
| 6097 response = trans->GetResponseInfo(); | 6098 response = trans->GetResponseInfo(); |
| 6098 ASSERT_TRUE(response != NULL); | 6099 ASSERT_TRUE(response); |
| 6099 ASSERT_TRUE(response->headers.get() != NULL); | 6100 ASSERT_TRUE(response->headers); |
| 6100 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6101 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6101 | 6102 |
| 6102 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6103 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
| 6103 | 6104 |
| 6104 rv = ReadTransaction(trans.get(), &response_data); | 6105 rv = ReadTransaction(trans.get(), &response_data); |
| 6105 EXPECT_EQ(OK, rv); | 6106 EXPECT_EQ(OK, rv); |
| 6106 EXPECT_EQ("hello world", response_data); | 6107 EXPECT_EQ("hello world", response_data); |
| 6107 | 6108 |
| 6108 // Empty the current queue. This is necessary because idle sockets are | 6109 // Empty the current queue. This is necessary because idle sockets are |
| 6109 // added to the connection pool asynchronously with a PostTask. | 6110 // added to the connection pool asynchronously with a PostTask. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6145 | 6146 |
| 6146 TestCompletionCallback callback; | 6147 TestCompletionCallback callback; |
| 6147 | 6148 |
| 6148 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6149 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6149 EXPECT_EQ(ERR_IO_PENDING, rv); | 6150 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6150 | 6151 |
| 6151 rv = callback.WaitForResult(); | 6152 rv = callback.WaitForResult(); |
| 6152 EXPECT_EQ(OK, rv); | 6153 EXPECT_EQ(OK, rv); |
| 6153 | 6154 |
| 6154 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6155 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6155 ASSERT_TRUE(response != NULL); | 6156 ASSERT_TRUE(response); |
| 6156 | 6157 |
| 6157 EXPECT_TRUE(response->headers.get() != NULL); | 6158 EXPECT_TRUE(response->headers); |
| 6158 std::string status_line = response->headers->GetStatusLine(); | 6159 std::string status_line = response->headers->GetStatusLine(); |
| 6159 EXPECT_EQ("HTTP/1.1 204 No Content", status_line); | 6160 EXPECT_EQ("HTTP/1.1 204 No Content", status_line); |
| 6160 | 6161 |
| 6161 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6162 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
| 6162 | 6163 |
| 6163 std::string response_data; | 6164 std::string response_data; |
| 6164 rv = ReadTransaction(trans.get(), &response_data); | 6165 rv = ReadTransaction(trans.get(), &response_data); |
| 6165 EXPECT_EQ(OK, rv); | 6166 EXPECT_EQ(OK, rv); |
| 6166 EXPECT_EQ("", response_data); | 6167 EXPECT_EQ("", response_data); |
| 6167 | 6168 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6244 | 6245 |
| 6245 TestCompletionCallback callback; | 6246 TestCompletionCallback callback; |
| 6246 | 6247 |
| 6247 int rv = trans->Start(&request[i], callback.callback(), BoundNetLog()); | 6248 int rv = trans->Start(&request[i], callback.callback(), BoundNetLog()); |
| 6248 EXPECT_EQ(ERR_IO_PENDING, rv); | 6249 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6249 | 6250 |
| 6250 rv = callback.WaitForResult(); | 6251 rv = callback.WaitForResult(); |
| 6251 EXPECT_EQ(OK, rv); | 6252 EXPECT_EQ(OK, rv); |
| 6252 | 6253 |
| 6253 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6254 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6254 ASSERT_TRUE(response != NULL); | 6255 ASSERT_TRUE(response); |
| 6255 | 6256 |
| 6256 EXPECT_TRUE(response->headers.get() != NULL); | 6257 EXPECT_TRUE(response->headers); |
| 6257 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6258 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6258 | 6259 |
| 6259 std::string response_data; | 6260 std::string response_data; |
| 6260 rv = ReadTransaction(trans.get(), &response_data); | 6261 rv = ReadTransaction(trans.get(), &response_data); |
| 6261 EXPECT_EQ(OK, rv); | 6262 EXPECT_EQ(OK, rv); |
| 6262 EXPECT_EQ(kExpectedResponseData[i], response_data); | 6263 EXPECT_EQ(kExpectedResponseData[i], response_data); |
| 6263 } | 6264 } |
| 6264 } | 6265 } |
| 6265 | 6266 |
| 6266 // Test the request-challenge-retry sequence for basic auth when there is | 6267 // Test the request-challenge-retry sequence for basic auth when there is |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6325 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 6326 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 6326 | 6327 |
| 6327 TestCompletionCallback callback2; | 6328 TestCompletionCallback callback2; |
| 6328 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); | 6329 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 6329 EXPECT_EQ(ERR_IO_PENDING, rv); | 6330 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6330 rv = callback2.WaitForResult(); | 6331 rv = callback2.WaitForResult(); |
| 6331 EXPECT_EQ(OK, rv); | 6332 EXPECT_EQ(OK, rv); |
| 6332 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6333 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 6333 | 6334 |
| 6334 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6335 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6335 ASSERT_TRUE(response != NULL); | 6336 ASSERT_TRUE(response); |
| 6336 | 6337 |
| 6337 // There is no challenge info, since the identity in URL worked. | 6338 // There is no challenge info, since the identity in URL worked. |
| 6338 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6339 EXPECT_FALSE(response->auth_challenge); |
| 6339 | 6340 |
| 6340 EXPECT_EQ(100, response->headers->GetContentLength()); | 6341 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6341 | 6342 |
| 6342 // Empty the current queue. | 6343 // Empty the current queue. |
| 6343 base::MessageLoop::current()->RunUntilIdle(); | 6344 base::MessageLoop::current()->RunUntilIdle(); |
| 6344 } | 6345 } |
| 6345 | 6346 |
| 6346 // Test the request-challenge-retry sequence for basic auth when there is an | 6347 // Test the request-challenge-retry sequence for basic auth when there is an |
| 6347 // incorrect identity in the URL. The identity from the URL should be used only | 6348 // incorrect identity in the URL. The identity from the URL should be used only |
| 6348 // once. | 6349 // once. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6426 | 6427 |
| 6427 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 6428 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 6428 TestCompletionCallback callback2; | 6429 TestCompletionCallback callback2; |
| 6429 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); | 6430 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 6430 EXPECT_EQ(ERR_IO_PENDING, rv); | 6431 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6431 rv = callback2.WaitForResult(); | 6432 rv = callback2.WaitForResult(); |
| 6432 EXPECT_EQ(OK, rv); | 6433 EXPECT_EQ(OK, rv); |
| 6433 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6434 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 6434 | 6435 |
| 6435 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6436 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6436 ASSERT_TRUE(response != NULL); | 6437 ASSERT_TRUE(response); |
| 6437 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6438 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 6438 | 6439 |
| 6439 TestCompletionCallback callback3; | 6440 TestCompletionCallback callback3; |
| 6440 rv = trans->RestartWithAuth( | 6441 rv = trans->RestartWithAuth( |
| 6441 AuthCredentials(kFoo, kBar), callback3.callback()); | 6442 AuthCredentials(kFoo, kBar), callback3.callback()); |
| 6442 EXPECT_EQ(ERR_IO_PENDING, rv); | 6443 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6443 rv = callback3.WaitForResult(); | 6444 rv = callback3.WaitForResult(); |
| 6444 EXPECT_EQ(OK, rv); | 6445 EXPECT_EQ(OK, rv); |
| 6445 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6446 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 6446 | 6447 |
| 6447 response = trans->GetResponseInfo(); | 6448 response = trans->GetResponseInfo(); |
| 6448 ASSERT_TRUE(response != NULL); | 6449 ASSERT_TRUE(response); |
| 6449 | 6450 |
| 6450 // There is no challenge info, since the identity worked. | 6451 // There is no challenge info, since the identity worked. |
| 6451 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6452 EXPECT_FALSE(response->auth_challenge); |
| 6452 | 6453 |
| 6453 EXPECT_EQ(100, response->headers->GetContentLength()); | 6454 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6454 | 6455 |
| 6455 // Empty the current queue. | 6456 // Empty the current queue. |
| 6456 base::MessageLoop::current()->RunUntilIdle(); | 6457 base::MessageLoop::current()->RunUntilIdle(); |
| 6457 } | 6458 } |
| 6458 | 6459 |
| 6459 | 6460 |
| 6460 // Test the request-challenge-retry sequence for basic auth when there is a | 6461 // Test the request-challenge-retry sequence for basic auth when there is a |
| 6461 // correct identity in the URL, but its use is being suppressed. The identity | 6462 // correct identity in the URL, but its use is being suppressed. The identity |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6509 session_deps_.socket_factory->AddSocketDataProvider(&data3); | 6510 session_deps_.socket_factory->AddSocketDataProvider(&data3); |
| 6510 | 6511 |
| 6511 TestCompletionCallback callback1; | 6512 TestCompletionCallback callback1; |
| 6512 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6513 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6513 EXPECT_EQ(ERR_IO_PENDING, rv); | 6514 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6514 rv = callback1.WaitForResult(); | 6515 rv = callback1.WaitForResult(); |
| 6515 EXPECT_EQ(OK, rv); | 6516 EXPECT_EQ(OK, rv); |
| 6516 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6517 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 6517 | 6518 |
| 6518 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6519 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6519 ASSERT_TRUE(response != NULL); | 6520 ASSERT_TRUE(response); |
| 6520 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6521 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 6521 | 6522 |
| 6522 TestCompletionCallback callback3; | 6523 TestCompletionCallback callback3; |
| 6523 rv = trans->RestartWithAuth( | 6524 rv = trans->RestartWithAuth( |
| 6524 AuthCredentials(kFoo, kBar), callback3.callback()); | 6525 AuthCredentials(kFoo, kBar), callback3.callback()); |
| 6525 EXPECT_EQ(ERR_IO_PENDING, rv); | 6526 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6526 rv = callback3.WaitForResult(); | 6527 rv = callback3.WaitForResult(); |
| 6527 EXPECT_EQ(OK, rv); | 6528 EXPECT_EQ(OK, rv); |
| 6528 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6529 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 6529 | 6530 |
| 6530 response = trans->GetResponseInfo(); | 6531 response = trans->GetResponseInfo(); |
| 6531 ASSERT_TRUE(response != NULL); | 6532 ASSERT_TRUE(response); |
| 6532 | 6533 |
| 6533 // There is no challenge info, since the identity worked. | 6534 // There is no challenge info, since the identity worked. |
| 6534 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6535 EXPECT_FALSE(response->auth_challenge); |
| 6535 EXPECT_EQ(100, response->headers->GetContentLength()); | 6536 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6536 | 6537 |
| 6537 // Empty the current queue. | 6538 // Empty the current queue. |
| 6538 base::MessageLoop::current()->RunUntilIdle(); | 6539 base::MessageLoop::current()->RunUntilIdle(); |
| 6539 } | 6540 } |
| 6540 | 6541 |
| 6541 // Test that previously tried username/passwords for a realm get re-used. | 6542 // Test that previously tried username/passwords for a realm get re-used. |
| 6542 TEST_P(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { | 6543 TEST_P(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { |
| 6543 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 6544 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 6544 | 6545 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6591 | 6592 |
| 6592 TestCompletionCallback callback1; | 6593 TestCompletionCallback callback1; |
| 6593 | 6594 |
| 6594 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6595 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6595 EXPECT_EQ(ERR_IO_PENDING, rv); | 6596 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6596 | 6597 |
| 6597 rv = callback1.WaitForResult(); | 6598 rv = callback1.WaitForResult(); |
| 6598 EXPECT_EQ(OK, rv); | 6599 EXPECT_EQ(OK, rv); |
| 6599 | 6600 |
| 6600 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6601 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6601 ASSERT_TRUE(response != NULL); | 6602 ASSERT_TRUE(response); |
| 6602 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6603 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 6603 | 6604 |
| 6604 TestCompletionCallback callback2; | 6605 TestCompletionCallback callback2; |
| 6605 | 6606 |
| 6606 rv = trans->RestartWithAuth( | 6607 rv = trans->RestartWithAuth( |
| 6607 AuthCredentials(kFoo, kBar), callback2.callback()); | 6608 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 6608 EXPECT_EQ(ERR_IO_PENDING, rv); | 6609 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6609 | 6610 |
| 6610 rv = callback2.WaitForResult(); | 6611 rv = callback2.WaitForResult(); |
| 6611 EXPECT_EQ(OK, rv); | 6612 EXPECT_EQ(OK, rv); |
| 6612 | 6613 |
| 6613 response = trans->GetResponseInfo(); | 6614 response = trans->GetResponseInfo(); |
| 6614 ASSERT_TRUE(response != NULL); | 6615 ASSERT_TRUE(response); |
| 6615 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6616 EXPECT_FALSE(response->auth_challenge); |
| 6616 EXPECT_EQ(100, response->headers->GetContentLength()); | 6617 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6617 } | 6618 } |
| 6618 | 6619 |
| 6619 // ------------------------------------------------------------------------ | 6620 // ------------------------------------------------------------------------ |
| 6620 | 6621 |
| 6621 // Transaction 2: authenticate (foo2, bar2) on MyRealm2 | 6622 // Transaction 2: authenticate (foo2, bar2) on MyRealm2 |
| 6622 { | 6623 { |
| 6623 HttpRequestInfo request; | 6624 HttpRequestInfo request; |
| 6624 request.method = "GET"; | 6625 request.method = "GET"; |
| 6625 // Note that Transaction 1 was at /x/y/z, so this is in the same | 6626 // Note that Transaction 1 was at /x/y/z, so this is in the same |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6673 | 6674 |
| 6674 TestCompletionCallback callback1; | 6675 TestCompletionCallback callback1; |
| 6675 | 6676 |
| 6676 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6677 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6677 EXPECT_EQ(ERR_IO_PENDING, rv); | 6678 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6678 | 6679 |
| 6679 rv = callback1.WaitForResult(); | 6680 rv = callback1.WaitForResult(); |
| 6680 EXPECT_EQ(OK, rv); | 6681 EXPECT_EQ(OK, rv); |
| 6681 | 6682 |
| 6682 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6683 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6683 ASSERT_TRUE(response != NULL); | 6684 ASSERT_TRUE(response); |
| 6684 ASSERT_TRUE(response->auth_challenge.get()); | 6685 ASSERT_TRUE(response->auth_challenge); |
| 6685 EXPECT_FALSE(response->auth_challenge->is_proxy); | 6686 EXPECT_FALSE(response->auth_challenge->is_proxy); |
| 6686 EXPECT_EQ("www.example.org:80", | 6687 EXPECT_EQ("www.example.org:80", |
| 6687 response->auth_challenge->challenger.ToString()); | 6688 response->auth_challenge->challenger.ToString()); |
| 6688 EXPECT_EQ("MyRealm2", response->auth_challenge->realm); | 6689 EXPECT_EQ("MyRealm2", response->auth_challenge->realm); |
| 6689 EXPECT_EQ(kBasicAuthScheme, response->auth_challenge->scheme); | 6690 EXPECT_EQ(kBasicAuthScheme, response->auth_challenge->scheme); |
| 6690 | 6691 |
| 6691 TestCompletionCallback callback2; | 6692 TestCompletionCallback callback2; |
| 6692 | 6693 |
| 6693 rv = trans->RestartWithAuth( | 6694 rv = trans->RestartWithAuth( |
| 6694 AuthCredentials(kFoo2, kBar2), callback2.callback()); | 6695 AuthCredentials(kFoo2, kBar2), callback2.callback()); |
| 6695 EXPECT_EQ(ERR_IO_PENDING, rv); | 6696 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6696 | 6697 |
| 6697 rv = callback2.WaitForResult(); | 6698 rv = callback2.WaitForResult(); |
| 6698 EXPECT_EQ(OK, rv); | 6699 EXPECT_EQ(OK, rv); |
| 6699 | 6700 |
| 6700 response = trans->GetResponseInfo(); | 6701 response = trans->GetResponseInfo(); |
| 6701 ASSERT_TRUE(response != NULL); | 6702 ASSERT_TRUE(response); |
| 6702 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6703 EXPECT_FALSE(response->auth_challenge); |
| 6703 EXPECT_EQ(100, response->headers->GetContentLength()); | 6704 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6704 } | 6705 } |
| 6705 | 6706 |
| 6706 // ------------------------------------------------------------------------ | 6707 // ------------------------------------------------------------------------ |
| 6707 | 6708 |
| 6708 // Transaction 3: Resend a request in MyRealm's protection space -- | 6709 // Transaction 3: Resend a request in MyRealm's protection space -- |
| 6709 // succeed with preemptive authorization. | 6710 // succeed with preemptive authorization. |
| 6710 { | 6711 { |
| 6711 HttpRequestInfo request; | 6712 HttpRequestInfo request; |
| 6712 request.method = "GET"; | 6713 request.method = "GET"; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6739 | 6740 |
| 6740 TestCompletionCallback callback1; | 6741 TestCompletionCallback callback1; |
| 6741 | 6742 |
| 6742 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6743 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6743 EXPECT_EQ(ERR_IO_PENDING, rv); | 6744 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6744 | 6745 |
| 6745 rv = callback1.WaitForResult(); | 6746 rv = callback1.WaitForResult(); |
| 6746 EXPECT_EQ(OK, rv); | 6747 EXPECT_EQ(OK, rv); |
| 6747 | 6748 |
| 6748 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6749 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6749 ASSERT_TRUE(response != NULL); | 6750 ASSERT_TRUE(response); |
| 6750 | 6751 |
| 6751 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6752 EXPECT_FALSE(response->auth_challenge); |
| 6752 EXPECT_EQ(100, response->headers->GetContentLength()); | 6753 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6753 } | 6754 } |
| 6754 | 6755 |
| 6755 // ------------------------------------------------------------------------ | 6756 // ------------------------------------------------------------------------ |
| 6756 | 6757 |
| 6757 // Transaction 4: request another URL in MyRealm (however the | 6758 // Transaction 4: request another URL in MyRealm (however the |
| 6758 // url is not known to belong to the protection space, so no pre-auth). | 6759 // url is not known to belong to the protection space, so no pre-auth). |
| 6759 { | 6760 { |
| 6760 HttpRequestInfo request; | 6761 HttpRequestInfo request; |
| 6761 request.method = "GET"; | 6762 request.method = "GET"; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6812 | 6813 |
| 6813 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 6814 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 6814 TestCompletionCallback callback2; | 6815 TestCompletionCallback callback2; |
| 6815 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); | 6816 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 6816 EXPECT_EQ(ERR_IO_PENDING, rv); | 6817 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6817 rv = callback2.WaitForResult(); | 6818 rv = callback2.WaitForResult(); |
| 6818 EXPECT_EQ(OK, rv); | 6819 EXPECT_EQ(OK, rv); |
| 6819 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6820 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 6820 | 6821 |
| 6821 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6822 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6822 ASSERT_TRUE(response != NULL); | 6823 ASSERT_TRUE(response); |
| 6823 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6824 EXPECT_FALSE(response->auth_challenge); |
| 6824 EXPECT_EQ(100, response->headers->GetContentLength()); | 6825 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6825 } | 6826 } |
| 6826 | 6827 |
| 6827 // ------------------------------------------------------------------------ | 6828 // ------------------------------------------------------------------------ |
| 6828 | 6829 |
| 6829 // Transaction 5: request a URL in MyRealm, but the server rejects the | 6830 // Transaction 5: request a URL in MyRealm, but the server rejects the |
| 6830 // cached identity. Should invalidate and re-prompt. | 6831 // cached identity. Should invalidate and re-prompt. |
| 6831 { | 6832 { |
| 6832 HttpRequestInfo request; | 6833 HttpRequestInfo request; |
| 6833 request.method = "GET"; | 6834 request.method = "GET"; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6905 | 6906 |
| 6906 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 6907 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 6907 TestCompletionCallback callback2; | 6908 TestCompletionCallback callback2; |
| 6908 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); | 6909 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 6909 EXPECT_EQ(ERR_IO_PENDING, rv); | 6910 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6910 rv = callback2.WaitForResult(); | 6911 rv = callback2.WaitForResult(); |
| 6911 EXPECT_EQ(OK, rv); | 6912 EXPECT_EQ(OK, rv); |
| 6912 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6913 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 6913 | 6914 |
| 6914 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6915 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6915 ASSERT_TRUE(response != NULL); | 6916 ASSERT_TRUE(response); |
| 6916 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6917 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 6917 | 6918 |
| 6918 TestCompletionCallback callback3; | 6919 TestCompletionCallback callback3; |
| 6919 | 6920 |
| 6920 rv = trans->RestartWithAuth( | 6921 rv = trans->RestartWithAuth( |
| 6921 AuthCredentials(kFoo3, kBar3), callback3.callback()); | 6922 AuthCredentials(kFoo3, kBar3), callback3.callback()); |
| 6922 EXPECT_EQ(ERR_IO_PENDING, rv); | 6923 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6923 | 6924 |
| 6924 rv = callback3.WaitForResult(); | 6925 rv = callback3.WaitForResult(); |
| 6925 EXPECT_EQ(OK, rv); | 6926 EXPECT_EQ(OK, rv); |
| 6926 | 6927 |
| 6927 response = trans->GetResponseInfo(); | 6928 response = trans->GetResponseInfo(); |
| 6928 ASSERT_TRUE(response != NULL); | 6929 ASSERT_TRUE(response); |
| 6929 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6930 EXPECT_FALSE(response->auth_challenge); |
| 6930 EXPECT_EQ(100, response->headers->GetContentLength()); | 6931 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6931 } | 6932 } |
| 6932 } | 6933 } |
| 6933 | 6934 |
| 6934 // Tests that nonce count increments when multiple auth attempts | 6935 // Tests that nonce count increments when multiple auth attempts |
| 6935 // are started with the same nonce. | 6936 // are started with the same nonce. |
| 6936 TEST_P(HttpNetworkTransactionTest, DigestPreAuthNonceCount) { | 6937 TEST_P(HttpNetworkTransactionTest, DigestPreAuthNonceCount) { |
| 6937 HttpAuthHandlerDigest::Factory* digest_factory = | 6938 HttpAuthHandlerDigest::Factory* digest_factory = |
| 6938 new HttpAuthHandlerDigest::Factory(); | 6939 new HttpAuthHandlerDigest::Factory(); |
| 6939 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator = | 6940 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator = |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6993 | 6994 |
| 6994 TestCompletionCallback callback1; | 6995 TestCompletionCallback callback1; |
| 6995 | 6996 |
| 6996 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6997 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6997 EXPECT_EQ(ERR_IO_PENDING, rv); | 6998 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6998 | 6999 |
| 6999 rv = callback1.WaitForResult(); | 7000 rv = callback1.WaitForResult(); |
| 7000 EXPECT_EQ(OK, rv); | 7001 EXPECT_EQ(OK, rv); |
| 7001 | 7002 |
| 7002 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7003 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7003 ASSERT_TRUE(response != NULL); | 7004 ASSERT_TRUE(response); |
| 7004 EXPECT_TRUE(CheckDigestServerAuth(response->auth_challenge.get())); | 7005 EXPECT_TRUE(CheckDigestServerAuth(response->auth_challenge.get())); |
| 7005 | 7006 |
| 7006 TestCompletionCallback callback2; | 7007 TestCompletionCallback callback2; |
| 7007 | 7008 |
| 7008 rv = trans->RestartWithAuth( | 7009 rv = trans->RestartWithAuth( |
| 7009 AuthCredentials(kFoo, kBar), callback2.callback()); | 7010 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 7010 EXPECT_EQ(ERR_IO_PENDING, rv); | 7011 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7011 | 7012 |
| 7012 rv = callback2.WaitForResult(); | 7013 rv = callback2.WaitForResult(); |
| 7013 EXPECT_EQ(OK, rv); | 7014 EXPECT_EQ(OK, rv); |
| 7014 | 7015 |
| 7015 response = trans->GetResponseInfo(); | 7016 response = trans->GetResponseInfo(); |
| 7016 ASSERT_TRUE(response != NULL); | 7017 ASSERT_TRUE(response); |
| 7017 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7018 EXPECT_FALSE(response->auth_challenge); |
| 7018 } | 7019 } |
| 7019 | 7020 |
| 7020 // ------------------------------------------------------------------------ | 7021 // ------------------------------------------------------------------------ |
| 7021 | 7022 |
| 7022 // Transaction 2: Request another resource in digestive's protection space. | 7023 // Transaction 2: Request another resource in digestive's protection space. |
| 7023 // This will preemptively add an Authorization header which should have an | 7024 // This will preemptively add an Authorization header which should have an |
| 7024 // "nc" value of 2 (as compared to 1 in the first use. | 7025 // "nc" value of 2 (as compared to 1 in the first use. |
| 7025 { | 7026 { |
| 7026 HttpRequestInfo request; | 7027 HttpRequestInfo request; |
| 7027 request.method = "GET"; | 7028 request.method = "GET"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 7057 | 7058 |
| 7058 TestCompletionCallback callback1; | 7059 TestCompletionCallback callback1; |
| 7059 | 7060 |
| 7060 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 7061 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 7061 EXPECT_EQ(ERR_IO_PENDING, rv); | 7062 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7062 | 7063 |
| 7063 rv = callback1.WaitForResult(); | 7064 rv = callback1.WaitForResult(); |
| 7064 EXPECT_EQ(OK, rv); | 7065 EXPECT_EQ(OK, rv); |
| 7065 | 7066 |
| 7066 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7067 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7067 ASSERT_TRUE(response != NULL); | 7068 ASSERT_TRUE(response); |
| 7068 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7069 EXPECT_FALSE(response->auth_challenge); |
| 7069 } | 7070 } |
| 7070 } | 7071 } |
| 7071 | 7072 |
| 7072 // Test the ResetStateForRestart() private method. | 7073 // Test the ResetStateForRestart() private method. |
| 7073 TEST_P(HttpNetworkTransactionTest, ResetStateForRestart) { | 7074 TEST_P(HttpNetworkTransactionTest, ResetStateForRestart) { |
| 7074 // Create a transaction (the dependencies aren't important). | 7075 // Create a transaction (the dependencies aren't important). |
| 7075 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 7076 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 7076 std::unique_ptr<HttpNetworkTransaction> trans( | 7077 std::unique_ptr<HttpNetworkTransaction> trans( |
| 7077 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7078 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7078 | 7079 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7095 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); | 7096 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); |
| 7096 request.extra_headers.SetHeader("Foo", "1"); | 7097 request.extra_headers.SetHeader("Foo", "1"); |
| 7097 request.extra_headers.SetHeader("bar", "23"); | 7098 request.extra_headers.SetHeader("bar", "23"); |
| 7098 EXPECT_TRUE(response->vary_data.Init(request, *headers.get())); | 7099 EXPECT_TRUE(response->vary_data.Init(request, *headers.get())); |
| 7099 } | 7100 } |
| 7100 | 7101 |
| 7101 // Cause the above state to be reset. | 7102 // Cause the above state to be reset. |
| 7102 trans->ResetStateForRestart(); | 7103 trans->ResetStateForRestart(); |
| 7103 | 7104 |
| 7104 // Verify that the state that needed to be reset, has been reset. | 7105 // Verify that the state that needed to be reset, has been reset. |
| 7105 EXPECT_TRUE(trans->read_buf_.get() == NULL); | 7106 EXPECT_FALSE(trans->read_buf_); |
| 7106 EXPECT_EQ(0, trans->read_buf_len_); | 7107 EXPECT_EQ(0, trans->read_buf_len_); |
| 7107 EXPECT_TRUE(trans->request_headers_.IsEmpty()); | 7108 EXPECT_TRUE(trans->request_headers_.IsEmpty()); |
| 7108 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7109 EXPECT_FALSE(response->auth_challenge); |
| 7109 EXPECT_TRUE(response->headers.get() == NULL); | 7110 EXPECT_FALSE(response->headers); |
| 7110 EXPECT_FALSE(response->was_cached); | 7111 EXPECT_FALSE(response->was_cached); |
| 7111 EXPECT_EQ(0U, response->ssl_info.cert_status); | 7112 EXPECT_EQ(0U, response->ssl_info.cert_status); |
| 7112 EXPECT_FALSE(response->vary_data.is_valid()); | 7113 EXPECT_FALSE(response->vary_data.is_valid()); |
| 7113 } | 7114 } |
| 7114 | 7115 |
| 7115 // Test HTTPS connections to a site with a bad certificate | 7116 // Test HTTPS connections to a site with a bad certificate |
| 7116 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificate) { | 7117 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificate) { |
| 7117 HttpRequestInfo request; | 7118 HttpRequestInfo request; |
| 7118 request.method = "GET"; | 7119 request.method = "GET"; |
| 7119 request.url = GURL("https://www.example.org/"); | 7120 request.url = GURL("https://www.example.org/"); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7157 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 7158 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 7158 | 7159 |
| 7159 rv = trans->RestartIgnoringLastError(callback.callback()); | 7160 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 7160 EXPECT_EQ(ERR_IO_PENDING, rv); | 7161 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7161 | 7162 |
| 7162 rv = callback.WaitForResult(); | 7163 rv = callback.WaitForResult(); |
| 7163 EXPECT_EQ(OK, rv); | 7164 EXPECT_EQ(OK, rv); |
| 7164 | 7165 |
| 7165 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7166 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7166 | 7167 |
| 7167 ASSERT_TRUE(response != NULL); | 7168 ASSERT_TRUE(response); |
| 7168 EXPECT_EQ(100, response->headers->GetContentLength()); | 7169 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 7169 } | 7170 } |
| 7170 | 7171 |
| 7171 // Test HTTPS connections to a site with a bad certificate, going through a | 7172 // Test HTTPS connections to a site with a bad certificate, going through a |
| 7172 // proxy | 7173 // proxy |
| 7173 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) { | 7174 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) { |
| 7174 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70"); | 7175 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70"); |
| 7175 | 7176 |
| 7176 HttpRequestInfo request; | 7177 HttpRequestInfo request; |
| 7177 request.method = "GET"; | 7178 request.method = "GET"; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7235 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 7236 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 7236 | 7237 |
| 7237 rv = trans->RestartIgnoringLastError(callback.callback()); | 7238 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 7238 EXPECT_EQ(ERR_IO_PENDING, rv); | 7239 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7239 | 7240 |
| 7240 rv = callback.WaitForResult(); | 7241 rv = callback.WaitForResult(); |
| 7241 EXPECT_EQ(OK, rv); | 7242 EXPECT_EQ(OK, rv); |
| 7242 | 7243 |
| 7243 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7244 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7244 | 7245 |
| 7245 ASSERT_TRUE(response != NULL); | 7246 ASSERT_TRUE(response); |
| 7246 EXPECT_EQ(100, response->headers->GetContentLength()); | 7247 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 7247 } | 7248 } |
| 7248 } | 7249 } |
| 7249 | 7250 |
| 7250 | 7251 |
| 7251 // Test HTTPS connections to a site, going through an HTTPS proxy | 7252 // Test HTTPS connections to a site, going through an HTTPS proxy |
| 7252 TEST_P(HttpNetworkTransactionTest, HTTPSViaHttpsProxy) { | 7253 TEST_P(HttpNetworkTransactionTest, HTTPSViaHttpsProxy) { |
| 7253 session_deps_.proxy_service = | 7254 session_deps_.proxy_service = |
| 7254 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70"); | 7255 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70"); |
| 7255 TestNetLog net_log; | 7256 TestNetLog net_log; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7292 std::unique_ptr<HttpTransaction> trans( | 7293 std::unique_ptr<HttpTransaction> trans( |
| 7293 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7294 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7294 | 7295 |
| 7295 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7296 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7296 EXPECT_EQ(ERR_IO_PENDING, rv); | 7297 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7297 | 7298 |
| 7298 rv = callback.WaitForResult(); | 7299 rv = callback.WaitForResult(); |
| 7299 EXPECT_EQ(OK, rv); | 7300 EXPECT_EQ(OK, rv); |
| 7300 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7301 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7301 | 7302 |
| 7302 ASSERT_TRUE(response != NULL); | 7303 ASSERT_TRUE(response); |
| 7303 | 7304 |
| 7304 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7305 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 7305 EXPECT_EQ(200, response->headers->response_code()); | 7306 EXPECT_EQ(200, response->headers->response_code()); |
| 7306 EXPECT_EQ(100, response->headers->GetContentLength()); | 7307 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 7307 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7308 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 7308 | 7309 |
| 7309 LoadTimingInfo load_timing_info; | 7310 LoadTimingInfo load_timing_info; |
| 7310 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 7311 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 7311 TestLoadTimingNotReusedWithPac(load_timing_info, | 7312 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 7312 CONNECT_TIMING_HAS_SSL_TIMES); | 7313 CONNECT_TIMING_HAS_SSL_TIMES); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7350 std::unique_ptr<HttpTransaction> trans( | 7351 std::unique_ptr<HttpTransaction> trans( |
| 7351 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7352 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7352 | 7353 |
| 7353 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7354 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7354 EXPECT_EQ(ERR_IO_PENDING, rv); | 7355 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7355 | 7356 |
| 7356 rv = callback.WaitForResult(); | 7357 rv = callback.WaitForResult(); |
| 7357 EXPECT_EQ(OK, rv); | 7358 EXPECT_EQ(OK, rv); |
| 7358 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7359 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7359 | 7360 |
| 7360 ASSERT_TRUE(response != NULL); | 7361 ASSERT_TRUE(response); |
| 7361 | 7362 |
| 7362 EXPECT_EQ(302, response->headers->response_code()); | 7363 EXPECT_EQ(302, response->headers->response_code()); |
| 7363 std::string url; | 7364 std::string url; |
| 7364 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 7365 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
| 7365 EXPECT_EQ("http://login.example.com/", url); | 7366 EXPECT_EQ("http://login.example.com/", url); |
| 7366 | 7367 |
| 7367 // In the case of redirects from proxies, HttpNetworkTransaction returns | 7368 // In the case of redirects from proxies, HttpNetworkTransaction returns |
| 7368 // timing for the proxy connection instead of the connection to the host, | 7369 // timing for the proxy connection instead of the connection to the host, |
| 7369 // and no send / receive times. | 7370 // and no send / receive times. |
| 7370 // See HttpNetworkTransaction::OnHttpsProxyTunnelResponse. | 7371 // See HttpNetworkTransaction::OnHttpsProxyTunnelResponse. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7431 std::unique_ptr<HttpTransaction> trans( | 7432 std::unique_ptr<HttpTransaction> trans( |
| 7432 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7433 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7433 | 7434 |
| 7434 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7435 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7435 EXPECT_EQ(ERR_IO_PENDING, rv); | 7436 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7436 | 7437 |
| 7437 rv = callback.WaitForResult(); | 7438 rv = callback.WaitForResult(); |
| 7438 EXPECT_EQ(OK, rv); | 7439 EXPECT_EQ(OK, rv); |
| 7439 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7440 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7440 | 7441 |
| 7441 ASSERT_TRUE(response != NULL); | 7442 ASSERT_TRUE(response); |
| 7442 | 7443 |
| 7443 EXPECT_EQ(302, response->headers->response_code()); | 7444 EXPECT_EQ(302, response->headers->response_code()); |
| 7444 std::string url; | 7445 std::string url; |
| 7445 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 7446 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
| 7446 EXPECT_EQ("http://login.example.com/", url); | 7447 EXPECT_EQ("http://login.example.com/", url); |
| 7447 } | 7448 } |
| 7448 | 7449 |
| 7449 // Test that an HTTPS proxy's response to a CONNECT request is filtered. | 7450 // Test that an HTTPS proxy's response to a CONNECT request is filtered. |
| 7450 TEST_P(HttpNetworkTransactionTest, | 7451 TEST_P(HttpNetworkTransactionTest, |
| 7451 ErrorResponseToHttpsConnectViaHttpsProxy) { | 7452 ErrorResponseToHttpsConnectViaHttpsProxy) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7645 log.GetEntries(&entries); | 7646 log.GetEntries(&entries); |
| 7646 size_t pos = ExpectLogContainsSomewhere( | 7647 size_t pos = ExpectLogContainsSomewhere( |
| 7647 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 7648 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 7648 NetLog::PHASE_NONE); | 7649 NetLog::PHASE_NONE); |
| 7649 ExpectLogContainsSomewhere( | 7650 ExpectLogContainsSomewhere( |
| 7650 entries, pos, | 7651 entries, pos, |
| 7651 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 7652 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 7652 NetLog::PHASE_NONE); | 7653 NetLog::PHASE_NONE); |
| 7653 | 7654 |
| 7654 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7655 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7655 ASSERT_TRUE(response != NULL); | 7656 ASSERT_TRUE(response); |
| 7656 ASSERT_FALSE(response->headers.get() == NULL); | 7657 ASSERT_TRUE(response->headers); |
| 7657 EXPECT_EQ(407, response->headers->response_code()); | 7658 EXPECT_EQ(407, response->headers->response_code()); |
| 7658 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7659 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 7659 EXPECT_TRUE(response->auth_challenge.get() != NULL); | 7660 EXPECT_TRUE(response->auth_challenge); |
| 7660 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 7661 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 7661 | 7662 |
| 7662 TestCompletionCallback callback2; | 7663 TestCompletionCallback callback2; |
| 7663 | 7664 |
| 7664 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), | 7665 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), |
| 7665 callback2.callback()); | 7666 callback2.callback()); |
| 7666 EXPECT_EQ(ERR_IO_PENDING, rv); | 7667 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7667 | 7668 |
| 7668 rv = callback2.WaitForResult(); | 7669 rv = callback2.WaitForResult(); |
| 7669 EXPECT_EQ(OK, rv); | 7670 EXPECT_EQ(OK, rv); |
| 7670 | 7671 |
| 7671 response = trans->GetResponseInfo(); | 7672 response = trans->GetResponseInfo(); |
| 7672 ASSERT_TRUE(response != NULL); | 7673 ASSERT_TRUE(response); |
| 7673 | 7674 |
| 7674 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7675 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 7675 EXPECT_EQ(200, response->headers->response_code()); | 7676 EXPECT_EQ(200, response->headers->response_code()); |
| 7676 EXPECT_EQ(5, response->headers->GetContentLength()); | 7677 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 7677 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7678 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 7678 | 7679 |
| 7679 // The password prompt info should not be set. | 7680 // The password prompt info should not be set. |
| 7680 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7681 EXPECT_FALSE(response->auth_challenge); |
| 7681 | 7682 |
| 7682 LoadTimingInfo load_timing_info; | 7683 LoadTimingInfo load_timing_info; |
| 7683 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 7684 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 7684 TestLoadTimingNotReusedWithPac(load_timing_info, | 7685 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 7685 CONNECT_TIMING_HAS_SSL_TIMES); | 7686 CONNECT_TIMING_HAS_SSL_TIMES); |
| 7686 | 7687 |
| 7687 trans.reset(); | 7688 trans.reset(); |
| 7688 session->CloseAllConnections(); | 7689 session->CloseAllConnections(); |
| 7689 } | 7690 } |
| 7690 | 7691 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7761 | 7762 |
| 7762 std::unique_ptr<HttpTransaction> push_trans( | 7763 std::unique_ptr<HttpTransaction> push_trans( |
| 7763 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7764 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7764 rv = push_trans->Start(&push_request, callback.callback(), log.bound()); | 7765 rv = push_trans->Start(&push_request, callback.callback(), log.bound()); |
| 7765 EXPECT_EQ(ERR_IO_PENDING, rv); | 7766 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7766 | 7767 |
| 7767 rv = callback.WaitForResult(); | 7768 rv = callback.WaitForResult(); |
| 7768 EXPECT_EQ(OK, rv); | 7769 EXPECT_EQ(OK, rv); |
| 7769 const HttpResponseInfo* push_response = push_trans->GetResponseInfo(); | 7770 const HttpResponseInfo* push_response = push_trans->GetResponseInfo(); |
| 7770 | 7771 |
| 7771 ASSERT_TRUE(response != NULL); | 7772 ASSERT_TRUE(response); |
| 7772 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7773 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 7773 | 7774 |
| 7774 EXPECT_EQ(200, response->headers->response_code()); | 7775 EXPECT_EQ(200, response->headers->response_code()); |
| 7775 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7776 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 7776 | 7777 |
| 7777 std::string response_data; | 7778 std::string response_data; |
| 7778 rv = ReadTransaction(trans.get(), &response_data); | 7779 rv = ReadTransaction(trans.get(), &response_data); |
| 7779 EXPECT_EQ(OK, rv); | 7780 EXPECT_EQ(OK, rv); |
| 7780 EXPECT_EQ("hello!", response_data); | 7781 EXPECT_EQ("hello!", response_data); |
| 7781 | 7782 |
| 7782 LoadTimingInfo load_timing_info; | 7783 LoadTimingInfo load_timing_info; |
| 7783 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 7784 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 7784 TestLoadTimingNotReusedWithPac(load_timing_info, | 7785 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 7785 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 7786 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 7786 | 7787 |
| 7787 // Verify the pushed stream. | 7788 // Verify the pushed stream. |
| 7788 EXPECT_TRUE(push_response->headers.get() != NULL); | 7789 EXPECT_TRUE(push_response->headers); |
| 7789 EXPECT_EQ(200, push_response->headers->response_code()); | 7790 EXPECT_EQ(200, push_response->headers->response_code()); |
| 7790 | 7791 |
| 7791 rv = ReadTransaction(push_trans.get(), &response_data); | 7792 rv = ReadTransaction(push_trans.get(), &response_data); |
| 7792 EXPECT_EQ(OK, rv); | 7793 EXPECT_EQ(OK, rv); |
| 7793 EXPECT_EQ("pushed", response_data); | 7794 EXPECT_EQ("pushed", response_data); |
| 7794 | 7795 |
| 7795 LoadTimingInfo push_load_timing_info; | 7796 LoadTimingInfo push_load_timing_info; |
| 7796 EXPECT_TRUE(push_trans->GetLoadTimingInfo(&push_load_timing_info)); | 7797 EXPECT_TRUE(push_trans->GetLoadTimingInfo(&push_load_timing_info)); |
| 7797 TestLoadTimingReusedWithPac(push_load_timing_info); | 7798 TestLoadTimingReusedWithPac(push_load_timing_info); |
| 7798 // The transactions should share a socket ID, despite being for different | 7799 // The transactions should share a socket ID, despite being for different |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7863 std::unique_ptr<HttpTransaction> trans( | 7864 std::unique_ptr<HttpTransaction> trans( |
| 7864 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7865 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7865 TestCompletionCallback callback; | 7866 TestCompletionCallback callback; |
| 7866 int rv = trans->Start(&request, callback.callback(), log.bound()); | 7867 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 7867 EXPECT_EQ(ERR_IO_PENDING, rv); | 7868 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7868 | 7869 |
| 7869 rv = callback.WaitForResult(); | 7870 rv = callback.WaitForResult(); |
| 7870 EXPECT_EQ(OK, rv); | 7871 EXPECT_EQ(OK, rv); |
| 7871 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7872 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7872 | 7873 |
| 7873 ASSERT_TRUE(response != NULL); | 7874 ASSERT_TRUE(response); |
| 7874 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7875 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 7875 | 7876 |
| 7876 EXPECT_EQ(200, response->headers->response_code()); | 7877 EXPECT_EQ(200, response->headers->response_code()); |
| 7877 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7878 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 7878 | 7879 |
| 7879 std::string response_data; | 7880 std::string response_data; |
| 7880 rv = ReadTransaction(trans.get(), &response_data); | 7881 rv = ReadTransaction(trans.get(), &response_data); |
| 7881 EXPECT_EQ(OK, rv); | 7882 EXPECT_EQ(OK, rv); |
| 7882 EXPECT_EQ("hello!", response_data); | 7883 EXPECT_EQ("hello!", response_data); |
| 7883 | 7884 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7949 std::unique_ptr<HttpTransaction> trans( | 7950 std::unique_ptr<HttpTransaction> trans( |
| 7950 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7951 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7951 TestCompletionCallback callback; | 7952 TestCompletionCallback callback; |
| 7952 int rv = trans->Start(&request, callback.callback(), log.bound()); | 7953 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 7953 EXPECT_EQ(ERR_IO_PENDING, rv); | 7954 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7954 | 7955 |
| 7955 rv = callback.WaitForResult(); | 7956 rv = callback.WaitForResult(); |
| 7956 EXPECT_EQ(OK, rv); | 7957 EXPECT_EQ(OK, rv); |
| 7957 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7958 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7958 | 7959 |
| 7959 ASSERT_TRUE(response != nullptr); | 7960 ASSERT_TRUE(response); |
| 7960 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7961 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 7961 | 7962 |
| 7962 EXPECT_EQ(200, response->headers->response_code()); | 7963 EXPECT_EQ(200, response->headers->response_code()); |
| 7963 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7964 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 7964 | 7965 |
| 7965 std::string response_data; | 7966 std::string response_data; |
| 7966 rv = ReadTransaction(trans.get(), &response_data); | 7967 rv = ReadTransaction(trans.get(), &response_data); |
| 7967 EXPECT_EQ(OK, rv); | 7968 EXPECT_EQ(OK, rv); |
| 7968 EXPECT_EQ("hello!", response_data); | 7969 EXPECT_EQ("hello!", response_data); |
| 7969 | 7970 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8042 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 8043 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 8043 | 8044 |
| 8044 rv = trans->RestartIgnoringLastError(callback.callback()); | 8045 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 8045 EXPECT_EQ(ERR_IO_PENDING, rv); | 8046 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8046 | 8047 |
| 8047 rv = callback.WaitForResult(); | 8048 rv = callback.WaitForResult(); |
| 8048 EXPECT_EQ(OK, rv); | 8049 EXPECT_EQ(OK, rv); |
| 8049 | 8050 |
| 8050 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8051 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8051 | 8052 |
| 8052 ASSERT_TRUE(response != NULL); | 8053 ASSERT_TRUE(response); |
| 8053 EXPECT_EQ(100, response->headers->GetContentLength()); | 8054 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 8054 } | 8055 } |
| 8055 | 8056 |
| 8056 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgent) { | 8057 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgent) { |
| 8057 HttpRequestInfo request; | 8058 HttpRequestInfo request; |
| 8058 request.method = "GET"; | 8059 request.method = "GET"; |
| 8059 request.url = GURL("http://www.example.org/"); | 8060 request.url = GURL("http://www.example.org/"); |
| 8060 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, | 8061 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, |
| 8061 "Chromium Ultra Awesome X Edition"); | 8062 "Chromium Ultra Awesome X Edition"); |
| 8062 | 8063 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8486 | 8487 |
| 8487 TestCompletionCallback callback; | 8488 TestCompletionCallback callback; |
| 8488 | 8489 |
| 8489 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8490 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8490 EXPECT_EQ(ERR_IO_PENDING, rv); | 8491 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8491 | 8492 |
| 8492 rv = callback.WaitForResult(); | 8493 rv = callback.WaitForResult(); |
| 8493 EXPECT_EQ(OK, rv); | 8494 EXPECT_EQ(OK, rv); |
| 8494 | 8495 |
| 8495 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8496 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8496 ASSERT_TRUE(response != NULL); | 8497 ASSERT_TRUE(response); |
| 8497 | 8498 |
| 8498 LoadTimingInfo load_timing_info; | 8499 LoadTimingInfo load_timing_info; |
| 8499 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 8500 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 8500 TestLoadTimingNotReusedWithPac(load_timing_info, | 8501 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 8501 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 8502 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 8502 | 8503 |
| 8503 std::string response_text; | 8504 std::string response_text; |
| 8504 rv = ReadTransaction(trans.get(), &response_text); | 8505 rv = ReadTransaction(trans.get(), &response_text); |
| 8505 EXPECT_EQ(OK, rv); | 8506 EXPECT_EQ(OK, rv); |
| 8506 EXPECT_EQ("Payload", response_text); | 8507 EXPECT_EQ("Payload", response_text); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8555 | 8556 |
| 8556 rv = callback.WaitForResult(); | 8557 rv = callback.WaitForResult(); |
| 8557 EXPECT_EQ(OK, rv); | 8558 EXPECT_EQ(OK, rv); |
| 8558 | 8559 |
| 8559 LoadTimingInfo load_timing_info; | 8560 LoadTimingInfo load_timing_info; |
| 8560 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 8561 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 8561 TestLoadTimingNotReusedWithPac(load_timing_info, | 8562 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 8562 CONNECT_TIMING_HAS_SSL_TIMES); | 8563 CONNECT_TIMING_HAS_SSL_TIMES); |
| 8563 | 8564 |
| 8564 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8565 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8565 ASSERT_TRUE(response != NULL); | 8566 ASSERT_TRUE(response); |
| 8566 | 8567 |
| 8567 std::string response_text; | 8568 std::string response_text; |
| 8568 rv = ReadTransaction(trans.get(), &response_text); | 8569 rv = ReadTransaction(trans.get(), &response_text); |
| 8569 EXPECT_EQ(OK, rv); | 8570 EXPECT_EQ(OK, rv); |
| 8570 EXPECT_EQ("Payload", response_text); | 8571 EXPECT_EQ("Payload", response_text); |
| 8571 } | 8572 } |
| 8572 | 8573 |
| 8573 TEST_P(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) { | 8574 TEST_P(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) { |
| 8574 HttpRequestInfo request; | 8575 HttpRequestInfo request; |
| 8575 request.method = "GET"; | 8576 request.method = "GET"; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8609 | 8610 |
| 8610 TestCompletionCallback callback; | 8611 TestCompletionCallback callback; |
| 8611 | 8612 |
| 8612 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8613 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8613 EXPECT_EQ(ERR_IO_PENDING, rv); | 8614 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8614 | 8615 |
| 8615 rv = callback.WaitForResult(); | 8616 rv = callback.WaitForResult(); |
| 8616 EXPECT_EQ(OK, rv); | 8617 EXPECT_EQ(OK, rv); |
| 8617 | 8618 |
| 8618 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8619 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8619 ASSERT_TRUE(response != NULL); | 8620 ASSERT_TRUE(response); |
| 8620 | 8621 |
| 8621 LoadTimingInfo load_timing_info; | 8622 LoadTimingInfo load_timing_info; |
| 8622 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 8623 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 8623 TestLoadTimingNotReused(load_timing_info, | 8624 TestLoadTimingNotReused(load_timing_info, |
| 8624 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 8625 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 8625 | 8626 |
| 8626 std::string response_text; | 8627 std::string response_text; |
| 8627 rv = ReadTransaction(trans.get(), &response_text); | 8628 rv = ReadTransaction(trans.get(), &response_text); |
| 8628 EXPECT_EQ(OK, rv); | 8629 EXPECT_EQ(OK, rv); |
| 8629 EXPECT_EQ("Payload", response_text); | 8630 EXPECT_EQ("Payload", response_text); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8681 | 8682 |
| 8682 TestCompletionCallback callback; | 8683 TestCompletionCallback callback; |
| 8683 | 8684 |
| 8684 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8685 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8685 EXPECT_EQ(ERR_IO_PENDING, rv); | 8686 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8686 | 8687 |
| 8687 rv = callback.WaitForResult(); | 8688 rv = callback.WaitForResult(); |
| 8688 EXPECT_EQ(OK, rv); | 8689 EXPECT_EQ(OK, rv); |
| 8689 | 8690 |
| 8690 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8691 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8691 ASSERT_TRUE(response != NULL); | 8692 ASSERT_TRUE(response); |
| 8692 | 8693 |
| 8693 LoadTimingInfo load_timing_info; | 8694 LoadTimingInfo load_timing_info; |
| 8694 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 8695 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 8695 TestLoadTimingNotReusedWithPac(load_timing_info, | 8696 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 8696 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 8697 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
| 8697 | 8698 |
| 8698 std::string response_text; | 8699 std::string response_text; |
| 8699 rv = ReadTransaction(trans.get(), &response_text); | 8700 rv = ReadTransaction(trans.get(), &response_text); |
| 8700 EXPECT_EQ(OK, rv); | 8701 EXPECT_EQ(OK, rv); |
| 8701 EXPECT_EQ("Payload", response_text); | 8702 EXPECT_EQ("Payload", response_text); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8758 | 8759 |
| 8759 TestCompletionCallback callback; | 8760 TestCompletionCallback callback; |
| 8760 | 8761 |
| 8761 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8762 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8762 EXPECT_EQ(ERR_IO_PENDING, rv); | 8763 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8763 | 8764 |
| 8764 rv = callback.WaitForResult(); | 8765 rv = callback.WaitForResult(); |
| 8765 EXPECT_EQ(OK, rv); | 8766 EXPECT_EQ(OK, rv); |
| 8766 | 8767 |
| 8767 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8768 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8768 ASSERT_TRUE(response != NULL); | 8769 ASSERT_TRUE(response); |
| 8769 | 8770 |
| 8770 LoadTimingInfo load_timing_info; | 8771 LoadTimingInfo load_timing_info; |
| 8771 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 8772 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 8772 TestLoadTimingNotReusedWithPac(load_timing_info, | 8773 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 8773 CONNECT_TIMING_HAS_SSL_TIMES); | 8774 CONNECT_TIMING_HAS_SSL_TIMES); |
| 8774 | 8775 |
| 8775 std::string response_text; | 8776 std::string response_text; |
| 8776 rv = ReadTransaction(trans.get(), &response_text); | 8777 rv = ReadTransaction(trans.get(), &response_text); |
| 8777 EXPECT_EQ(OK, rv); | 8778 EXPECT_EQ(OK, rv); |
| 8778 EXPECT_EQ("Payload", response_text); | 8779 EXPECT_EQ("Payload", response_text); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9177 std::unique_ptr<HttpTransaction> trans( | 9178 std::unique_ptr<HttpTransaction> trans( |
| 9178 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9179 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9179 | 9180 |
| 9180 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9181 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9181 EXPECT_EQ(ERR_IO_PENDING, rv); | 9182 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9182 | 9183 |
| 9183 rv = callback.WaitForResult(); | 9184 rv = callback.WaitForResult(); |
| 9184 EXPECT_EQ(OK, rv); | 9185 EXPECT_EQ(OK, rv); |
| 9185 | 9186 |
| 9186 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9187 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9187 ASSERT_TRUE(response != NULL); | 9188 ASSERT_TRUE(response); |
| 9188 | 9189 |
| 9189 EXPECT_TRUE(response->headers.get() != NULL); | 9190 EXPECT_TRUE(response->headers); |
| 9190 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 9191 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 9191 | 9192 |
| 9192 std::string response_data; | 9193 std::string response_data; |
| 9193 rv = ReadTransaction(trans.get(), &response_data); | 9194 rv = ReadTransaction(trans.get(), &response_data); |
| 9194 EXPECT_EQ(OK, rv); | 9195 EXPECT_EQ(OK, rv); |
| 9195 EXPECT_EQ("", response_data); | 9196 EXPECT_EQ("", response_data); |
| 9196 | 9197 |
| 9197 IPEndPoint endpoint; | 9198 IPEndPoint endpoint; |
| 9198 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); | 9199 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); |
| 9199 EXPECT_LT(0u, endpoint.address().size()); | 9200 EXPECT_LT(0u, endpoint.address().size()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9255 std::unique_ptr<HttpTransaction> trans( | 9256 std::unique_ptr<HttpTransaction> trans( |
| 9256 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9257 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9257 | 9258 |
| 9258 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 9259 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 9259 EXPECT_EQ(ERR_IO_PENDING, rv); | 9260 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9260 | 9261 |
| 9261 rv = callback1.WaitForResult(); | 9262 rv = callback1.WaitForResult(); |
| 9262 EXPECT_EQ(OK, rv); | 9263 EXPECT_EQ(OK, rv); |
| 9263 | 9264 |
| 9264 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9265 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9265 ASSERT_TRUE(response != NULL); | 9266 ASSERT_TRUE(response); |
| 9266 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 9267 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 9267 | 9268 |
| 9268 TestCompletionCallback callback2; | 9269 TestCompletionCallback callback2; |
| 9269 | 9270 |
| 9270 rv = trans->RestartWithAuth( | 9271 rv = trans->RestartWithAuth( |
| 9271 AuthCredentials(kFoo, kBar), callback2.callback()); | 9272 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 9272 EXPECT_EQ(ERR_IO_PENDING, rv); | 9273 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9273 | 9274 |
| 9274 rv = callback2.WaitForResult(); | 9275 rv = callback2.WaitForResult(); |
| 9275 EXPECT_EQ(OK, rv); | 9276 EXPECT_EQ(OK, rv); |
| 9276 | 9277 |
| 9277 response = trans->GetResponseInfo(); | 9278 response = trans->GetResponseInfo(); |
| 9278 ASSERT_TRUE(response != NULL); | 9279 ASSERT_TRUE(response); |
| 9279 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 9280 EXPECT_FALSE(response->auth_challenge); |
| 9280 EXPECT_EQ(100, response->headers->GetContentLength()); | 9281 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 9281 } | 9282 } |
| 9282 | 9283 |
| 9283 // Test HTTPS connections going through a proxy that sends extra data. | 9284 // Test HTTPS connections going through a proxy that sends extra data. |
| 9284 TEST_P(HttpNetworkTransactionTest, HTTPSViaProxyWithExtraData) { | 9285 TEST_P(HttpNetworkTransactionTest, HTTPSViaProxyWithExtraData) { |
| 9285 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70"); | 9286 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70"); |
| 9286 | 9287 |
| 9287 HttpRequestInfo request; | 9288 HttpRequestInfo request; |
| 9288 request.method = "GET"; | 9289 request.method = "GET"; |
| 9289 request.url = GURL("https://www.example.org/"); | 9290 request.url = GURL("https://www.example.org/"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9334 session_deps_.socket_factory->AddSocketDataProvider(&data); | 9335 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 9335 | 9336 |
| 9336 TestCompletionCallback callback; | 9337 TestCompletionCallback callback; |
| 9337 | 9338 |
| 9338 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9339 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9339 EXPECT_EQ(ERR_IO_PENDING, rv); | 9340 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9340 | 9341 |
| 9341 EXPECT_EQ(OK, callback.WaitForResult()); | 9342 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9342 | 9343 |
| 9343 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9344 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9344 ASSERT_TRUE(response != NULL); | 9345 ASSERT_TRUE(response); |
| 9345 | 9346 |
| 9346 EXPECT_TRUE(response->headers.get() != NULL); | 9347 EXPECT_TRUE(response->headers); |
| 9347 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 9348 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 9348 | 9349 |
| 9349 std::string response_data; | 9350 std::string response_data; |
| 9350 rv = ReadTransaction(trans.get(), &response_data); | 9351 rv = ReadTransaction(trans.get(), &response_data); |
| 9351 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 9352 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
| 9352 } | 9353 } |
| 9353 | 9354 |
| 9354 TEST_P(HttpNetworkTransactionTest, UploadFileSmallerThanLength) { | 9355 TEST_P(HttpNetworkTransactionTest, UploadFileSmallerThanLength) { |
| 9355 base::FilePath temp_file_path; | 9356 base::FilePath temp_file_path; |
| 9356 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path)); | 9357 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 9384 | 9385 |
| 9385 TestCompletionCallback callback; | 9386 TestCompletionCallback callback; |
| 9386 | 9387 |
| 9387 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9388 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9388 EXPECT_EQ(ERR_IO_PENDING, rv); | 9389 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9389 | 9390 |
| 9390 rv = callback.WaitForResult(); | 9391 rv = callback.WaitForResult(); |
| 9391 EXPECT_EQ(OK, rv); | 9392 EXPECT_EQ(OK, rv); |
| 9392 | 9393 |
| 9393 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9394 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9394 ASSERT_TRUE(response != NULL); | 9395 ASSERT_TRUE(response); |
| 9395 | 9396 |
| 9396 EXPECT_TRUE(response->headers.get() != NULL); | 9397 EXPECT_TRUE(response->headers); |
| 9397 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 9398 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 9398 | 9399 |
| 9399 std::string response_data; | 9400 std::string response_data; |
| 9400 rv = ReadTransaction(trans.get(), &response_data); | 9401 rv = ReadTransaction(trans.get(), &response_data); |
| 9401 EXPECT_EQ(OK, rv); | 9402 EXPECT_EQ(OK, rv); |
| 9402 EXPECT_EQ("hello world", response_data); | 9403 EXPECT_EQ("hello world", response_data); |
| 9403 | 9404 |
| 9404 base::DeleteFile(temp_file_path, false); | 9405 base::DeleteFile(temp_file_path, false); |
| 9405 } | 9406 } |
| 9406 | 9407 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9591 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9592 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9592 | 9593 |
| 9593 // Issue the first request with Authorize headers. There should be a | 9594 // Issue the first request with Authorize headers. There should be a |
| 9594 // password prompt for first_realm waiting to be filled in after the | 9595 // password prompt for first_realm waiting to be filled in after the |
| 9595 // transaction completes. | 9596 // transaction completes. |
| 9596 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 9597 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 9597 EXPECT_EQ(ERR_IO_PENDING, rv); | 9598 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9598 rv = callback1.WaitForResult(); | 9599 rv = callback1.WaitForResult(); |
| 9599 EXPECT_EQ(OK, rv); | 9600 EXPECT_EQ(OK, rv); |
| 9600 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9601 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9601 ASSERT_TRUE(response != NULL); | 9602 ASSERT_TRUE(response); |
| 9602 const AuthChallengeInfo* challenge = response->auth_challenge.get(); | 9603 const AuthChallengeInfo* challenge = response->auth_challenge.get(); |
| 9603 ASSERT_FALSE(challenge == NULL); | 9604 ASSERT_TRUE(challenge); |
| 9604 EXPECT_FALSE(challenge->is_proxy); | 9605 EXPECT_FALSE(challenge->is_proxy); |
| 9605 EXPECT_EQ("www.example.org:80", challenge->challenger.ToString()); | 9606 EXPECT_EQ("www.example.org:80", challenge->challenger.ToString()); |
| 9606 EXPECT_EQ("first_realm", challenge->realm); | 9607 EXPECT_EQ("first_realm", challenge->realm); |
| 9607 EXPECT_EQ(kBasicAuthScheme, challenge->scheme); | 9608 EXPECT_EQ(kBasicAuthScheme, challenge->scheme); |
| 9608 | 9609 |
| 9609 // Issue the second request with an incorrect password. There should be a | 9610 // Issue the second request with an incorrect password. There should be a |
| 9610 // password prompt for second_realm waiting to be filled in after the | 9611 // password prompt for second_realm waiting to be filled in after the |
| 9611 // transaction completes. | 9612 // transaction completes. |
| 9612 TestCompletionCallback callback2; | 9613 TestCompletionCallback callback2; |
| 9613 rv = trans->RestartWithAuth( | 9614 rv = trans->RestartWithAuth( |
| 9614 AuthCredentials(kFirst, kBaz), callback2.callback()); | 9615 AuthCredentials(kFirst, kBaz), callback2.callback()); |
| 9615 EXPECT_EQ(ERR_IO_PENDING, rv); | 9616 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9616 rv = callback2.WaitForResult(); | 9617 rv = callback2.WaitForResult(); |
| 9617 EXPECT_EQ(OK, rv); | 9618 EXPECT_EQ(OK, rv); |
| 9618 response = trans->GetResponseInfo(); | 9619 response = trans->GetResponseInfo(); |
| 9619 ASSERT_TRUE(response != NULL); | 9620 ASSERT_TRUE(response); |
| 9620 challenge = response->auth_challenge.get(); | 9621 challenge = response->auth_challenge.get(); |
| 9621 ASSERT_FALSE(challenge == NULL); | 9622 ASSERT_TRUE(challenge); |
| 9622 EXPECT_FALSE(challenge->is_proxy); | 9623 EXPECT_FALSE(challenge->is_proxy); |
| 9623 EXPECT_EQ("www.example.org:80", challenge->challenger.ToString()); | 9624 EXPECT_EQ("www.example.org:80", challenge->challenger.ToString()); |
| 9624 EXPECT_EQ("second_realm", challenge->realm); | 9625 EXPECT_EQ("second_realm", challenge->realm); |
| 9625 EXPECT_EQ(kBasicAuthScheme, challenge->scheme); | 9626 EXPECT_EQ(kBasicAuthScheme, challenge->scheme); |
| 9626 | 9627 |
| 9627 // Issue the third request with another incorrect password. There should be | 9628 // Issue the third request with another incorrect password. There should be |
| 9628 // a password prompt for first_realm waiting to be filled in. If the password | 9629 // a password prompt for first_realm waiting to be filled in. If the password |
| 9629 // prompt is not present, it indicates that the HttpAuthCacheEntry for | 9630 // prompt is not present, it indicates that the HttpAuthCacheEntry for |
| 9630 // first_realm was not correctly removed. | 9631 // first_realm was not correctly removed. |
| 9631 TestCompletionCallback callback3; | 9632 TestCompletionCallback callback3; |
| 9632 rv = trans->RestartWithAuth( | 9633 rv = trans->RestartWithAuth( |
| 9633 AuthCredentials(kSecond, kFou), callback3.callback()); | 9634 AuthCredentials(kSecond, kFou), callback3.callback()); |
| 9634 EXPECT_EQ(ERR_IO_PENDING, rv); | 9635 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9635 rv = callback3.WaitForResult(); | 9636 rv = callback3.WaitForResult(); |
| 9636 EXPECT_EQ(OK, rv); | 9637 EXPECT_EQ(OK, rv); |
| 9637 response = trans->GetResponseInfo(); | 9638 response = trans->GetResponseInfo(); |
| 9638 ASSERT_TRUE(response != NULL); | 9639 ASSERT_TRUE(response); |
| 9639 challenge = response->auth_challenge.get(); | 9640 challenge = response->auth_challenge.get(); |
| 9640 ASSERT_FALSE(challenge == NULL); | 9641 ASSERT_TRUE(challenge); |
| 9641 EXPECT_FALSE(challenge->is_proxy); | 9642 EXPECT_FALSE(challenge->is_proxy); |
| 9642 EXPECT_EQ("www.example.org:80", challenge->challenger.ToString()); | 9643 EXPECT_EQ("www.example.org:80", challenge->challenger.ToString()); |
| 9643 EXPECT_EQ("first_realm", challenge->realm); | 9644 EXPECT_EQ("first_realm", challenge->realm); |
| 9644 EXPECT_EQ(kBasicAuthScheme, challenge->scheme); | 9645 EXPECT_EQ(kBasicAuthScheme, challenge->scheme); |
| 9645 | 9646 |
| 9646 // Issue the fourth request with the correct password and username. | 9647 // Issue the fourth request with the correct password and username. |
| 9647 TestCompletionCallback callback4; | 9648 TestCompletionCallback callback4; |
| 9648 rv = trans->RestartWithAuth( | 9649 rv = trans->RestartWithAuth( |
| 9649 AuthCredentials(kFirst, kBar), callback4.callback()); | 9650 AuthCredentials(kFirst, kBar), callback4.callback()); |
| 9650 EXPECT_EQ(ERR_IO_PENDING, rv); | 9651 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9651 rv = callback4.WaitForResult(); | 9652 rv = callback4.WaitForResult(); |
| 9652 EXPECT_EQ(OK, rv); | 9653 EXPECT_EQ(OK, rv); |
| 9653 response = trans->GetResponseInfo(); | 9654 response = trans->GetResponseInfo(); |
| 9654 ASSERT_TRUE(response != NULL); | 9655 ASSERT_TRUE(response); |
| 9655 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 9656 EXPECT_FALSE(response->auth_challenge); |
| 9656 } | 9657 } |
| 9657 | 9658 |
| 9658 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { | 9659 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { |
| 9659 session_deps_.parse_alternative_services = true; | 9660 session_deps_.parse_alternative_services = true; |
| 9660 session_deps_.enable_alternative_service_with_different_host = false; | 9661 session_deps_.enable_alternative_service_with_different_host = false; |
| 9661 | 9662 |
| 9662 std::string alternative_service_http_header = | 9663 std::string alternative_service_http_header = |
| 9663 GetAlternativeServiceHttpHeader(); | 9664 GetAlternativeServiceHttpHeader(); |
| 9664 | 9665 |
| 9665 MockRead data_reads[] = { | 9666 MockRead data_reads[] = { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 9691 url::SchemeHostPort test_server("http", "www.example.org", 80); | 9692 url::SchemeHostPort test_server("http", "www.example.org", 80); |
| 9692 HttpServerProperties& http_server_properties = | 9693 HttpServerProperties& http_server_properties = |
| 9693 *session->http_server_properties(); | 9694 *session->http_server_properties(); |
| 9694 AlternativeServiceVector alternative_service_vector = | 9695 AlternativeServiceVector alternative_service_vector = |
| 9695 http_server_properties.GetAlternativeServices(test_server); | 9696 http_server_properties.GetAlternativeServices(test_server); |
| 9696 EXPECT_TRUE(alternative_service_vector.empty()); | 9697 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9697 | 9698 |
| 9698 EXPECT_EQ(OK, callback.WaitForResult()); | 9699 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9699 | 9700 |
| 9700 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9701 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9701 ASSERT_TRUE(response != NULL); | 9702 ASSERT_TRUE(response); |
| 9702 ASSERT_TRUE(response->headers.get() != NULL); | 9703 ASSERT_TRUE(response->headers); |
| 9703 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9704 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9704 EXPECT_FALSE(response->was_fetched_via_spdy); | 9705 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9705 EXPECT_FALSE(response->was_npn_negotiated); | 9706 EXPECT_FALSE(response->was_npn_negotiated); |
| 9706 | 9707 |
| 9707 std::string response_data; | 9708 std::string response_data; |
| 9708 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9709 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9709 EXPECT_EQ("hello world", response_data); | 9710 EXPECT_EQ("hello world", response_data); |
| 9710 | 9711 |
| 9711 alternative_service_vector = | 9712 alternative_service_vector = |
| 9712 http_server_properties.GetAlternativeServices(test_server); | 9713 http_server_properties.GetAlternativeServices(test_server); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9752 | 9753 |
| 9753 TestCompletionCallback callback; | 9754 TestCompletionCallback callback; |
| 9754 | 9755 |
| 9755 std::unique_ptr<HttpTransaction> trans( | 9756 std::unique_ptr<HttpTransaction> trans( |
| 9756 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9757 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9757 | 9758 |
| 9758 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9759 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9759 EXPECT_EQ(OK, callback.GetResult(rv)); | 9760 EXPECT_EQ(OK, callback.GetResult(rv)); |
| 9760 | 9761 |
| 9761 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9762 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9762 ASSERT_TRUE(response != nullptr); | 9763 ASSERT_TRUE(response); |
| 9763 ASSERT_TRUE(response->headers.get() != nullptr); | 9764 ASSERT_TRUE(response->headers); |
| 9764 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9765 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9765 EXPECT_FALSE(response->was_fetched_via_spdy); | 9766 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9766 EXPECT_FALSE(response->was_npn_negotiated); | 9767 EXPECT_FALSE(response->was_npn_negotiated); |
| 9767 | 9768 |
| 9768 std::string response_data; | 9769 std::string response_data; |
| 9769 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9770 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9770 EXPECT_EQ("hello world", response_data); | 9771 EXPECT_EQ("hello world", response_data); |
| 9771 | 9772 |
| 9772 alternative_service_vector = | 9773 alternative_service_vector = |
| 9773 http_server_properties.GetAlternativeServices(test_server); | 9774 http_server_properties.GetAlternativeServices(test_server); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9811 url::SchemeHostPort test_server("http", "www.example.org", 80); | 9812 url::SchemeHostPort test_server("http", "www.example.org", 80); |
| 9812 HttpServerProperties& http_server_properties = | 9813 HttpServerProperties& http_server_properties = |
| 9813 *session->http_server_properties(); | 9814 *session->http_server_properties(); |
| 9814 AlternativeServiceVector alternative_service_vector = | 9815 AlternativeServiceVector alternative_service_vector = |
| 9815 http_server_properties.GetAlternativeServices(test_server); | 9816 http_server_properties.GetAlternativeServices(test_server); |
| 9816 EXPECT_TRUE(alternative_service_vector.empty()); | 9817 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9817 | 9818 |
| 9818 EXPECT_EQ(OK, callback.WaitForResult()); | 9819 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9819 | 9820 |
| 9820 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9821 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9821 ASSERT_TRUE(response != nullptr); | 9822 ASSERT_TRUE(response); |
| 9822 ASSERT_TRUE(response->headers.get() != nullptr); | 9823 ASSERT_TRUE(response->headers); |
| 9823 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9824 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9824 EXPECT_FALSE(response->was_fetched_via_spdy); | 9825 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9825 EXPECT_FALSE(response->was_npn_negotiated); | 9826 EXPECT_FALSE(response->was_npn_negotiated); |
| 9826 | 9827 |
| 9827 std::string response_data; | 9828 std::string response_data; |
| 9828 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9829 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9829 EXPECT_EQ("hello world", response_data); | 9830 EXPECT_EQ("hello world", response_data); |
| 9830 | 9831 |
| 9831 alternative_service_vector = | 9832 alternative_service_vector = |
| 9832 http_server_properties.GetAlternativeServices(test_server); | 9833 http_server_properties.GetAlternativeServices(test_server); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9869 url::SchemeHostPort test_server("http", "www.example.org", 80); | 9870 url::SchemeHostPort test_server("http", "www.example.org", 80); |
| 9870 HttpServerProperties& http_server_properties = | 9871 HttpServerProperties& http_server_properties = |
| 9871 *session->http_server_properties(); | 9872 *session->http_server_properties(); |
| 9872 AlternativeServiceVector alternative_service_vector = | 9873 AlternativeServiceVector alternative_service_vector = |
| 9873 http_server_properties.GetAlternativeServices(test_server); | 9874 http_server_properties.GetAlternativeServices(test_server); |
| 9874 EXPECT_TRUE(alternative_service_vector.empty()); | 9875 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9875 | 9876 |
| 9876 EXPECT_EQ(OK, callback.WaitForResult()); | 9877 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9877 | 9878 |
| 9878 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9879 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9879 ASSERT_TRUE(response != NULL); | 9880 ASSERT_TRUE(response); |
| 9880 ASSERT_TRUE(response->headers.get() != NULL); | 9881 ASSERT_TRUE(response->headers); |
| 9881 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9882 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9882 EXPECT_FALSE(response->was_fetched_via_spdy); | 9883 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9883 EXPECT_FALSE(response->was_npn_negotiated); | 9884 EXPECT_FALSE(response->was_npn_negotiated); |
| 9884 | 9885 |
| 9885 std::string response_data; | 9886 std::string response_data; |
| 9886 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9887 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9887 EXPECT_EQ("hello world", response_data); | 9888 EXPECT_EQ("hello world", response_data); |
| 9888 | 9889 |
| 9889 alternative_service_vector = | 9890 alternative_service_vector = |
| 9890 http_server_properties.GetAlternativeServices(test_server); | 9891 http_server_properties.GetAlternativeServices(test_server); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9936 url::SchemeHostPort test_server("http", "www.example.org", 80); | 9937 url::SchemeHostPort test_server("http", "www.example.org", 80); |
| 9937 HttpServerProperties& http_server_properties = | 9938 HttpServerProperties& http_server_properties = |
| 9938 *session->http_server_properties(); | 9939 *session->http_server_properties(); |
| 9939 AlternativeServiceVector alternative_service_vector = | 9940 AlternativeServiceVector alternative_service_vector = |
| 9940 http_server_properties.GetAlternativeServices(test_server); | 9941 http_server_properties.GetAlternativeServices(test_server); |
| 9941 EXPECT_TRUE(alternative_service_vector.empty()); | 9942 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9942 | 9943 |
| 9943 EXPECT_EQ(OK, callback.WaitForResult()); | 9944 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9944 | 9945 |
| 9945 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9946 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9946 ASSERT_TRUE(response != NULL); | 9947 ASSERT_TRUE(response); |
| 9947 ASSERT_TRUE(response->headers.get() != NULL); | 9948 ASSERT_TRUE(response->headers); |
| 9948 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9949 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9949 EXPECT_FALSE(response->was_fetched_via_spdy); | 9950 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9950 EXPECT_FALSE(response->was_npn_negotiated); | 9951 EXPECT_FALSE(response->was_npn_negotiated); |
| 9951 | 9952 |
| 9952 std::string response_data; | 9953 std::string response_data; |
| 9953 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9954 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9954 EXPECT_EQ("hello world", response_data); | 9955 EXPECT_EQ("hello world", response_data); |
| 9955 | 9956 |
| 9956 alternative_service_vector = | 9957 alternative_service_vector = |
| 9957 http_server_properties.GetAlternativeServices(test_server); | 9958 http_server_properties.GetAlternativeServices(test_server); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10000 | 10001 |
| 10001 std::unique_ptr<HttpTransaction> trans( | 10002 std::unique_ptr<HttpTransaction> trans( |
| 10002 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10003 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10003 | 10004 |
| 10004 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10005 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10005 EXPECT_EQ(ERR_IO_PENDING, rv); | 10006 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10006 | 10007 |
| 10007 EXPECT_EQ(OK, callback.WaitForResult()); | 10008 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10008 | 10009 |
| 10009 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10010 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10010 ASSERT_TRUE(response != NULL); | 10011 ASSERT_TRUE(response); |
| 10011 ASSERT_TRUE(response->headers.get() != NULL); | 10012 ASSERT_TRUE(response->headers); |
| 10012 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10013 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10013 EXPECT_FALSE(response->was_fetched_via_spdy); | 10014 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10014 EXPECT_FALSE(response->was_npn_negotiated); | 10015 EXPECT_FALSE(response->was_npn_negotiated); |
| 10015 | 10016 |
| 10016 std::string response_data; | 10017 std::string response_data; |
| 10017 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10018 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10018 EXPECT_EQ("hello world", response_data); | 10019 EXPECT_EQ("hello world", response_data); |
| 10019 | 10020 |
| 10020 alternative_service_vector = | 10021 alternative_service_vector = |
| 10021 http_server_properties.GetAlternativeServices(test_server); | 10022 http_server_properties.GetAlternativeServices(test_server); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10062 url::SchemeHostPort test_server("http", "www.example.org", 80); | 10063 url::SchemeHostPort test_server("http", "www.example.org", 80); |
| 10063 HttpServerProperties& http_server_properties = | 10064 HttpServerProperties& http_server_properties = |
| 10064 *session->http_server_properties(); | 10065 *session->http_server_properties(); |
| 10065 AlternativeServiceVector alternative_service_vector = | 10066 AlternativeServiceVector alternative_service_vector = |
| 10066 http_server_properties.GetAlternativeServices(test_server); | 10067 http_server_properties.GetAlternativeServices(test_server); |
| 10067 EXPECT_TRUE(alternative_service_vector.empty()); | 10068 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10068 | 10069 |
| 10069 EXPECT_EQ(OK, callback.WaitForResult()); | 10070 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10070 | 10071 |
| 10071 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10072 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10072 ASSERT_TRUE(response != NULL); | 10073 ASSERT_TRUE(response); |
| 10073 ASSERT_TRUE(response->headers.get() != NULL); | 10074 ASSERT_TRUE(response->headers); |
| 10074 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10075 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10075 EXPECT_FALSE(response->was_fetched_via_spdy); | 10076 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10076 EXPECT_FALSE(response->was_npn_negotiated); | 10077 EXPECT_FALSE(response->was_npn_negotiated); |
| 10077 | 10078 |
| 10078 std::string response_data; | 10079 std::string response_data; |
| 10079 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10080 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10080 EXPECT_EQ("hello world", response_data); | 10081 EXPECT_EQ("hello world", response_data); |
| 10081 | 10082 |
| 10082 alternative_service_vector = | 10083 alternative_service_vector = |
| 10083 http_server_properties.GetAlternativeServices(test_server); | 10084 http_server_properties.GetAlternativeServices(test_server); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10311 | 10312 |
| 10312 std::unique_ptr<HttpTransaction> trans( | 10313 std::unique_ptr<HttpTransaction> trans( |
| 10313 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10314 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10314 TestCompletionCallback callback; | 10315 TestCompletionCallback callback; |
| 10315 | 10316 |
| 10316 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10317 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10317 EXPECT_EQ(ERR_IO_PENDING, rv); | 10318 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10318 EXPECT_EQ(OK, callback.WaitForResult()); | 10319 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10319 | 10320 |
| 10320 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10321 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10321 ASSERT_TRUE(response != NULL); | 10322 ASSERT_TRUE(response); |
| 10322 ASSERT_TRUE(response->headers.get() != NULL); | 10323 ASSERT_TRUE(response->headers); |
| 10323 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10324 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10324 | 10325 |
| 10325 std::string response_data; | 10326 std::string response_data; |
| 10326 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10327 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10327 EXPECT_EQ("hello world", response_data); | 10328 EXPECT_EQ("hello world", response_data); |
| 10328 | 10329 |
| 10329 const AlternativeServiceVector alternative_service_vector = | 10330 const AlternativeServiceVector alternative_service_vector = |
| 10330 http_server_properties->GetAlternativeServices(server); | 10331 http_server_properties->GetAlternativeServices(server); |
| 10331 ASSERT_EQ(1u, alternative_service_vector.size()); | 10332 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 10332 EXPECT_EQ(alternative_service, alternative_service_vector[0]); | 10333 EXPECT_EQ(alternative_service, alternative_service_vector[0]); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10634 std::unique_ptr<HttpTransaction> trans( | 10635 std::unique_ptr<HttpTransaction> trans( |
| 10635 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10636 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10636 TestCompletionCallback callback; | 10637 TestCompletionCallback callback; |
| 10637 | 10638 |
| 10638 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10639 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10639 EXPECT_EQ(ERR_IO_PENDING, rv); | 10640 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10640 // The HTTP request should succeed. | 10641 // The HTTP request should succeed. |
| 10641 EXPECT_EQ(OK, callback.WaitForResult()); | 10642 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10642 | 10643 |
| 10643 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10644 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10644 ASSERT_TRUE(response != NULL); | 10645 ASSERT_TRUE(response); |
| 10645 ASSERT_TRUE(response->headers.get() != NULL); | 10646 ASSERT_TRUE(response->headers); |
| 10646 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10647 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10647 | 10648 |
| 10648 std::string response_data; | 10649 std::string response_data; |
| 10649 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10650 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10650 EXPECT_EQ("hello world", response_data); | 10651 EXPECT_EQ("hello world", response_data); |
| 10651 } | 10652 } |
| 10652 | 10653 |
| 10653 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { | 10654 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { |
| 10654 session_deps_.parse_alternative_services = false; | 10655 session_deps_.parse_alternative_services = false; |
| 10655 session_deps_.enable_alternative_service_with_different_host = false; | 10656 session_deps_.enable_alternative_service_with_different_host = false; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10708 | 10709 |
| 10709 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10710 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10710 std::unique_ptr<HttpTransaction> trans( | 10711 std::unique_ptr<HttpTransaction> trans( |
| 10711 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10712 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10712 | 10713 |
| 10713 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10714 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10714 EXPECT_EQ(ERR_IO_PENDING, rv); | 10715 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10715 EXPECT_EQ(OK, callback.WaitForResult()); | 10716 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10716 | 10717 |
| 10717 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10718 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10718 ASSERT_TRUE(response != NULL); | 10719 ASSERT_TRUE(response); |
| 10719 ASSERT_TRUE(response->headers.get() != NULL); | 10720 ASSERT_TRUE(response->headers); |
| 10720 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10721 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10721 | 10722 |
| 10722 std::string response_data; | 10723 std::string response_data; |
| 10723 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10724 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10724 EXPECT_EQ("hello world", response_data); | 10725 EXPECT_EQ("hello world", response_data); |
| 10725 | 10726 |
| 10726 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10727 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10727 | 10728 |
| 10728 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10729 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10729 EXPECT_EQ(ERR_IO_PENDING, rv); | 10730 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10730 EXPECT_EQ(OK, callback.WaitForResult()); | 10731 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10731 | 10732 |
| 10732 response = trans->GetResponseInfo(); | 10733 response = trans->GetResponseInfo(); |
| 10733 ASSERT_TRUE(response != NULL); | 10734 ASSERT_TRUE(response); |
| 10734 ASSERT_TRUE(response->headers.get() != NULL); | 10735 ASSERT_TRUE(response->headers); |
| 10735 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10736 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10736 EXPECT_TRUE(response->was_fetched_via_spdy); | 10737 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10737 EXPECT_TRUE(response->was_npn_negotiated); | 10738 EXPECT_TRUE(response->was_npn_negotiated); |
| 10738 | 10739 |
| 10739 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10740 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10740 EXPECT_EQ("hello!", response_data); | 10741 EXPECT_EQ("hello!", response_data); |
| 10741 } | 10742 } |
| 10742 | 10743 |
| 10743 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { | 10744 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { |
| 10744 session_deps_.parse_alternative_services = false; | 10745 session_deps_.parse_alternative_services = false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 10773 // non-Alternate-Protocol jobs from the 2nd transaction. | 10774 // non-Alternate-Protocol jobs from the 2nd transaction. |
| 10774 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket1); | 10775 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket1); |
| 10775 | 10776 |
| 10776 StaticSocketDataProvider hanging_socket2(NULL, 0, NULL, 0); | 10777 StaticSocketDataProvider hanging_socket2(NULL, 0, NULL, 0); |
| 10777 hanging_socket2.set_connect_data(never_finishing_connect); | 10778 hanging_socket2.set_connect_data(never_finishing_connect); |
| 10778 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket2); | 10779 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket2); |
| 10779 | 10780 |
| 10780 SSLSocketDataProvider ssl(ASYNC, OK); | 10781 SSLSocketDataProvider ssl(ASYNC, OK); |
| 10781 ssl.SetNextProto(GetProtocol()); | 10782 ssl.SetNextProto(GetProtocol()); |
| 10782 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 10783 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 10783 ASSERT_TRUE(ssl.cert.get()); | 10784 ASSERT_TRUE(ssl.cert); |
| 10784 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 10785 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 10785 | 10786 |
| 10786 std::unique_ptr<SpdySerializedFrame> req1( | 10787 std::unique_ptr<SpdySerializedFrame> req1( |
| 10787 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 10788 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 10788 std::unique_ptr<SpdySerializedFrame> req2( | 10789 std::unique_ptr<SpdySerializedFrame> req2( |
| 10789 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); | 10790 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); |
| 10790 MockWrite spdy_writes[] = { | 10791 MockWrite spdy_writes[] = { |
| 10791 CreateMockWrite(*req1, 0), CreateMockWrite(*req2, 1), | 10792 CreateMockWrite(*req1, 0), CreateMockWrite(*req2, 1), |
| 10792 }; | 10793 }; |
| 10793 std::unique_ptr<SpdySerializedFrame> resp1( | 10794 std::unique_ptr<SpdySerializedFrame> resp1( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 10818 | 10819 |
| 10819 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10820 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10820 TestCompletionCallback callback1; | 10821 TestCompletionCallback callback1; |
| 10821 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 10822 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 10822 | 10823 |
| 10823 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); | 10824 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); |
| 10824 EXPECT_EQ(ERR_IO_PENDING, rv); | 10825 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10825 EXPECT_EQ(OK, callback1.WaitForResult()); | 10826 EXPECT_EQ(OK, callback1.WaitForResult()); |
| 10826 | 10827 |
| 10827 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 10828 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 10828 ASSERT_TRUE(response != NULL); | 10829 ASSERT_TRUE(response); |
| 10829 ASSERT_TRUE(response->headers.get() != NULL); | 10830 ASSERT_TRUE(response->headers); |
| 10830 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10831 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10831 | 10832 |
| 10832 std::string response_data; | 10833 std::string response_data; |
| 10833 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 10834 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 10834 EXPECT_EQ("hello world", response_data); | 10835 EXPECT_EQ("hello world", response_data); |
| 10835 | 10836 |
| 10836 TestCompletionCallback callback2; | 10837 TestCompletionCallback callback2; |
| 10837 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); | 10838 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
| 10838 rv = trans2.Start(&request, callback2.callback(), BoundNetLog()); | 10839 rv = trans2.Start(&request, callback2.callback(), BoundNetLog()); |
| 10839 EXPECT_EQ(ERR_IO_PENDING, rv); | 10840 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10840 | 10841 |
| 10841 TestCompletionCallback callback3; | 10842 TestCompletionCallback callback3; |
| 10842 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, session.get()); | 10843 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, session.get()); |
| 10843 rv = trans3.Start(&request, callback3.callback(), BoundNetLog()); | 10844 rv = trans3.Start(&request, callback3.callback(), BoundNetLog()); |
| 10844 EXPECT_EQ(ERR_IO_PENDING, rv); | 10845 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10845 | 10846 |
| 10846 EXPECT_EQ(OK, callback2.WaitForResult()); | 10847 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 10847 EXPECT_EQ(OK, callback3.WaitForResult()); | 10848 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 10848 | 10849 |
| 10849 response = trans2.GetResponseInfo(); | 10850 response = trans2.GetResponseInfo(); |
| 10850 ASSERT_TRUE(response != NULL); | 10851 ASSERT_TRUE(response); |
| 10851 ASSERT_TRUE(response->headers.get() != NULL); | 10852 ASSERT_TRUE(response->headers); |
| 10852 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10853 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10853 EXPECT_TRUE(response->was_fetched_via_spdy); | 10854 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10854 EXPECT_TRUE(response->was_npn_negotiated); | 10855 EXPECT_TRUE(response->was_npn_negotiated); |
| 10855 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 10856 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 10856 EXPECT_EQ("hello!", response_data); | 10857 EXPECT_EQ("hello!", response_data); |
| 10857 | 10858 |
| 10858 response = trans3.GetResponseInfo(); | 10859 response = trans3.GetResponseInfo(); |
| 10859 ASSERT_TRUE(response != NULL); | 10860 ASSERT_TRUE(response); |
| 10860 ASSERT_TRUE(response->headers.get() != NULL); | 10861 ASSERT_TRUE(response->headers); |
| 10861 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10862 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10862 EXPECT_TRUE(response->was_fetched_via_spdy); | 10863 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10863 EXPECT_TRUE(response->was_npn_negotiated); | 10864 EXPECT_TRUE(response->was_npn_negotiated); |
| 10864 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); | 10865 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); |
| 10865 EXPECT_EQ("hello!", response_data); | 10866 EXPECT_EQ("hello!", response_data); |
| 10866 } | 10867 } |
| 10867 | 10868 |
| 10868 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { | 10869 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { |
| 10869 session_deps_.parse_alternative_services = false; | 10870 session_deps_.parse_alternative_services = false; |
| 10870 session_deps_.enable_alternative_service_with_different_host = false; | 10871 session_deps_.enable_alternative_service_with_different_host = false; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10911 | 10912 |
| 10912 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10913 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10913 std::unique_ptr<HttpTransaction> trans( | 10914 std::unique_ptr<HttpTransaction> trans( |
| 10914 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10915 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10915 | 10916 |
| 10916 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10917 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10917 EXPECT_EQ(ERR_IO_PENDING, rv); | 10918 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10918 EXPECT_EQ(OK, callback.WaitForResult()); | 10919 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10919 | 10920 |
| 10920 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10921 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10921 ASSERT_TRUE(response != NULL); | 10922 ASSERT_TRUE(response); |
| 10922 ASSERT_TRUE(response->headers.get() != NULL); | 10923 ASSERT_TRUE(response->headers); |
| 10923 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10924 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10924 | 10925 |
| 10925 std::string response_data; | 10926 std::string response_data; |
| 10926 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10927 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10927 EXPECT_EQ("hello world", response_data); | 10928 EXPECT_EQ("hello world", response_data); |
| 10928 | 10929 |
| 10929 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10930 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10930 | 10931 |
| 10931 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10932 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10932 EXPECT_EQ(ERR_IO_PENDING, rv); | 10933 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10933 EXPECT_EQ(OK, callback.WaitForResult()); | 10934 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10934 | 10935 |
| 10935 response = trans->GetResponseInfo(); | 10936 response = trans->GetResponseInfo(); |
| 10936 ASSERT_TRUE(response != NULL); | 10937 ASSERT_TRUE(response); |
| 10937 ASSERT_TRUE(response->headers.get() != NULL); | 10938 ASSERT_TRUE(response->headers); |
| 10938 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10939 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10939 EXPECT_FALSE(response->was_fetched_via_spdy); | 10940 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10940 EXPECT_FALSE(response->was_npn_negotiated); | 10941 EXPECT_FALSE(response->was_npn_negotiated); |
| 10941 | 10942 |
| 10942 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10943 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10943 EXPECT_EQ("hello world", response_data); | 10944 EXPECT_EQ("hello world", response_data); |
| 10944 } | 10945 } |
| 10945 | 10946 |
| 10946 class CapturingProxyResolver : public ProxyResolver { | 10947 class CapturingProxyResolver : public ProxyResolver { |
| 10947 public: | 10948 public: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11028 MockRead(ASYNC, OK), | 11029 MockRead(ASYNC, OK), |
| 11029 }; | 11030 }; |
| 11030 | 11031 |
| 11031 StaticSocketDataProvider first_transaction( | 11032 StaticSocketDataProvider first_transaction( |
| 11032 data_reads, arraysize(data_reads), NULL, 0); | 11033 data_reads, arraysize(data_reads), NULL, 0); |
| 11033 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11034 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11034 | 11035 |
| 11035 SSLSocketDataProvider ssl(ASYNC, OK); | 11036 SSLSocketDataProvider ssl(ASYNC, OK); |
| 11036 ssl.SetNextProto(GetProtocol()); | 11037 ssl.SetNextProto(GetProtocol()); |
| 11037 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 11038 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 11038 ASSERT_TRUE(ssl.cert.get()); | 11039 ASSERT_TRUE(ssl.cert); |
| 11039 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11040 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 11040 | 11041 |
| 11041 std::unique_ptr<SpdySerializedFrame> req( | 11042 std::unique_ptr<SpdySerializedFrame> req( |
| 11042 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 11043 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 11043 MockWrite spdy_writes[] = { | 11044 MockWrite spdy_writes[] = { |
| 11044 MockWrite(ASYNC, 0, | 11045 MockWrite(ASYNC, 0, |
| 11045 "CONNECT www.example.org:443 HTTP/1.1\r\n" | 11046 "CONNECT www.example.org:443 HTTP/1.1\r\n" |
| 11046 "Host: www.example.org:443\r\n" | 11047 "Host: www.example.org:443\r\n" |
| 11047 "Proxy-Connection: keep-alive\r\n\r\n"), | 11048 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 11048 CreateMockWrite(*req, 2), | 11049 CreateMockWrite(*req, 2), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 11075 | 11076 |
| 11076 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 11077 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 11077 std::unique_ptr<HttpTransaction> trans( | 11078 std::unique_ptr<HttpTransaction> trans( |
| 11078 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11079 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11079 | 11080 |
| 11080 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11081 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11081 EXPECT_EQ(ERR_IO_PENDING, rv); | 11082 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11082 EXPECT_EQ(OK, callback.WaitForResult()); | 11083 EXPECT_EQ(OK, callback.WaitForResult()); |
| 11083 | 11084 |
| 11084 const HttpResponseInfo* response = trans->GetResponseInfo(); | 11085 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 11085 ASSERT_TRUE(response != NULL); | 11086 ASSERT_TRUE(response); |
| 11086 ASSERT_TRUE(response->headers.get() != NULL); | 11087 ASSERT_TRUE(response->headers); |
| 11087 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11088 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 11088 EXPECT_FALSE(response->was_fetched_via_spdy); | 11089 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 11089 EXPECT_FALSE(response->was_npn_negotiated); | 11090 EXPECT_FALSE(response->was_npn_negotiated); |
| 11090 | 11091 |
| 11091 std::string response_data; | 11092 std::string response_data; |
| 11092 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11093 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11093 EXPECT_EQ("hello world", response_data); | 11094 EXPECT_EQ("hello world", response_data); |
| 11094 | 11095 |
| 11095 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11096 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11096 | 11097 |
| 11097 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11098 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11098 EXPECT_EQ(ERR_IO_PENDING, rv); | 11099 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11099 EXPECT_EQ(OK, callback.WaitForResult()); | 11100 EXPECT_EQ(OK, callback.WaitForResult()); |
| 11100 | 11101 |
| 11101 response = trans->GetResponseInfo(); | 11102 response = trans->GetResponseInfo(); |
| 11102 ASSERT_TRUE(response != NULL); | 11103 ASSERT_TRUE(response); |
| 11103 ASSERT_TRUE(response->headers.get() != NULL); | 11104 ASSERT_TRUE(response->headers); |
| 11104 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 11105 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 11105 EXPECT_TRUE(response->was_fetched_via_spdy); | 11106 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 11106 EXPECT_TRUE(response->was_npn_negotiated); | 11107 EXPECT_TRUE(response->was_npn_negotiated); |
| 11107 | 11108 |
| 11108 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11109 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11109 EXPECT_EQ("hello!", response_data); | 11110 EXPECT_EQ("hello!", response_data); |
| 11110 ASSERT_EQ(3u, capturing_proxy_resolver.resolved().size()); | 11111 ASSERT_EQ(3u, capturing_proxy_resolver.resolved().size()); |
| 11111 EXPECT_EQ("http://www.example.org/", | 11112 EXPECT_EQ("http://www.example.org/", |
| 11112 capturing_proxy_resolver.resolved()[0].spec()); | 11113 capturing_proxy_resolver.resolved()[0].spec()); |
| 11113 EXPECT_EQ("https://www.example.org/", | 11114 EXPECT_EQ("https://www.example.org/", |
| (...skipping 26 matching lines...) Expand all Loading... |
| 11140 MockRead(ASYNC, OK), | 11141 MockRead(ASYNC, OK), |
| 11141 }; | 11142 }; |
| 11142 | 11143 |
| 11143 StaticSocketDataProvider first_transaction( | 11144 StaticSocketDataProvider first_transaction( |
| 11144 data_reads, arraysize(data_reads), NULL, 0); | 11145 data_reads, arraysize(data_reads), NULL, 0); |
| 11145 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11146 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11146 | 11147 |
| 11147 SSLSocketDataProvider ssl(ASYNC, OK); | 11148 SSLSocketDataProvider ssl(ASYNC, OK); |
| 11148 ssl.SetNextProto(GetProtocol()); | 11149 ssl.SetNextProto(GetProtocol()); |
| 11149 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 11150 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 11150 ASSERT_TRUE(ssl.cert.get()); | 11151 ASSERT_TRUE(ssl.cert); |
| 11151 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11152 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 11152 | 11153 |
| 11153 std::unique_ptr<SpdySerializedFrame> req( | 11154 std::unique_ptr<SpdySerializedFrame> req( |
| 11154 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 11155 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 11155 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; | 11156 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; |
| 11156 | 11157 |
| 11157 std::unique_ptr<SpdySerializedFrame> resp( | 11158 std::unique_ptr<SpdySerializedFrame> resp( |
| 11158 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 11159 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 11159 std::unique_ptr<SpdySerializedFrame> data( | 11160 std::unique_ptr<SpdySerializedFrame> data( |
| 11160 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 11161 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 11171 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 11172 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 11172 | 11173 |
| 11173 std::unique_ptr<HttpTransaction> trans( | 11174 std::unique_ptr<HttpTransaction> trans( |
| 11174 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11175 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11175 | 11176 |
| 11176 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11177 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11177 EXPECT_EQ(ERR_IO_PENDING, rv); | 11178 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11178 EXPECT_EQ(OK, callback.WaitForResult()); | 11179 EXPECT_EQ(OK, callback.WaitForResult()); |
| 11179 | 11180 |
| 11180 const HttpResponseInfo* response = trans->GetResponseInfo(); | 11181 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 11181 ASSERT_TRUE(response != NULL); | 11182 ASSERT_TRUE(response); |
| 11182 ASSERT_TRUE(response->headers.get() != NULL); | 11183 ASSERT_TRUE(response->headers); |
| 11183 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11184 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 11184 | 11185 |
| 11185 std::string response_data; | 11186 std::string response_data; |
| 11186 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11187 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11187 EXPECT_EQ("hello world", response_data); | 11188 EXPECT_EQ("hello world", response_data); |
| 11188 | 11189 |
| 11189 // Set up an initial SpdySession in the pool to reuse. | 11190 // Set up an initial SpdySession in the pool to reuse. |
| 11190 HostPortPair host_port_pair("www.example.org", 443); | 11191 HostPortPair host_port_pair("www.example.org", 443); |
| 11191 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 11192 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 11192 PRIVACY_MODE_DISABLED); | 11193 PRIVACY_MODE_DISABLED); |
| 11193 base::WeakPtr<SpdySession> spdy_session = | 11194 base::WeakPtr<SpdySession> spdy_session = |
| 11194 CreateSecureSpdySession(session.get(), key, BoundNetLog()); | 11195 CreateSecureSpdySession(session.get(), key, BoundNetLog()); |
| 11195 | 11196 |
| 11196 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11197 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11197 | 11198 |
| 11198 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11199 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11199 EXPECT_EQ(ERR_IO_PENDING, rv); | 11200 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11200 EXPECT_EQ(OK, callback.WaitForResult()); | 11201 EXPECT_EQ(OK, callback.WaitForResult()); |
| 11201 | 11202 |
| 11202 response = trans->GetResponseInfo(); | 11203 response = trans->GetResponseInfo(); |
| 11203 ASSERT_TRUE(response != NULL); | 11204 ASSERT_TRUE(response); |
| 11204 ASSERT_TRUE(response->headers.get() != NULL); | 11205 ASSERT_TRUE(response->headers); |
| 11205 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 11206 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 11206 EXPECT_TRUE(response->was_fetched_via_spdy); | 11207 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 11207 EXPECT_TRUE(response->was_npn_negotiated); | 11208 EXPECT_TRUE(response->was_npn_negotiated); |
| 11208 | 11209 |
| 11209 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11210 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11210 EXPECT_EQ("hello!", response_data); | 11211 EXPECT_EQ("hello!", response_data); |
| 11211 } | 11212 } |
| 11212 | 11213 |
| 11213 // GenerateAuthToken is a mighty big test. | 11214 // GenerateAuthToken is a mighty big test. |
| 11214 // It tests all permutation of GenerateAuthToken behavior: | 11215 // It tests all permutation of GenerateAuthToken behavior: |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11622 rv = callback.WaitForResult(); | 11623 rv = callback.WaitForResult(); |
| 11623 | 11624 |
| 11624 // Compare results with expected data. | 11625 // Compare results with expected data. |
| 11625 EXPECT_EQ(read_write_round.expected_rv, rv); | 11626 EXPECT_EQ(read_write_round.expected_rv, rv); |
| 11626 const HttpResponseInfo* response = trans.GetResponseInfo(); | 11627 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 11627 if (read_write_round.expected_rv != OK) { | 11628 if (read_write_round.expected_rv != OK) { |
| 11628 EXPECT_EQ(round + 1, test_config.num_auth_rounds); | 11629 EXPECT_EQ(round + 1, test_config.num_auth_rounds); |
| 11629 continue; | 11630 continue; |
| 11630 } | 11631 } |
| 11631 if (round + 1 < test_config.num_auth_rounds) { | 11632 if (round + 1 < test_config.num_auth_rounds) { |
| 11632 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 11633 EXPECT_TRUE(response->auth_challenge); |
| 11633 } else { | 11634 } else { |
| 11634 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 11635 EXPECT_FALSE(response->auth_challenge); |
| 11635 } | 11636 } |
| 11636 } | 11637 } |
| 11637 } | 11638 } |
| 11638 } | 11639 } |
| 11639 | 11640 |
| 11640 TEST_P(HttpNetworkTransactionTest, MultiRoundAuth) { | 11641 TEST_P(HttpNetworkTransactionTest, MultiRoundAuth) { |
| 11641 // Do multi-round authentication and make sure it works correctly. | 11642 // Do multi-round authentication and make sure it works correctly. |
| 11642 HttpAuthHandlerMock::Factory* auth_factory( | 11643 HttpAuthHandlerMock::Factory* auth_factory( |
| 11643 new HttpAuthHandlerMock::Factory()); | 11644 new HttpAuthHandlerMock::Factory()); |
| 11644 session_deps_.http_auth_handler_factory.reset(auth_factory); | 11645 session_deps_.http_auth_handler_factory.reset(auth_factory); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11736 | 11737 |
| 11737 const char kSocketGroup[] = "www.example.com:80"; | 11738 const char kSocketGroup[] = "www.example.com:80"; |
| 11738 | 11739 |
| 11739 // First round of authentication. | 11740 // First round of authentication. |
| 11740 auth_handler->SetGenerateExpectation(false, OK); | 11741 auth_handler->SetGenerateExpectation(false, OK); |
| 11741 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11742 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11742 if (rv == ERR_IO_PENDING) | 11743 if (rv == ERR_IO_PENDING) |
| 11743 rv = callback.WaitForResult(); | 11744 rv = callback.WaitForResult(); |
| 11744 EXPECT_EQ(OK, rv); | 11745 EXPECT_EQ(OK, rv); |
| 11745 response = trans->GetResponseInfo(); | 11746 response = trans->GetResponseInfo(); |
| 11746 ASSERT_TRUE(response != NULL); | 11747 ASSERT_TRUE(response); |
| 11747 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 11748 EXPECT_TRUE(response->auth_challenge); |
| 11748 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 11749 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 11749 | 11750 |
| 11750 // In between rounds, another request comes in for the same domain. | 11751 // In between rounds, another request comes in for the same domain. |
| 11751 // It should not be able to grab the TCP socket that trans has already | 11752 // It should not be able to grab the TCP socket that trans has already |
| 11752 // claimed. | 11753 // claimed. |
| 11753 std::unique_ptr<HttpTransaction> trans_compete( | 11754 std::unique_ptr<HttpTransaction> trans_compete( |
| 11754 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11755 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11755 TestCompletionCallback callback_compete; | 11756 TestCompletionCallback callback_compete; |
| 11756 rv = trans_compete->Start( | 11757 rv = trans_compete->Start( |
| 11757 &request, callback_compete.callback(), BoundNetLog()); | 11758 &request, callback_compete.callback(), BoundNetLog()); |
| 11758 EXPECT_EQ(ERR_IO_PENDING, rv); | 11759 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11759 // callback_compete.WaitForResult at this point would stall forever, | 11760 // callback_compete.WaitForResult at this point would stall forever, |
| 11760 // since the HttpNetworkTransaction does not release the request back to | 11761 // since the HttpNetworkTransaction does not release the request back to |
| 11761 // the pool until after authentication completes. | 11762 // the pool until after authentication completes. |
| 11762 | 11763 |
| 11763 // Second round of authentication. | 11764 // Second round of authentication. |
| 11764 auth_handler->SetGenerateExpectation(false, OK); | 11765 auth_handler->SetGenerateExpectation(false, OK); |
| 11765 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), callback.callback()); | 11766 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), callback.callback()); |
| 11766 if (rv == ERR_IO_PENDING) | 11767 if (rv == ERR_IO_PENDING) |
| 11767 rv = callback.WaitForResult(); | 11768 rv = callback.WaitForResult(); |
| 11768 EXPECT_EQ(OK, rv); | 11769 EXPECT_EQ(OK, rv); |
| 11769 response = trans->GetResponseInfo(); | 11770 response = trans->GetResponseInfo(); |
| 11770 ASSERT_TRUE(response != NULL); | 11771 ASSERT_TRUE(response); |
| 11771 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 11772 EXPECT_FALSE(response->auth_challenge); |
| 11772 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 11773 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 11773 | 11774 |
| 11774 // Third round of authentication. | 11775 // Third round of authentication. |
| 11775 auth_handler->SetGenerateExpectation(false, OK); | 11776 auth_handler->SetGenerateExpectation(false, OK); |
| 11776 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); | 11777 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); |
| 11777 if (rv == ERR_IO_PENDING) | 11778 if (rv == ERR_IO_PENDING) |
| 11778 rv = callback.WaitForResult(); | 11779 rv = callback.WaitForResult(); |
| 11779 EXPECT_EQ(OK, rv); | 11780 EXPECT_EQ(OK, rv); |
| 11780 response = trans->GetResponseInfo(); | 11781 response = trans->GetResponseInfo(); |
| 11781 ASSERT_TRUE(response != NULL); | 11782 ASSERT_TRUE(response); |
| 11782 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 11783 EXPECT_FALSE(response->auth_challenge); |
| 11783 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 11784 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 11784 | 11785 |
| 11785 // Fourth round of authentication, which completes successfully. | 11786 // Fourth round of authentication, which completes successfully. |
| 11786 auth_handler->SetGenerateExpectation(false, OK); | 11787 auth_handler->SetGenerateExpectation(false, OK); |
| 11787 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); | 11788 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); |
| 11788 if (rv == ERR_IO_PENDING) | 11789 if (rv == ERR_IO_PENDING) |
| 11789 rv = callback.WaitForResult(); | 11790 rv = callback.WaitForResult(); |
| 11790 EXPECT_EQ(OK, rv); | 11791 EXPECT_EQ(OK, rv); |
| 11791 response = trans->GetResponseInfo(); | 11792 response = trans->GetResponseInfo(); |
| 11792 ASSERT_TRUE(response != NULL); | 11793 ASSERT_TRUE(response); |
| 11793 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 11794 EXPECT_FALSE(response->auth_challenge); |
| 11794 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 11795 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 11795 | 11796 |
| 11796 // Read the body since the fourth round was successful. This will also | 11797 // Read the body since the fourth round was successful. This will also |
| 11797 // release the socket back to the pool. | 11798 // release the socket back to the pool. |
| 11798 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); | 11799 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); |
| 11799 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 11800 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
| 11800 if (rv == ERR_IO_PENDING) | 11801 if (rv == ERR_IO_PENDING) |
| 11801 rv = callback.WaitForResult(); | 11802 rv = callback.WaitForResult(); |
| 11802 EXPECT_EQ(3, rv); | 11803 EXPECT_EQ(3, rv); |
| 11803 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 11804 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11864 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 11865 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 11865 std::unique_ptr<HttpTransaction> trans( | 11866 std::unique_ptr<HttpTransaction> trans( |
| 11866 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11867 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11867 | 11868 |
| 11868 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11869 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11869 | 11870 |
| 11870 EXPECT_EQ(ERR_IO_PENDING, rv); | 11871 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11871 EXPECT_EQ(OK, callback.WaitForResult()); | 11872 EXPECT_EQ(OK, callback.WaitForResult()); |
| 11872 | 11873 |
| 11873 const HttpResponseInfo* response = trans->GetResponseInfo(); | 11874 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 11874 ASSERT_TRUE(response != NULL); | 11875 ASSERT_TRUE(response); |
| 11875 ASSERT_TRUE(response->headers.get() != NULL); | 11876 ASSERT_TRUE(response->headers); |
| 11876 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11877 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 11877 | 11878 |
| 11878 std::string response_data; | 11879 std::string response_data; |
| 11879 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11880 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11880 EXPECT_EQ("hello world", response_data); | 11881 EXPECT_EQ("hello world", response_data); |
| 11881 | 11882 |
| 11882 EXPECT_FALSE(response->was_fetched_via_spdy); | 11883 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 11883 EXPECT_TRUE(response->was_npn_negotiated); | 11884 EXPECT_TRUE(response->was_npn_negotiated); |
| 11884 } | 11885 } |
| 11885 | 11886 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12049 // SPDY response | 12050 // SPDY response |
| 12050 CreateMockRead(*resp.get(), 5), CreateMockRead(*data.get(), 6), | 12051 CreateMockRead(*resp.get(), 5), CreateMockRead(*data.get(), 6), |
| 12051 MockRead(ASYNC, 0, 0, 7), | 12052 MockRead(ASYNC, 0, 0, 7), |
| 12052 }; | 12053 }; |
| 12053 SequencedSocketData data_2(data_reads_2, arraysize(data_reads_2), | 12054 SequencedSocketData data_2(data_reads_2, arraysize(data_reads_2), |
| 12054 data_writes_2, arraysize(data_writes_2)); | 12055 data_writes_2, arraysize(data_writes_2)); |
| 12055 | 12056 |
| 12056 SSLSocketDataProvider ssl(ASYNC, OK); | 12057 SSLSocketDataProvider ssl(ASYNC, OK); |
| 12057 ssl.SetNextProto(GetProtocol()); | 12058 ssl.SetNextProto(GetProtocol()); |
| 12058 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 12059 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 12059 ASSERT_TRUE(ssl.cert.get()); | 12060 ASSERT_TRUE(ssl.cert); |
| 12060 | 12061 |
| 12061 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 12062 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 12062 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 12063 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
| 12063 NULL, 0, NULL, 0); | 12064 NULL, 0, NULL, 0); |
| 12064 hanging_non_alternate_protocol_socket.set_connect_data( | 12065 hanging_non_alternate_protocol_socket.set_connect_data( |
| 12065 never_finishing_connect); | 12066 never_finishing_connect); |
| 12066 | 12067 |
| 12067 session_deps_.socket_factory->AddSocketDataProvider(&data_1); | 12068 session_deps_.socket_factory->AddSocketDataProvider(&data_1); |
| 12068 session_deps_.socket_factory->AddSocketDataProvider(&data_2); | 12069 session_deps_.socket_factory->AddSocketDataProvider(&data_2); |
| 12069 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 12070 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 12080 EXPECT_EQ(OK, callback_1.WaitForResult()); | 12081 EXPECT_EQ(OK, callback_1.WaitForResult()); |
| 12081 | 12082 |
| 12082 // Second round should attempt a tunnel connect and get an auth challenge. | 12083 // Second round should attempt a tunnel connect and get an auth challenge. |
| 12083 TestCompletionCallback callback_2; | 12084 TestCompletionCallback callback_2; |
| 12084 std::unique_ptr<HttpTransaction> trans_2( | 12085 std::unique_ptr<HttpTransaction> trans_2( |
| 12085 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 12086 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 12086 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); | 12087 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); |
| 12087 EXPECT_EQ(ERR_IO_PENDING, rv); | 12088 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 12088 EXPECT_EQ(OK, callback_2.WaitForResult()); | 12089 EXPECT_EQ(OK, callback_2.WaitForResult()); |
| 12089 const HttpResponseInfo* response = trans_2->GetResponseInfo(); | 12090 const HttpResponseInfo* response = trans_2->GetResponseInfo(); |
| 12090 ASSERT_TRUE(response != NULL); | 12091 ASSERT_TRUE(response); |
| 12091 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 12092 ASSERT_TRUE(response->auth_challenge); |
| 12092 | 12093 |
| 12093 // Restart with auth. Tunnel should work and response received. | 12094 // Restart with auth. Tunnel should work and response received. |
| 12094 TestCompletionCallback callback_3; | 12095 TestCompletionCallback callback_3; |
| 12095 rv = trans_2->RestartWithAuth( | 12096 rv = trans_2->RestartWithAuth( |
| 12096 AuthCredentials(kFoo, kBar), callback_3.callback()); | 12097 AuthCredentials(kFoo, kBar), callback_3.callback()); |
| 12097 EXPECT_EQ(ERR_IO_PENDING, rv); | 12098 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 12098 EXPECT_EQ(OK, callback_3.WaitForResult()); | 12099 EXPECT_EQ(OK, callback_3.WaitForResult()); |
| 12099 | 12100 |
| 12100 // After all that work, these two lines (or actually, just the scheme) are | 12101 // After all that work, these two lines (or actually, just the scheme) are |
| 12101 // what this test is all about. Make sure it happens correctly. | 12102 // what this test is all about. Make sure it happens correctly. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12176 request.load_flags = 0; | 12177 request.load_flags = 0; |
| 12177 | 12178 |
| 12178 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 12179 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 12179 TestCompletionCallback callback; | 12180 TestCompletionCallback callback; |
| 12180 | 12181 |
| 12181 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 12182 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
| 12182 EXPECT_EQ(ERR_IO_PENDING, rv); | 12183 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 12183 callback.WaitForResult(); | 12184 callback.WaitForResult(); |
| 12184 | 12185 |
| 12185 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12186 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 12186 ASSERT_TRUE(response != NULL); | 12187 ASSERT_TRUE(response); |
| 12187 EXPECT_TRUE(response->headers.get() != NULL); | 12188 EXPECT_TRUE(response->headers); |
| 12188 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 12189 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 12189 | 12190 |
| 12190 // The transaction and HttpRequestInfo are deleted. | 12191 // The transaction and HttpRequestInfo are deleted. |
| 12191 } | 12192 } |
| 12192 | 12193 |
| 12193 // Let the HttpResponseBodyDrainer drain the socket. | 12194 // Let the HttpResponseBodyDrainer drain the socket. |
| 12194 base::MessageLoop::current()->RunUntilIdle(); | 12195 base::MessageLoop::current()->RunUntilIdle(); |
| 12195 | 12196 |
| 12196 // Socket should now be idle, waiting to be reused. | 12197 // Socket should now be idle, waiting to be reused. |
| 12197 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); | 12198 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12236 base::Bind(&BeforeProxyHeadersSentHandler::OnBeforeProxyHeadersSent, | 12237 base::Bind(&BeforeProxyHeadersSentHandler::OnBeforeProxyHeadersSent, |
| 12237 base::Unretained(&proxy_headers_handler))); | 12238 base::Unretained(&proxy_headers_handler))); |
| 12238 | 12239 |
| 12239 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 12240 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 12240 EXPECT_EQ(ERR_IO_PENDING, rv); | 12241 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 12241 | 12242 |
| 12242 rv = callback1.WaitForResult(); | 12243 rv = callback1.WaitForResult(); |
| 12243 EXPECT_EQ(OK, rv); | 12244 EXPECT_EQ(OK, rv); |
| 12244 | 12245 |
| 12245 const HttpResponseInfo* response = trans->GetResponseInfo(); | 12246 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 12246 ASSERT_TRUE(response != NULL); | 12247 ASSERT_TRUE(response); |
| 12247 | 12248 |
| 12248 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12249 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 12249 EXPECT_EQ(200, response->headers->response_code()); | 12250 EXPECT_EQ(200, response->headers->response_code()); |
| 12250 EXPECT_EQ(100, response->headers->GetContentLength()); | 12251 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 12251 EXPECT_TRUE(response->was_fetched_via_proxy); | 12252 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 12252 EXPECT_TRUE( | 12253 EXPECT_TRUE( |
| 12253 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12254 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); |
| 12254 EXPECT_TRUE(proxy_headers_handler.observed_before_proxy_headers_sent()); | 12255 EXPECT_TRUE(proxy_headers_handler.observed_before_proxy_headers_sent()); |
| 12255 EXPECT_EQ("myproxy:70", proxy_headers_handler.observed_proxy_server_uri()); | 12256 EXPECT_EQ("myproxy:70", proxy_headers_handler.observed_proxy_server_uri()); |
| 12256 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12257 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12313 log.GetEntries(&entries); | 12314 log.GetEntries(&entries); |
| 12314 size_t pos = ExpectLogContainsSomewhere( | 12315 size_t pos = ExpectLogContainsSomewhere( |
| 12315 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 12316 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 12316 NetLog::PHASE_NONE); | 12317 NetLog::PHASE_NONE); |
| 12317 ExpectLogContainsSomewhere( | 12318 ExpectLogContainsSomewhere( |
| 12318 entries, pos, | 12319 entries, pos, |
| 12319 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 12320 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 12320 NetLog::PHASE_NONE); | 12321 NetLog::PHASE_NONE); |
| 12321 | 12322 |
| 12322 const HttpResponseInfo* response = trans->GetResponseInfo(); | 12323 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 12323 ASSERT_TRUE(response != NULL); | 12324 ASSERT_TRUE(response); |
| 12324 | 12325 |
| 12325 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12326 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 12326 EXPECT_EQ(200, response->headers->response_code()); | 12327 EXPECT_EQ(200, response->headers->response_code()); |
| 12327 EXPECT_EQ(100, response->headers->GetContentLength()); | 12328 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 12328 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12329 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 12329 EXPECT_TRUE(response->was_fetched_via_proxy); | 12330 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 12330 EXPECT_TRUE( | 12331 EXPECT_TRUE( |
| 12331 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12332 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); |
| 12332 | 12333 |
| 12333 LoadTimingInfo load_timing_info; | 12334 LoadTimingInfo load_timing_info; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12388 TestNetLogEntry::List entries; | 12389 TestNetLogEntry::List entries; |
| 12389 log.GetEntries(&entries); | 12390 log.GetEntries(&entries); |
| 12390 size_t pos = ExpectLogContainsSomewhere( | 12391 size_t pos = ExpectLogContainsSomewhere( |
| 12391 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 12392 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 12392 NetLog::PHASE_NONE); | 12393 NetLog::PHASE_NONE); |
| 12393 ExpectLogContainsSomewhere( | 12394 ExpectLogContainsSomewhere( |
| 12394 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 12395 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 12395 NetLog::PHASE_NONE); | 12396 NetLog::PHASE_NONE); |
| 12396 | 12397 |
| 12397 const HttpResponseInfo* response = trans->GetResponseInfo(); | 12398 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 12398 ASSERT_TRUE(response != NULL); | 12399 ASSERT_TRUE(response); |
| 12399 | 12400 |
| 12400 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12401 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 12401 EXPECT_EQ(200, response->headers->response_code()); | 12402 EXPECT_EQ(200, response->headers->response_code()); |
| 12402 EXPECT_EQ(100, response->headers->GetContentLength()); | 12403 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 12403 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12404 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 12404 EXPECT_TRUE(response->was_fetched_via_proxy); | 12405 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 12405 EXPECT_TRUE( | 12406 EXPECT_TRUE( |
| 12406 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12407 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); |
| 12407 | 12408 |
| 12408 LoadTimingInfo load_timing_info; | 12409 LoadTimingInfo load_timing_info; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12639 // legitimate-but-unacceptable certificate. | 12640 // legitimate-but-unacceptable certificate. |
| 12640 rv = trans->RestartWithCertificate(NULL, NULL, callback.callback()); | 12641 rv = trans->RestartWithCertificate(NULL, NULL, callback.callback()); |
| 12641 ASSERT_EQ(ERR_IO_PENDING, rv); | 12642 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 12642 | 12643 |
| 12643 // Ensure the certificate was added to the client auth cache before | 12644 // Ensure the certificate was added to the client auth cache before |
| 12644 // allowing the connection to continue restarting. | 12645 // allowing the connection to continue restarting. |
| 12645 scoped_refptr<X509Certificate> client_cert; | 12646 scoped_refptr<X509Certificate> client_cert; |
| 12646 scoped_refptr<SSLPrivateKey> client_private_key; | 12647 scoped_refptr<SSLPrivateKey> client_private_key; |
| 12647 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( | 12648 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( |
| 12648 HostPortPair("www.example.com", 443), &client_cert, &client_private_key)); | 12649 HostPortPair("www.example.com", 443), &client_cert, &client_private_key)); |
| 12649 ASSERT_EQ(NULL, client_cert.get()); | 12650 ASSERT_FALSE(client_cert); |
| 12650 | 12651 |
| 12651 // Restart the handshake. This will consume ssl_data2, which fails, and | 12652 // Restart the handshake. This will consume ssl_data2, which fails, and |
| 12652 // then consume ssl_data3 and ssl_data4, both of which should also fail. | 12653 // then consume ssl_data3 and ssl_data4, both of which should also fail. |
| 12653 // The result code is checked against what ssl_data4 should return. | 12654 // The result code is checked against what ssl_data4 should return. |
| 12654 rv = callback.WaitForResult(); | 12655 rv = callback.WaitForResult(); |
| 12655 ASSERT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); | 12656 ASSERT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); |
| 12656 | 12657 |
| 12657 // Ensure that the client certificate is removed from the cache on a | 12658 // Ensure that the client certificate is removed from the cache on a |
| 12658 // handshake failure. | 12659 // handshake failure. |
| 12659 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( | 12660 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12757 // legitimate-but-unacceptable certificate. | 12758 // legitimate-but-unacceptable certificate. |
| 12758 rv = trans->RestartWithCertificate(NULL, NULL, callback.callback()); | 12759 rv = trans->RestartWithCertificate(NULL, NULL, callback.callback()); |
| 12759 ASSERT_EQ(ERR_IO_PENDING, rv); | 12760 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 12760 | 12761 |
| 12761 // Ensure the certificate was added to the client auth cache before | 12762 // Ensure the certificate was added to the client auth cache before |
| 12762 // allowing the connection to continue restarting. | 12763 // allowing the connection to continue restarting. |
| 12763 scoped_refptr<X509Certificate> client_cert; | 12764 scoped_refptr<X509Certificate> client_cert; |
| 12764 scoped_refptr<SSLPrivateKey> client_private_key; | 12765 scoped_refptr<SSLPrivateKey> client_private_key; |
| 12765 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( | 12766 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( |
| 12766 HostPortPair("www.example.com", 443), &client_cert, &client_private_key)); | 12767 HostPortPair("www.example.com", 443), &client_cert, &client_private_key)); |
| 12767 ASSERT_EQ(NULL, client_cert.get()); | 12768 ASSERT_FALSE(client_cert); |
| 12768 | 12769 |
| 12769 // Restart the handshake. This will consume ssl_data2, which fails, and | 12770 // Restart the handshake. This will consume ssl_data2, which fails, and |
| 12770 // then consume ssl_data3 and ssl_data4, both of which should also fail. | 12771 // then consume ssl_data3 and ssl_data4, both of which should also fail. |
| 12771 // The result code is checked against what ssl_data4 should return. | 12772 // The result code is checked against what ssl_data4 should return. |
| 12772 rv = callback.WaitForResult(); | 12773 rv = callback.WaitForResult(); |
| 12773 ASSERT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); | 12774 ASSERT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); |
| 12774 | 12775 |
| 12775 // Ensure that the client certificate is removed from the cache on a | 12776 // Ensure that the client certificate is removed from the cache on a |
| 12776 // handshake failure. | 12777 // handshake failure. |
| 12777 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( | 12778 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12850 // legitimate-but-unacceptable certificate. | 12851 // legitimate-but-unacceptable certificate. |
| 12851 rv = trans->RestartWithCertificate(NULL, NULL, callback.callback()); | 12852 rv = trans->RestartWithCertificate(NULL, NULL, callback.callback()); |
| 12852 ASSERT_EQ(ERR_IO_PENDING, rv); | 12853 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 12853 | 12854 |
| 12854 // Ensure the certificate was added to the client auth cache before | 12855 // Ensure the certificate was added to the client auth cache before |
| 12855 // allowing the connection to continue restarting. | 12856 // allowing the connection to continue restarting. |
| 12856 scoped_refptr<X509Certificate> client_cert; | 12857 scoped_refptr<X509Certificate> client_cert; |
| 12857 scoped_refptr<SSLPrivateKey> client_private_key; | 12858 scoped_refptr<SSLPrivateKey> client_private_key; |
| 12858 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( | 12859 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( |
| 12859 HostPortPair("proxy", 70), &client_cert, &client_private_key)); | 12860 HostPortPair("proxy", 70), &client_cert, &client_private_key)); |
| 12860 ASSERT_EQ(NULL, client_cert.get()); | 12861 ASSERT_FALSE(client_cert); |
| 12861 // Ensure the certificate was NOT cached for the endpoint. This only | 12862 // Ensure the certificate was NOT cached for the endpoint. This only |
| 12862 // applies to HTTPS requests, but is fine to check for HTTP requests. | 12863 // applies to HTTPS requests, but is fine to check for HTTP requests. |
| 12863 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( | 12864 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( |
| 12864 HostPortPair("www.example.com", 443), &client_cert, | 12865 HostPortPair("www.example.com", 443), &client_cert, |
| 12865 &client_private_key)); | 12866 &client_private_key)); |
| 12866 | 12867 |
| 12867 // Restart the handshake. This will consume ssl_data2, which fails, and | 12868 // Restart the handshake. This will consume ssl_data2, which fails, and |
| 12868 // then consume ssl_data3, which should also fail. The result code is | 12869 // then consume ssl_data3, which should also fail. The result code is |
| 12869 // checked against what ssl_data3 should return. | 12870 // checked against what ssl_data3 should return. |
| 12870 rv = callback.WaitForResult(); | 12871 rv = callback.WaitForResult(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12929 request1.method = "GET"; | 12930 request1.method = "GET"; |
| 12930 request1.url = GURL("https://www.example.org/"); | 12931 request1.url = GURL("https://www.example.org/"); |
| 12931 request1.load_flags = 0; | 12932 request1.load_flags = 0; |
| 12932 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 12933 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 12933 | 12934 |
| 12934 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 12935 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 12935 EXPECT_EQ(ERR_IO_PENDING, rv); | 12936 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 12936 EXPECT_EQ(OK, callback.WaitForResult()); | 12937 EXPECT_EQ(OK, callback.WaitForResult()); |
| 12937 | 12938 |
| 12938 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 12939 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 12939 ASSERT_TRUE(response != NULL); | 12940 ASSERT_TRUE(response); |
| 12940 ASSERT_TRUE(response->headers.get() != NULL); | 12941 ASSERT_TRUE(response->headers); |
| 12941 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 12942 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 12942 | 12943 |
| 12943 std::string response_data; | 12944 std::string response_data; |
| 12944 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 12945 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 12945 EXPECT_EQ("hello!", response_data); | 12946 EXPECT_EQ("hello!", response_data); |
| 12946 | 12947 |
| 12947 // Preload www.gmail.com into HostCache. | 12948 // Preload www.gmail.com into HostCache. |
| 12948 HostPortPair host_port("www.gmail.com", 443); | 12949 HostPortPair host_port("www.gmail.com", 443); |
| 12949 HostResolver::RequestInfo resolve_info(host_port); | 12950 HostResolver::RequestInfo resolve_info(host_port); |
| 12950 AddressList ignored; | 12951 AddressList ignored; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 12962 request2.method = "GET"; | 12963 request2.method = "GET"; |
| 12963 request2.url = GURL("https://www.gmail.com/"); | 12964 request2.url = GURL("https://www.gmail.com/"); |
| 12964 request2.load_flags = 0; | 12965 request2.load_flags = 0; |
| 12965 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); | 12966 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
| 12966 | 12967 |
| 12967 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 12968 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 12968 EXPECT_EQ(ERR_IO_PENDING, rv); | 12969 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 12969 EXPECT_EQ(OK, callback.WaitForResult()); | 12970 EXPECT_EQ(OK, callback.WaitForResult()); |
| 12970 | 12971 |
| 12971 response = trans2.GetResponseInfo(); | 12972 response = trans2.GetResponseInfo(); |
| 12972 ASSERT_TRUE(response != NULL); | 12973 ASSERT_TRUE(response); |
| 12973 ASSERT_TRUE(response->headers.get() != NULL); | 12974 ASSERT_TRUE(response->headers); |
| 12974 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 12975 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 12975 EXPECT_TRUE(response->was_fetched_via_spdy); | 12976 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 12976 EXPECT_TRUE(response->was_npn_negotiated); | 12977 EXPECT_TRUE(response->was_npn_negotiated); |
| 12977 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 12978 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 12978 EXPECT_EQ("hello!", response_data); | 12979 EXPECT_EQ("hello!", response_data); |
| 12979 } | 12980 } |
| 12980 | 12981 |
| 12981 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { | 12982 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { |
| 12982 session_deps_.parse_alternative_services = true; | 12983 session_deps_.parse_alternative_services = true; |
| 12983 session_deps_.enable_alternative_service_with_different_host = false; | 12984 session_deps_.enable_alternative_service_with_different_host = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13027 request1.method = "GET"; | 13028 request1.method = "GET"; |
| 13028 request1.url = GURL("https://www.example.org/"); | 13029 request1.url = GURL("https://www.example.org/"); |
| 13029 request1.load_flags = 0; | 13030 request1.load_flags = 0; |
| 13030 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 13031 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 13031 | 13032 |
| 13032 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 13033 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 13033 EXPECT_EQ(ERR_IO_PENDING, rv); | 13034 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 13034 EXPECT_EQ(OK, callback.WaitForResult()); | 13035 EXPECT_EQ(OK, callback.WaitForResult()); |
| 13035 | 13036 |
| 13036 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 13037 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 13037 ASSERT_TRUE(response != NULL); | 13038 ASSERT_TRUE(response); |
| 13038 ASSERT_TRUE(response->headers.get() != NULL); | 13039 ASSERT_TRUE(response->headers); |
| 13039 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 13040 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 13040 | 13041 |
| 13041 std::string response_data; | 13042 std::string response_data; |
| 13042 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 13043 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 13043 EXPECT_EQ("hello!", response_data); | 13044 EXPECT_EQ("hello!", response_data); |
| 13044 | 13045 |
| 13045 HttpRequestInfo request2; | 13046 HttpRequestInfo request2; |
| 13046 request2.method = "GET"; | 13047 request2.method = "GET"; |
| 13047 request2.url = GURL("https://www.gmail.com/"); | 13048 request2.url = GURL("https://www.gmail.com/"); |
| 13048 request2.load_flags = 0; | 13049 request2.load_flags = 0; |
| 13049 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); | 13050 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
| 13050 | 13051 |
| 13051 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 13052 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 13052 EXPECT_EQ(ERR_IO_PENDING, rv); | 13053 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 13053 EXPECT_EQ(OK, callback.WaitForResult()); | 13054 EXPECT_EQ(OK, callback.WaitForResult()); |
| 13054 | 13055 |
| 13055 response = trans2.GetResponseInfo(); | 13056 response = trans2.GetResponseInfo(); |
| 13056 ASSERT_TRUE(response != NULL); | 13057 ASSERT_TRUE(response); |
| 13057 ASSERT_TRUE(response->headers.get() != NULL); | 13058 ASSERT_TRUE(response->headers); |
| 13058 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 13059 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 13059 EXPECT_TRUE(response->was_fetched_via_spdy); | 13060 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 13060 EXPECT_TRUE(response->was_npn_negotiated); | 13061 EXPECT_TRUE(response->was_npn_negotiated); |
| 13061 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 13062 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 13062 EXPECT_EQ("hello!", response_data); | 13063 EXPECT_EQ("hello!", response_data); |
| 13063 } | 13064 } |
| 13064 | 13065 |
| 13065 class OneTimeCachingHostResolver : public HostResolver { | 13066 class OneTimeCachingHostResolver : public HostResolver { |
| 13066 public: | 13067 public: |
| 13067 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) | 13068 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13156 request1.method = "GET"; | 13157 request1.method = "GET"; |
| 13157 request1.url = GURL("https://www.example.org/"); | 13158 request1.url = GURL("https://www.example.org/"); |
| 13158 request1.load_flags = 0; | 13159 request1.load_flags = 0; |
| 13159 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 13160 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 13160 | 13161 |
| 13161 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 13162 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 13162 EXPECT_EQ(ERR_IO_PENDING, rv); | 13163 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 13163 EXPECT_EQ(OK, callback.WaitForResult()); | 13164 EXPECT_EQ(OK, callback.WaitForResult()); |
| 13164 | 13165 |
| 13165 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 13166 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 13166 ASSERT_TRUE(response != NULL); | 13167 ASSERT_TRUE(response); |
| 13167 ASSERT_TRUE(response->headers.get() != NULL); | 13168 ASSERT_TRUE(response->headers); |
| 13168 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 13169 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 13169 | 13170 |
| 13170 std::string response_data; | 13171 std::string response_data; |
| 13171 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 13172 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 13172 EXPECT_EQ("hello!", response_data); | 13173 EXPECT_EQ("hello!", response_data); |
| 13173 | 13174 |
| 13174 // Preload cache entries into HostCache. | 13175 // Preload cache entries into HostCache. |
| 13175 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); | 13176 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); |
| 13176 AddressList ignored; | 13177 AddressList ignored; |
| 13177 rv = host_resolver.Resolve(resolve_info, | 13178 rv = host_resolver.Resolve(resolve_info, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 13188 request2.method = "GET"; | 13189 request2.method = "GET"; |
| 13189 request2.url = GURL("https://www.gmail.com/"); | 13190 request2.url = GURL("https://www.gmail.com/"); |
| 13190 request2.load_flags = 0; | 13191 request2.load_flags = 0; |
| 13191 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); | 13192 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
| 13192 | 13193 |
| 13193 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 13194 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 13194 EXPECT_EQ(ERR_IO_PENDING, rv); | 13195 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 13195 EXPECT_EQ(OK, callback.WaitForResult()); | 13196 EXPECT_EQ(OK, callback.WaitForResult()); |
| 13196 | 13197 |
| 13197 response = trans2.GetResponseInfo(); | 13198 response = trans2.GetResponseInfo(); |
| 13198 ASSERT_TRUE(response != NULL); | 13199 ASSERT_TRUE(response); |
| 13199 ASSERT_TRUE(response->headers.get() != NULL); | 13200 ASSERT_TRUE(response->headers); |
| 13200 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 13201 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 13201 EXPECT_TRUE(response->was_fetched_via_spdy); | 13202 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 13202 EXPECT_TRUE(response->was_npn_negotiated); | 13203 EXPECT_TRUE(response->was_npn_negotiated); |
| 13203 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 13204 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 13204 EXPECT_EQ("hello!", response_data); | 13205 EXPECT_EQ("hello!", response_data); |
| 13205 } | 13206 } |
| 13206 | 13207 |
| 13207 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) { | 13208 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) { |
| 13208 const std::string https_url = "https://www.example.org:8080/"; | 13209 const std::string https_url = "https://www.example.org:8080/"; |
| 13209 const std::string http_url = "http://www.example.org:8080/"; | 13210 const std::string http_url = "http://www.example.org:8080/"; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13285 class AltSvcCertificateVerificationTest : public HttpNetworkTransactionTest { | 13286 class AltSvcCertificateVerificationTest : public HttpNetworkTransactionTest { |
| 13286 public: | 13287 public: |
| 13287 void Run(bool pooling, bool valid) { | 13288 void Run(bool pooling, bool valid) { |
| 13288 url::SchemeHostPort server(GURL(valid ? "https://mail.example.org:443" | 13289 url::SchemeHostPort server(GURL(valid ? "https://mail.example.org:443" |
| 13289 : "https://invalid.example.org:443")); | 13290 : "https://invalid.example.org:443")); |
| 13290 HostPortPair alternative("www.example.org", 443); | 13291 HostPortPair alternative("www.example.org", 443); |
| 13291 | 13292 |
| 13292 base::FilePath certs_dir = GetTestCertsDirectory(); | 13293 base::FilePath certs_dir = GetTestCertsDirectory(); |
| 13293 scoped_refptr<X509Certificate> cert( | 13294 scoped_refptr<X509Certificate> cert( |
| 13294 ImportCertFromFile(certs_dir, "spdy_pooling.pem")); | 13295 ImportCertFromFile(certs_dir, "spdy_pooling.pem")); |
| 13295 ASSERT_TRUE(cert.get()); | 13296 ASSERT_TRUE(cert); |
| 13296 bool common_name_fallback_used; | 13297 bool common_name_fallback_used; |
| 13297 EXPECT_EQ(valid, | 13298 EXPECT_EQ(valid, |
| 13298 cert->VerifyNameMatch(server.host(), &common_name_fallback_used)); | 13299 cert->VerifyNameMatch(server.host(), &common_name_fallback_used)); |
| 13299 EXPECT_TRUE( | 13300 EXPECT_TRUE( |
| 13300 cert->VerifyNameMatch(alternative.host(), &common_name_fallback_used)); | 13301 cert->VerifyNameMatch(alternative.host(), &common_name_fallback_used)); |
| 13301 SSLSocketDataProvider ssl(ASYNC, OK); | 13302 SSLSocketDataProvider ssl(ASYNC, OK); |
| 13302 ssl.SetNextProto(GetProtocol()); | 13303 ssl.SetNextProto(GetProtocol()); |
| 13303 ssl.cert = cert; | 13304 ssl.cert = cert; |
| 13304 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 13305 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 13305 | 13306 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13558 request1.method = "GET"; | 13559 request1.method = "GET"; |
| 13559 request1.url = GURL("https://origin.example.org:443"); | 13560 request1.url = GURL("https://origin.example.org:443"); |
| 13560 request1.load_flags = 0; | 13561 request1.load_flags = 0; |
| 13561 TestCompletionCallback callback1; | 13562 TestCompletionCallback callback1; |
| 13562 | 13563 |
| 13563 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); | 13564 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); |
| 13564 rv = callback1.GetResult(rv); | 13565 rv = callback1.GetResult(rv); |
| 13565 EXPECT_EQ(OK, rv); | 13566 EXPECT_EQ(OK, rv); |
| 13566 | 13567 |
| 13567 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); | 13568 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); |
| 13568 ASSERT_TRUE(response1 != nullptr); | 13569 ASSERT_TRUE(response1); |
| 13569 ASSERT_TRUE(response1->headers.get() != nullptr); | 13570 ASSERT_TRUE(response1->headers); |
| 13570 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); | 13571 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); |
| 13571 | 13572 |
| 13572 std::string response_data1; | 13573 std::string response_data1; |
| 13573 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data1)); | 13574 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data1)); |
| 13574 EXPECT_EQ("foobar", response_data1); | 13575 EXPECT_EQ("foobar", response_data1); |
| 13575 | 13576 |
| 13576 // Alternative should be marked as broken, because HTTP/1.1 is not sufficient | 13577 // Alternative should be marked as broken, because HTTP/1.1 is not sufficient |
| 13577 // for alternative service. | 13578 // for alternative service. |
| 13578 EXPECT_TRUE( | 13579 EXPECT_TRUE( |
| 13579 http_server_properties->IsAlternativeServiceBroken(alternative_service)); | 13580 http_server_properties->IsAlternativeServiceBroken(alternative_service)); |
| 13580 | 13581 |
| 13581 // Since |alternative_service| is broken, a second transaction to server | 13582 // Since |alternative_service| is broken, a second transaction to server |
| 13582 // should not start an alternate Job. It should pool to existing connection | 13583 // should not start an alternate Job. It should pool to existing connection |
| 13583 // to server. | 13584 // to server. |
| 13584 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); | 13585 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); |
| 13585 HttpRequestInfo request2; | 13586 HttpRequestInfo request2; |
| 13586 request2.method = "GET"; | 13587 request2.method = "GET"; |
| 13587 request2.url = GURL("https://origin.example.org:443/second"); | 13588 request2.url = GURL("https://origin.example.org:443/second"); |
| 13588 request2.load_flags = 0; | 13589 request2.load_flags = 0; |
| 13589 TestCompletionCallback callback2; | 13590 TestCompletionCallback callback2; |
| 13590 | 13591 |
| 13591 rv = trans2.Start(&request2, callback2.callback(), BoundNetLog()); | 13592 rv = trans2.Start(&request2, callback2.callback(), BoundNetLog()); |
| 13592 rv = callback2.GetResult(rv); | 13593 rv = callback2.GetResult(rv); |
| 13593 EXPECT_EQ(OK, rv); | 13594 EXPECT_EQ(OK, rv); |
| 13594 | 13595 |
| 13595 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); | 13596 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); |
| 13596 ASSERT_TRUE(response2 != nullptr); | 13597 ASSERT_TRUE(response2); |
| 13597 ASSERT_TRUE(response2->headers.get() != nullptr); | 13598 ASSERT_TRUE(response2->headers); |
| 13598 EXPECT_EQ("HTTP/1.1 200 OK", response2->headers->GetStatusLine()); | 13599 EXPECT_EQ("HTTP/1.1 200 OK", response2->headers->GetStatusLine()); |
| 13599 | 13600 |
| 13600 std::string response_data2; | 13601 std::string response_data2; |
| 13601 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data2)); | 13602 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data2)); |
| 13602 EXPECT_EQ("another", response_data2); | 13603 EXPECT_EQ("another", response_data2); |
| 13603 } | 13604 } |
| 13604 | 13605 |
| 13605 // Alternative service requires HTTP/2 (or SPDY), but there is already a | 13606 // Alternative service requires HTTP/2 (or SPDY), but there is already a |
| 13606 // HTTP/1.1 socket open to the alternative server. That socket should not be | 13607 // HTTP/1.1 socket open to the alternative server. That socket should not be |
| 13607 // used. | 13608 // used. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13669 HttpRequestInfo request1; | 13670 HttpRequestInfo request1; |
| 13670 request1.method = "GET"; | 13671 request1.method = "GET"; |
| 13671 request1.url = GURL(alternative_url); | 13672 request1.url = GURL(alternative_url); |
| 13672 request1.load_flags = 0; | 13673 request1.load_flags = 0; |
| 13673 TestCompletionCallback callback1; | 13674 TestCompletionCallback callback1; |
| 13674 | 13675 |
| 13675 int rv = trans1->Start(&request1, callback1.callback(), BoundNetLog()); | 13676 int rv = trans1->Start(&request1, callback1.callback(), BoundNetLog()); |
| 13676 EXPECT_EQ(OK, callback1.GetResult(rv)); | 13677 EXPECT_EQ(OK, callback1.GetResult(rv)); |
| 13677 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 13678 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 13678 ASSERT_TRUE(response1); | 13679 ASSERT_TRUE(response1); |
| 13679 ASSERT_TRUE(response1->headers.get()); | 13680 ASSERT_TRUE(response1->headers); |
| 13680 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); | 13681 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); |
| 13681 EXPECT_TRUE(response1->was_npn_negotiated); | 13682 EXPECT_TRUE(response1->was_npn_negotiated); |
| 13682 EXPECT_FALSE(response1->was_fetched_via_spdy); | 13683 EXPECT_FALSE(response1->was_fetched_via_spdy); |
| 13683 std::string response_data1; | 13684 std::string response_data1; |
| 13684 ASSERT_EQ(OK, ReadTransaction(trans1.get(), &response_data1)); | 13685 ASSERT_EQ(OK, ReadTransaction(trans1.get(), &response_data1)); |
| 13685 EXPECT_EQ("first HTTP/1.1 response from alternative", response_data1); | 13686 EXPECT_EQ("first HTTP/1.1 response from alternative", response_data1); |
| 13686 | 13687 |
| 13687 // Request for origin.example.org, which has an alternative service. This | 13688 // Request for origin.example.org, which has an alternative service. This |
| 13688 // will start two Jobs: the alternative looks for connections to pool to, | 13689 // will start two Jobs: the alternative looks for connections to pool to, |
| 13689 // finds one which is HTTP/1.1, and should ignore it, and should not try to | 13690 // finds one which is HTTP/1.1, and should ignore it, and should not try to |
| (...skipping 17 matching lines...) Expand all Loading... |
| 13707 HttpRequestInfo request3; | 13708 HttpRequestInfo request3; |
| 13708 request3.method = "GET"; | 13709 request3.method = "GET"; |
| 13709 request3.url = GURL(alternative_url); | 13710 request3.url = GURL(alternative_url); |
| 13710 request3.load_flags = 0; | 13711 request3.load_flags = 0; |
| 13711 TestCompletionCallback callback3; | 13712 TestCompletionCallback callback3; |
| 13712 | 13713 |
| 13713 rv = trans3->Start(&request3, callback3.callback(), BoundNetLog()); | 13714 rv = trans3->Start(&request3, callback3.callback(), BoundNetLog()); |
| 13714 EXPECT_EQ(OK, callback3.GetResult(rv)); | 13715 EXPECT_EQ(OK, callback3.GetResult(rv)); |
| 13715 const HttpResponseInfo* response3 = trans3->GetResponseInfo(); | 13716 const HttpResponseInfo* response3 = trans3->GetResponseInfo(); |
| 13716 ASSERT_TRUE(response3); | 13717 ASSERT_TRUE(response3); |
| 13717 ASSERT_TRUE(response3->headers.get()); | 13718 ASSERT_TRUE(response3->headers); |
| 13718 EXPECT_EQ("HTTP/1.1 200 OK", response3->headers->GetStatusLine()); | 13719 EXPECT_EQ("HTTP/1.1 200 OK", response3->headers->GetStatusLine()); |
| 13719 EXPECT_TRUE(response3->was_npn_negotiated); | 13720 EXPECT_TRUE(response3->was_npn_negotiated); |
| 13720 EXPECT_FALSE(response3->was_fetched_via_spdy); | 13721 EXPECT_FALSE(response3->was_fetched_via_spdy); |
| 13721 std::string response_data3; | 13722 std::string response_data3; |
| 13722 ASSERT_EQ(OK, ReadTransaction(trans3.get(), &response_data3)); | 13723 ASSERT_EQ(OK, ReadTransaction(trans3.get(), &response_data3)); |
| 13723 EXPECT_EQ("second HTTP/1.1 response from alternative", response_data3); | 13724 EXPECT_EQ("second HTTP/1.1 response from alternative", response_data3); |
| 13724 } | 13725 } |
| 13725 | 13726 |
| 13726 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttpOverTunnel) { | 13727 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttpOverTunnel) { |
| 13727 const std::string https_url = "https://www.example.org:8080/"; | 13728 const std::string https_url = "https://www.example.org:8080/"; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13912 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), nullptr, | 13913 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), nullptr, |
| 13913 NULL)); | 13914 NULL)); |
| 13914 | 13915 |
| 13915 SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy | 13916 SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy |
| 13916 ssl1.SetNextProto(GetProtocol()); | 13917 ssl1.SetNextProto(GetProtocol()); |
| 13917 // Load a valid cert. Note, that this does not need to | 13918 // Load a valid cert. Note, that this does not need to |
| 13918 // be valid for proxy because the MockSSLClientSocket does | 13919 // be valid for proxy because the MockSSLClientSocket does |
| 13919 // not actually verify it. But SpdySession will use this | 13920 // not actually verify it. But SpdySession will use this |
| 13920 // to see if it is valid for the new origin | 13921 // to see if it is valid for the new origin |
| 13921 ssl1.cert = ImportCertFromFile(GetTestCertsDirectory(), "ok_cert.pem"); | 13922 ssl1.cert = ImportCertFromFile(GetTestCertsDirectory(), "ok_cert.pem"); |
| 13922 ASSERT_TRUE(ssl1.cert.get()); | 13923 ASSERT_TRUE(ssl1.cert); |
| 13923 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1); | 13924 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1); |
| 13924 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 13925 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
| 13925 | 13926 |
| 13926 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server | 13927 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server |
| 13927 ssl2.SetNextProto(GetProtocol()); | 13928 ssl2.SetNextProto(GetProtocol()); |
| 13928 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); | 13929 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); |
| 13929 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 13930 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
| 13930 | 13931 |
| 13931 session_deps_.host_resolver.reset(new MockCachingHostResolver()); | 13932 session_deps_.host_resolver.reset(new MockCachingHostResolver()); |
| 13932 session_deps_.host_resolver->rules()->AddRule("news.example.org", ip_addr); | 13933 session_deps_.host_resolver->rules()->AddRule("news.example.org", ip_addr); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14125 request1.url = GURL("https://www.a.com/"); | 14126 request1.url = GURL("https://www.a.com/"); |
| 14126 request1.load_flags = 0; | 14127 request1.load_flags = 0; |
| 14127 std::unique_ptr<HttpNetworkTransaction> trans( | 14128 std::unique_ptr<HttpNetworkTransaction> trans( |
| 14128 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 14129 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 14129 | 14130 |
| 14130 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 14131 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
| 14131 EXPECT_EQ(ERR_IO_PENDING, rv); | 14132 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 14132 EXPECT_EQ(OK, callback.WaitForResult()); | 14133 EXPECT_EQ(OK, callback.WaitForResult()); |
| 14133 | 14134 |
| 14134 const HttpResponseInfo* response = trans->GetResponseInfo(); | 14135 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 14135 ASSERT_TRUE(response != NULL); | 14136 ASSERT_TRUE(response); |
| 14136 ASSERT_TRUE(response->headers.get() != NULL); | 14137 ASSERT_TRUE(response->headers); |
| 14137 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 14138 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 14138 EXPECT_TRUE(response->was_fetched_via_spdy); | 14139 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 14139 EXPECT_TRUE(response->was_npn_negotiated); | 14140 EXPECT_TRUE(response->was_npn_negotiated); |
| 14140 | 14141 |
| 14141 std::string response_data; | 14142 std::string response_data; |
| 14142 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 14143 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 14143 EXPECT_EQ("hello!", response_data); | 14144 EXPECT_EQ("hello!", response_data); |
| 14144 trans.reset(); | 14145 trans.reset(); |
| 14145 EXPECT_TRUE( | 14146 EXPECT_TRUE( |
| 14146 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); | 14147 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); |
| 14147 | 14148 |
| 14148 HostPortPair host_port_pair_b("www.b.com", 443); | 14149 HostPortPair host_port_pair_b("www.b.com", 443); |
| 14149 SpdySessionKey spdy_session_key_b( | 14150 SpdySessionKey spdy_session_key_b( |
| 14150 host_port_pair_b, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); | 14151 host_port_pair_b, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); |
| 14151 EXPECT_FALSE( | 14152 EXPECT_FALSE( |
| 14152 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); | 14153 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); |
| 14153 HttpRequestInfo request2; | 14154 HttpRequestInfo request2; |
| 14154 request2.method = "GET"; | 14155 request2.method = "GET"; |
| 14155 request2.url = GURL("https://www.b.com/"); | 14156 request2.url = GURL("https://www.b.com/"); |
| 14156 request2.load_flags = 0; | 14157 request2.load_flags = 0; |
| 14157 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 14158 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 14158 | 14159 |
| 14159 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); | 14160 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); |
| 14160 EXPECT_EQ(ERR_IO_PENDING, rv); | 14161 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 14161 EXPECT_EQ(OK, callback.WaitForResult()); | 14162 EXPECT_EQ(OK, callback.WaitForResult()); |
| 14162 | 14163 |
| 14163 response = trans->GetResponseInfo(); | 14164 response = trans->GetResponseInfo(); |
| 14164 ASSERT_TRUE(response != NULL); | 14165 ASSERT_TRUE(response); |
| 14165 ASSERT_TRUE(response->headers.get() != NULL); | 14166 ASSERT_TRUE(response->headers); |
| 14166 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 14167 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 14167 EXPECT_TRUE(response->was_fetched_via_spdy); | 14168 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 14168 EXPECT_TRUE(response->was_npn_negotiated); | 14169 EXPECT_TRUE(response->was_npn_negotiated); |
| 14169 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 14170 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 14170 EXPECT_EQ("hello!", response_data); | 14171 EXPECT_EQ("hello!", response_data); |
| 14171 EXPECT_FALSE( | 14172 EXPECT_FALSE( |
| 14172 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); | 14173 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); |
| 14173 EXPECT_TRUE( | 14174 EXPECT_TRUE( |
| 14174 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); | 14175 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); |
| 14175 | 14176 |
| 14176 HostPortPair host_port_pair_a1("www.a.com", 80); | 14177 HostPortPair host_port_pair_a1("www.a.com", 80); |
| 14177 SpdySessionKey spdy_session_key_a1( | 14178 SpdySessionKey spdy_session_key_a1( |
| 14178 host_port_pair_a1, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); | 14179 host_port_pair_a1, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); |
| 14179 EXPECT_FALSE( | 14180 EXPECT_FALSE( |
| 14180 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a1)); | 14181 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a1)); |
| 14181 HttpRequestInfo request3; | 14182 HttpRequestInfo request3; |
| 14182 request3.method = "GET"; | 14183 request3.method = "GET"; |
| 14183 request3.url = GURL("http://www.a.com/"); | 14184 request3.url = GURL("http://www.a.com/"); |
| 14184 request3.load_flags = 0; | 14185 request3.load_flags = 0; |
| 14185 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 14186 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 14186 | 14187 |
| 14187 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); | 14188 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); |
| 14188 EXPECT_EQ(ERR_IO_PENDING, rv); | 14189 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 14189 EXPECT_EQ(OK, callback.WaitForResult()); | 14190 EXPECT_EQ(OK, callback.WaitForResult()); |
| 14190 | 14191 |
| 14191 response = trans->GetResponseInfo(); | 14192 response = trans->GetResponseInfo(); |
| 14192 ASSERT_TRUE(response != NULL); | 14193 ASSERT_TRUE(response); |
| 14193 ASSERT_TRUE(response->headers.get() != NULL); | 14194 ASSERT_TRUE(response->headers); |
| 14194 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 14195 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 14195 EXPECT_FALSE(response->was_fetched_via_spdy); | 14196 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 14196 EXPECT_FALSE(response->was_npn_negotiated); | 14197 EXPECT_FALSE(response->was_npn_negotiated); |
| 14197 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 14198 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 14198 EXPECT_EQ("hello!", response_data); | 14199 EXPECT_EQ("hello!", response_data); |
| 14199 EXPECT_FALSE( | 14200 EXPECT_FALSE( |
| 14200 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); | 14201 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); |
| 14201 EXPECT_FALSE( | 14202 EXPECT_FALSE( |
| 14202 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); | 14203 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); |
| 14203 } | 14204 } |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14841 // Make sure that HttpNetworkTransaction passes on its priority to its | 14842 // Make sure that HttpNetworkTransaction passes on its priority to its |
| 14842 // stream request on start. | 14843 // stream request on start. |
| 14843 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriorityOnStart) { | 14844 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriorityOnStart) { |
| 14844 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 14845 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 14845 HttpNetworkSessionPeer peer(session.get()); | 14846 HttpNetworkSessionPeer peer(session.get()); |
| 14846 FakeStreamFactory* fake_factory = new FakeStreamFactory(); | 14847 FakeStreamFactory* fake_factory = new FakeStreamFactory(); |
| 14847 peer.SetHttpStreamFactory(std::unique_ptr<HttpStreamFactory>(fake_factory)); | 14848 peer.SetHttpStreamFactory(std::unique_ptr<HttpStreamFactory>(fake_factory)); |
| 14848 | 14849 |
| 14849 HttpNetworkTransaction trans(LOW, session.get()); | 14850 HttpNetworkTransaction trans(LOW, session.get()); |
| 14850 | 14851 |
| 14851 ASSERT_TRUE(fake_factory->last_stream_request() == NULL); | 14852 ASSERT_FALSE(fake_factory->last_stream_request()); |
| 14852 | 14853 |
| 14853 HttpRequestInfo request; | 14854 HttpRequestInfo request; |
| 14854 TestCompletionCallback callback; | 14855 TestCompletionCallback callback; |
| 14855 EXPECT_EQ(ERR_IO_PENDING, | 14856 EXPECT_EQ(ERR_IO_PENDING, |
| 14856 trans.Start(&request, callback.callback(), BoundNetLog())); | 14857 trans.Start(&request, callback.callback(), BoundNetLog())); |
| 14857 | 14858 |
| 14858 base::WeakPtr<FakeStreamRequest> fake_request = | 14859 base::WeakPtr<FakeStreamRequest> fake_request = |
| 14859 fake_factory->last_stream_request(); | 14860 fake_factory->last_stream_request(); |
| 14860 ASSERT_TRUE(fake_request != NULL); | 14861 ASSERT_TRUE(fake_request); |
| 14861 EXPECT_EQ(LOW, fake_request->priority()); | 14862 EXPECT_EQ(LOW, fake_request->priority()); |
| 14862 } | 14863 } |
| 14863 | 14864 |
| 14864 // Make sure that HttpNetworkTransaction passes on its priority | 14865 // Make sure that HttpNetworkTransaction passes on its priority |
| 14865 // updates to its stream request. | 14866 // updates to its stream request. |
| 14866 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriority) { | 14867 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriority) { |
| 14867 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 14868 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 14868 HttpNetworkSessionPeer peer(session.get()); | 14869 HttpNetworkSessionPeer peer(session.get()); |
| 14869 FakeStreamFactory* fake_factory = new FakeStreamFactory(); | 14870 FakeStreamFactory* fake_factory = new FakeStreamFactory(); |
| 14870 peer.SetHttpStreamFactory(std::unique_ptr<HttpStreamFactory>(fake_factory)); | 14871 peer.SetHttpStreamFactory(std::unique_ptr<HttpStreamFactory>(fake_factory)); |
| 14871 | 14872 |
| 14872 HttpNetworkTransaction trans(LOW, session.get()); | 14873 HttpNetworkTransaction trans(LOW, session.get()); |
| 14873 | 14874 |
| 14874 HttpRequestInfo request; | 14875 HttpRequestInfo request; |
| 14875 TestCompletionCallback callback; | 14876 TestCompletionCallback callback; |
| 14876 EXPECT_EQ(ERR_IO_PENDING, | 14877 EXPECT_EQ(ERR_IO_PENDING, |
| 14877 trans.Start(&request, callback.callback(), BoundNetLog())); | 14878 trans.Start(&request, callback.callback(), BoundNetLog())); |
| 14878 | 14879 |
| 14879 base::WeakPtr<FakeStreamRequest> fake_request = | 14880 base::WeakPtr<FakeStreamRequest> fake_request = |
| 14880 fake_factory->last_stream_request(); | 14881 fake_factory->last_stream_request(); |
| 14881 ASSERT_TRUE(fake_request != NULL); | 14882 ASSERT_TRUE(fake_request); |
| 14882 EXPECT_EQ(LOW, fake_request->priority()); | 14883 EXPECT_EQ(LOW, fake_request->priority()); |
| 14883 | 14884 |
| 14884 trans.SetPriority(LOWEST); | 14885 trans.SetPriority(LOWEST); |
| 14885 ASSERT_TRUE(fake_request != NULL); | 14886 ASSERT_TRUE(fake_request); |
| 14886 EXPECT_EQ(LOWEST, fake_request->priority()); | 14887 EXPECT_EQ(LOWEST, fake_request->priority()); |
| 14887 } | 14888 } |
| 14888 | 14889 |
| 14889 // Make sure that HttpNetworkTransaction passes on its priority | 14890 // Make sure that HttpNetworkTransaction passes on its priority |
| 14890 // updates to its stream. | 14891 // updates to its stream. |
| 14891 TEST_P(HttpNetworkTransactionTest, SetStreamPriority) { | 14892 TEST_P(HttpNetworkTransactionTest, SetStreamPriority) { |
| 14892 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 14893 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 14893 HttpNetworkSessionPeer peer(session.get()); | 14894 HttpNetworkSessionPeer peer(session.get()); |
| 14894 FakeStreamFactory* fake_factory = new FakeStreamFactory(); | 14895 FakeStreamFactory* fake_factory = new FakeStreamFactory(); |
| 14895 peer.SetHttpStreamFactory(std::unique_ptr<HttpStreamFactory>(fake_factory)); | 14896 peer.SetHttpStreamFactory(std::unique_ptr<HttpStreamFactory>(fake_factory)); |
| 14896 | 14897 |
| 14897 HttpNetworkTransaction trans(LOW, session.get()); | 14898 HttpNetworkTransaction trans(LOW, session.get()); |
| 14898 | 14899 |
| 14899 HttpRequestInfo request; | 14900 HttpRequestInfo request; |
| 14900 TestCompletionCallback callback; | 14901 TestCompletionCallback callback; |
| 14901 EXPECT_EQ(ERR_IO_PENDING, | 14902 EXPECT_EQ(ERR_IO_PENDING, |
| 14902 trans.Start(&request, callback.callback(), BoundNetLog())); | 14903 trans.Start(&request, callback.callback(), BoundNetLog())); |
| 14903 | 14904 |
| 14904 base::WeakPtr<FakeStreamRequest> fake_request = | 14905 base::WeakPtr<FakeStreamRequest> fake_request = |
| 14905 fake_factory->last_stream_request(); | 14906 fake_factory->last_stream_request(); |
| 14906 ASSERT_TRUE(fake_request != NULL); | 14907 ASSERT_TRUE(fake_request); |
| 14907 base::WeakPtr<FakeStream> fake_stream = fake_request->FinishStreamRequest(); | 14908 base::WeakPtr<FakeStream> fake_stream = fake_request->FinishStreamRequest(); |
| 14908 ASSERT_TRUE(fake_stream != NULL); | 14909 ASSERT_TRUE(fake_stream); |
| 14909 EXPECT_EQ(LOW, fake_stream->priority()); | 14910 EXPECT_EQ(LOW, fake_stream->priority()); |
| 14910 | 14911 |
| 14911 trans.SetPriority(LOWEST); | 14912 trans.SetPriority(LOWEST); |
| 14912 EXPECT_EQ(LOWEST, fake_stream->priority()); | 14913 EXPECT_EQ(LOWEST, fake_stream->priority()); |
| 14913 } | 14914 } |
| 14914 | 14915 |
| 14915 TEST_P(HttpNetworkTransactionTest, CreateWebSocketHandshakeStream) { | 14916 TEST_P(HttpNetworkTransactionTest, CreateWebSocketHandshakeStream) { |
| 14916 // The same logic needs to be tested for both ws: and wss: schemes, but this | 14917 // The same logic needs to be tested for both ws: and wss: schemes, but this |
| 14917 // test is already parameterised on NextProto, so it uses a loop to verify | 14918 // test is already parameterised on NextProto, so it uses a loop to verify |
| 14918 // that the different schemes work. | 14919 // that the different schemes work. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 14933 HttpRequestInfo request; | 14934 HttpRequestInfo request; |
| 14934 TestCompletionCallback callback; | 14935 TestCompletionCallback callback; |
| 14935 request.method = "GET"; | 14936 request.method = "GET"; |
| 14936 request.url = GURL(test_cases[i]); | 14937 request.url = GURL(test_cases[i]); |
| 14937 | 14938 |
| 14938 EXPECT_EQ(ERR_IO_PENDING, | 14939 EXPECT_EQ(ERR_IO_PENDING, |
| 14939 trans.Start(&request, callback.callback(), BoundNetLog())); | 14940 trans.Start(&request, callback.callback(), BoundNetLog())); |
| 14940 | 14941 |
| 14941 base::WeakPtr<FakeStreamRequest> fake_request = | 14942 base::WeakPtr<FakeStreamRequest> fake_request = |
| 14942 fake_factory->last_stream_request(); | 14943 fake_factory->last_stream_request(); |
| 14943 ASSERT_TRUE(fake_request != NULL); | 14944 ASSERT_TRUE(fake_request); |
| 14944 EXPECT_EQ(&websocket_stream_create_helper, | 14945 EXPECT_EQ(&websocket_stream_create_helper, |
| 14945 fake_request->websocket_stream_create_helper()); | 14946 fake_request->websocket_stream_create_helper()); |
| 14946 } | 14947 } |
| 14947 } | 14948 } |
| 14948 | 14949 |
| 14949 // Tests that when a used socket is returned to the SSL socket pool, it's closed | 14950 // Tests that when a used socket is returned to the SSL socket pool, it's closed |
| 14950 // if the transport socket pool is stalled on the global socket limit. | 14951 // if the transport socket pool is stalled on the global socket limit. |
| 14951 TEST_P(HttpNetworkTransactionTest, CloseSSLSocketOnIdleForHttpRequest) { | 14952 TEST_P(HttpNetworkTransactionTest, CloseSSLSocketOnIdleForHttpRequest) { |
| 14952 ClientSocketPoolManager::set_max_sockets_per_group( | 14953 ClientSocketPoolManager::set_max_sockets_per_group( |
| 14953 HttpNetworkSession::NORMAL_SOCKET_POOL, 1); | 14954 HttpNetworkSession::NORMAL_SOCKET_POOL, 1); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15145 | 15146 |
| 15146 TestCompletionCallback callback; | 15147 TestCompletionCallback callback; |
| 15147 | 15148 |
| 15148 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 15149 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 15149 EXPECT_EQ(ERR_IO_PENDING, rv); | 15150 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15150 | 15151 |
| 15151 rv = callback.WaitForResult(); | 15152 rv = callback.WaitForResult(); |
| 15152 EXPECT_EQ(OK, rv); | 15153 EXPECT_EQ(OK, rv); |
| 15153 | 15154 |
| 15154 const HttpResponseInfo* response = trans->GetResponseInfo(); | 15155 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 15155 ASSERT_TRUE(response != NULL); | 15156 ASSERT_TRUE(response); |
| 15156 | 15157 |
| 15157 EXPECT_TRUE(response->headers.get() != NULL); | 15158 EXPECT_TRUE(response->headers); |
| 15158 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); | 15159 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); |
| 15159 | 15160 |
| 15160 std::string response_data; | 15161 std::string response_data; |
| 15161 rv = ReadTransaction(trans.get(), &response_data); | 15162 rv = ReadTransaction(trans.get(), &response_data); |
| 15162 EXPECT_EQ(OK, rv); | 15163 EXPECT_EQ(OK, rv); |
| 15163 EXPECT_EQ("hello world", response_data); | 15164 EXPECT_EQ("hello world", response_data); |
| 15164 } | 15165 } |
| 15165 | 15166 |
| 15166 // This test makes sure the retry logic doesn't trigger when reading an error | 15167 // This test makes sure the retry logic doesn't trigger when reading an error |
| 15167 // response from a server that rejected a POST with a CONNECTION_RESET. | 15168 // response from a server that rejected a POST with a CONNECTION_RESET. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15200 | 15201 |
| 15201 std::unique_ptr<HttpTransaction> trans1( | 15202 std::unique_ptr<HttpTransaction> trans1( |
| 15202 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 15203 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 15203 int rv = trans1->Start(&request1, callback.callback(), BoundNetLog()); | 15204 int rv = trans1->Start(&request1, callback.callback(), BoundNetLog()); |
| 15204 EXPECT_EQ(ERR_IO_PENDING, rv); | 15205 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15205 | 15206 |
| 15206 rv = callback.WaitForResult(); | 15207 rv = callback.WaitForResult(); |
| 15207 EXPECT_EQ(OK, rv); | 15208 EXPECT_EQ(OK, rv); |
| 15208 | 15209 |
| 15209 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 15210 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 15210 ASSERT_TRUE(response1 != NULL); | 15211 ASSERT_TRUE(response1); |
| 15211 | 15212 |
| 15212 EXPECT_TRUE(response1->headers.get() != NULL); | 15213 EXPECT_TRUE(response1->headers); |
| 15213 EXPECT_EQ("HTTP/1.1 200 Peachy", response1->headers->GetStatusLine()); | 15214 EXPECT_EQ("HTTP/1.1 200 Peachy", response1->headers->GetStatusLine()); |
| 15214 | 15215 |
| 15215 std::string response_data1; | 15216 std::string response_data1; |
| 15216 rv = ReadTransaction(trans1.get(), &response_data1); | 15217 rv = ReadTransaction(trans1.get(), &response_data1); |
| 15217 EXPECT_EQ(OK, rv); | 15218 EXPECT_EQ(OK, rv); |
| 15218 EXPECT_EQ("first response", response_data1); | 15219 EXPECT_EQ("first response", response_data1); |
| 15219 // Delete the transaction to release the socket back into the socket pool. | 15220 // Delete the transaction to release the socket back into the socket pool. |
| 15220 trans1.reset(); | 15221 trans1.reset(); |
| 15221 | 15222 |
| 15222 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 15223 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
| 15223 element_readers.push_back( | 15224 element_readers.push_back( |
| 15224 base::WrapUnique(new UploadBytesElementReader("foo", 3))); | 15225 base::WrapUnique(new UploadBytesElementReader("foo", 3))); |
| 15225 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 15226 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
| 15226 | 15227 |
| 15227 HttpRequestInfo request2; | 15228 HttpRequestInfo request2; |
| 15228 request2.method = "POST"; | 15229 request2.method = "POST"; |
| 15229 request2.url = GURL("http://www.foo.com/"); | 15230 request2.url = GURL("http://www.foo.com/"); |
| 15230 request2.upload_data_stream = &upload_data_stream; | 15231 request2.upload_data_stream = &upload_data_stream; |
| 15231 request2.load_flags = 0; | 15232 request2.load_flags = 0; |
| 15232 | 15233 |
| 15233 std::unique_ptr<HttpTransaction> trans2( | 15234 std::unique_ptr<HttpTransaction> trans2( |
| 15234 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 15235 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 15235 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); | 15236 rv = trans2->Start(&request2, callback.callback(), BoundNetLog()); |
| 15236 EXPECT_EQ(ERR_IO_PENDING, rv); | 15237 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15237 | 15238 |
| 15238 rv = callback.WaitForResult(); | 15239 rv = callback.WaitForResult(); |
| 15239 EXPECT_EQ(OK, rv); | 15240 EXPECT_EQ(OK, rv); |
| 15240 | 15241 |
| 15241 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 15242 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 15242 ASSERT_TRUE(response2 != NULL); | 15243 ASSERT_TRUE(response2); |
| 15243 | 15244 |
| 15244 EXPECT_TRUE(response2->headers.get() != NULL); | 15245 EXPECT_TRUE(response2->headers); |
| 15245 EXPECT_EQ("HTTP/1.1 400 Not OK", response2->headers->GetStatusLine()); | 15246 EXPECT_EQ("HTTP/1.1 400 Not OK", response2->headers->GetStatusLine()); |
| 15246 | 15247 |
| 15247 std::string response_data2; | 15248 std::string response_data2; |
| 15248 rv = ReadTransaction(trans2.get(), &response_data2); | 15249 rv = ReadTransaction(trans2.get(), &response_data2); |
| 15249 EXPECT_EQ(OK, rv); | 15250 EXPECT_EQ(OK, rv); |
| 15250 EXPECT_EQ("second response", response_data2); | 15251 EXPECT_EQ("second response", response_data2); |
| 15251 } | 15252 } |
| 15252 | 15253 |
| 15253 TEST_P(HttpNetworkTransactionTest, | 15254 TEST_P(HttpNetworkTransactionTest, |
| 15254 PostReadsErrorResponseAfterResetPartialBodySent) { | 15255 PostReadsErrorResponseAfterResetPartialBodySent) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15287 | 15288 |
| 15288 TestCompletionCallback callback; | 15289 TestCompletionCallback callback; |
| 15289 | 15290 |
| 15290 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 15291 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 15291 EXPECT_EQ(ERR_IO_PENDING, rv); | 15292 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15292 | 15293 |
| 15293 rv = callback.WaitForResult(); | 15294 rv = callback.WaitForResult(); |
| 15294 EXPECT_EQ(OK, rv); | 15295 EXPECT_EQ(OK, rv); |
| 15295 | 15296 |
| 15296 const HttpResponseInfo* response = trans->GetResponseInfo(); | 15297 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 15297 ASSERT_TRUE(response != NULL); | 15298 ASSERT_TRUE(response); |
| 15298 | 15299 |
| 15299 EXPECT_TRUE(response->headers.get() != NULL); | 15300 EXPECT_TRUE(response->headers); |
| 15300 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); | 15301 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); |
| 15301 | 15302 |
| 15302 std::string response_data; | 15303 std::string response_data; |
| 15303 rv = ReadTransaction(trans.get(), &response_data); | 15304 rv = ReadTransaction(trans.get(), &response_data); |
| 15304 EXPECT_EQ(OK, rv); | 15305 EXPECT_EQ(OK, rv); |
| 15305 EXPECT_EQ("hello world", response_data); | 15306 EXPECT_EQ("hello world", response_data); |
| 15306 } | 15307 } |
| 15307 | 15308 |
| 15308 // This tests the more common case than the previous test, where headers and | 15309 // This tests the more common case than the previous test, where headers and |
| 15309 // body are not merged into a single request. | 15310 // body are not merged into a single request. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15346 // necessary since a chunked body is never merged with headers, but this makes | 15347 // necessary since a chunked body is never merged with headers, but this makes |
| 15347 // the test more future proof. | 15348 // the test more future proof. |
| 15348 base::RunLoop().RunUntilIdle(); | 15349 base::RunLoop().RunUntilIdle(); |
| 15349 | 15350 |
| 15350 upload_data_stream.AppendData("last chunk", 10, true); | 15351 upload_data_stream.AppendData("last chunk", 10, true); |
| 15351 | 15352 |
| 15352 rv = callback.WaitForResult(); | 15353 rv = callback.WaitForResult(); |
| 15353 EXPECT_EQ(OK, rv); | 15354 EXPECT_EQ(OK, rv); |
| 15354 | 15355 |
| 15355 const HttpResponseInfo* response = trans->GetResponseInfo(); | 15356 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 15356 ASSERT_TRUE(response != NULL); | 15357 ASSERT_TRUE(response); |
| 15357 | 15358 |
| 15358 EXPECT_TRUE(response->headers.get() != NULL); | 15359 EXPECT_TRUE(response->headers); |
| 15359 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); | 15360 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); |
| 15360 | 15361 |
| 15361 std::string response_data; | 15362 std::string response_data; |
| 15362 rv = ReadTransaction(trans.get(), &response_data); | 15363 rv = ReadTransaction(trans.get(), &response_data); |
| 15363 EXPECT_EQ(OK, rv); | 15364 EXPECT_EQ(OK, rv); |
| 15364 EXPECT_EQ("hello world", response_data); | 15365 EXPECT_EQ("hello world", response_data); |
| 15365 } | 15366 } |
| 15366 | 15367 |
| 15367 TEST_P(HttpNetworkTransactionTest, PostReadsErrorResponseAfterResetAnd100) { | 15368 TEST_P(HttpNetworkTransactionTest, PostReadsErrorResponseAfterResetAnd100) { |
| 15368 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 15369 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15400 | 15401 |
| 15401 TestCompletionCallback callback; | 15402 TestCompletionCallback callback; |
| 15402 | 15403 |
| 15403 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 15404 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 15404 EXPECT_EQ(ERR_IO_PENDING, rv); | 15405 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15405 | 15406 |
| 15406 rv = callback.WaitForResult(); | 15407 rv = callback.WaitForResult(); |
| 15407 EXPECT_EQ(OK, rv); | 15408 EXPECT_EQ(OK, rv); |
| 15408 | 15409 |
| 15409 const HttpResponseInfo* response = trans->GetResponseInfo(); | 15410 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 15410 ASSERT_TRUE(response != NULL); | 15411 ASSERT_TRUE(response); |
| 15411 | 15412 |
| 15412 EXPECT_TRUE(response->headers.get() != NULL); | 15413 EXPECT_TRUE(response->headers); |
| 15413 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); | 15414 EXPECT_EQ("HTTP/1.0 400 Not OK", response->headers->GetStatusLine()); |
| 15414 | 15415 |
| 15415 std::string response_data; | 15416 std::string response_data; |
| 15416 rv = ReadTransaction(trans.get(), &response_data); | 15417 rv = ReadTransaction(trans.get(), &response_data); |
| 15417 EXPECT_EQ(OK, rv); | 15418 EXPECT_EQ(OK, rv); |
| 15418 EXPECT_EQ("hello world", response_data); | 15419 EXPECT_EQ("hello world", response_data); |
| 15419 } | 15420 } |
| 15420 | 15421 |
| 15421 TEST_P(HttpNetworkTransactionTest, PostIgnoresNonErrorResponseAfterReset) { | 15422 TEST_P(HttpNetworkTransactionTest, PostIgnoresNonErrorResponseAfterReset) { |
| 15422 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 15423 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15657 | 15658 |
| 15658 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 15659 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 15659 EXPECT_EQ(ERR_IO_PENDING, rv); | 15660 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15660 | 15661 |
| 15661 rv = callback.WaitForResult(); | 15662 rv = callback.WaitForResult(); |
| 15662 EXPECT_EQ(OK, rv); | 15663 EXPECT_EQ(OK, rv); |
| 15663 } | 15664 } |
| 15664 | 15665 |
| 15665 const HttpResponseInfo* response = trans->GetResponseInfo(); | 15666 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 15666 ASSERT_TRUE(response); | 15667 ASSERT_TRUE(response); |
| 15667 ASSERT_TRUE(response->headers.get()); | 15668 ASSERT_TRUE(response->headers); |
| 15668 EXPECT_EQ(407, response->headers->response_code()); | 15669 EXPECT_EQ(407, response->headers->response_code()); |
| 15669 | 15670 |
| 15670 { | 15671 { |
| 15671 TestCompletionCallback callback; | 15672 TestCompletionCallback callback; |
| 15672 | 15673 |
| 15673 int rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), | 15674 int rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), |
| 15674 callback.callback()); | 15675 callback.callback()); |
| 15675 EXPECT_EQ(ERR_IO_PENDING, rv); | 15676 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15676 | 15677 |
| 15677 rv = callback.WaitForResult(); | 15678 rv = callback.WaitForResult(); |
| 15678 EXPECT_EQ(OK, rv); | 15679 EXPECT_EQ(OK, rv); |
| 15679 } | 15680 } |
| 15680 | 15681 |
| 15681 response = trans->GetResponseInfo(); | 15682 response = trans->GetResponseInfo(); |
| 15682 ASSERT_TRUE(response); | 15683 ASSERT_TRUE(response); |
| 15683 ASSERT_TRUE(response->headers.get()); | 15684 ASSERT_TRUE(response->headers); |
| 15684 | 15685 |
| 15685 EXPECT_EQ(101, response->headers->response_code()); | 15686 EXPECT_EQ(101, response->headers->response_code()); |
| 15686 | 15687 |
| 15687 trans.reset(); | 15688 trans.reset(); |
| 15688 session->CloseAllConnections(); | 15689 session->CloseAllConnections(); |
| 15689 } | 15690 } |
| 15690 | 15691 |
| 15691 // Verify that proxy headers are not sent to the destination server when | 15692 // Verify that proxy headers are not sent to the destination server when |
| 15692 // establishing a tunnel for an insecure WebSocket connection. | 15693 // establishing a tunnel for an insecure WebSocket connection. |
| 15693 // This requires the authentication info to be injected into the auth cache | 15694 // This requires the authentication info to be injected into the auth cache |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15754 TestCompletionCallback callback; | 15755 TestCompletionCallback callback; |
| 15755 | 15756 |
| 15756 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 15757 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 15757 EXPECT_EQ(ERR_IO_PENDING, rv); | 15758 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 15758 | 15759 |
| 15759 rv = callback.WaitForResult(); | 15760 rv = callback.WaitForResult(); |
| 15760 EXPECT_EQ(OK, rv); | 15761 EXPECT_EQ(OK, rv); |
| 15761 | 15762 |
| 15762 const HttpResponseInfo* response = trans->GetResponseInfo(); | 15763 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 15763 ASSERT_TRUE(response); | 15764 ASSERT_TRUE(response); |
| 15764 ASSERT_TRUE(response->headers.get()); | 15765 ASSERT_TRUE(response->headers); |
| 15765 | 15766 |
| 15766 EXPECT_EQ(101, response->headers->response_code()); | 15767 EXPECT_EQ(101, response->headers->response_code()); |
| 15767 | 15768 |
| 15768 trans.reset(); | 15769 trans.reset(); |
| 15769 session->CloseAllConnections(); | 15770 session->CloseAllConnections(); |
| 15770 } | 15771 } |
| 15771 | 15772 |
| 15772 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesPost) { | 15773 TEST_P(HttpNetworkTransactionTest, TotalNetworkBytesPost) { |
| 15773 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 15774 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
| 15774 element_readers.push_back( | 15775 element_readers.push_back( |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15973 base::MessageLoop::current()->RunUntilIdle(); | 15974 base::MessageLoop::current()->RunUntilIdle(); |
| 15974 | 15975 |
| 15975 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15976 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15976 HttpRequestHeaders headers; | 15977 HttpRequestHeaders headers; |
| 15977 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15978 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15978 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15979 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15979 } | 15980 } |
| 15980 #endif // !defined(OS_IOS) | 15981 #endif // !defined(OS_IOS) |
| 15981 | 15982 |
| 15982 } // namespace net | 15983 } // namespace net |
| OLD | NEW |