Chromium Code Reviews| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 | 278 |
| 279 protected: | 279 protected: |
| 280 HttpNetworkTransactionTest() | 280 HttpNetworkTransactionTest() |
| 281 : spdy_util_(GetProtocol(), GetDependenciesFromPriority()), | 281 : spdy_util_(GetProtocol(), GetDependenciesFromPriority()), |
| 282 session_deps_(GetProtocol()), | 282 session_deps_(GetProtocol()), |
| 283 old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group( | 283 old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group( |
| 284 HttpNetworkSession::NORMAL_SOCKET_POOL)), | 284 HttpNetworkSession::NORMAL_SOCKET_POOL)), |
| 285 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool( | 285 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool( |
| 286 HttpNetworkSession::NORMAL_SOCKET_POOL)) { | 286 HttpNetworkSession::NORMAL_SOCKET_POOL)) { |
| 287 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority(); | 287 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority(); |
| 288 session_deps_.enable_http2_alternative_service_with_different_host = true; | |
| 288 } | 289 } |
| 289 | 290 |
| 290 struct SimpleGetHelperResult { | 291 struct SimpleGetHelperResult { |
| 291 int rv; | 292 int rv; |
| 292 std::string status_line; | 293 std::string status_line; |
| 293 std::string response_data; | 294 std::string response_data; |
| 294 int64_t total_received_bytes; | 295 int64_t total_received_bytes; |
| 295 int64_t total_sent_bytes; | 296 int64_t total_sent_bytes; |
| 296 LoadTimingInfo load_timing_info; | 297 LoadTimingInfo load_timing_info; |
| 297 ConnectionAttempts connection_attempts; | 298 ConnectionAttempts connection_attempts; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 321 return GetParam() == kTestCaseHTTP2PriorityDependencies; | 322 return GetParam() == kTestCaseHTTP2PriorityDependencies; |
| 322 } | 323 } |
| 323 | 324 |
| 324 const char* GetAlternateProtocolFromParam() { | 325 const char* GetAlternateProtocolFromParam() { |
| 325 return AlternateProtocolToString( | 326 return AlternateProtocolToString( |
| 326 AlternateProtocolFromNextProto(GetProtocol())); | 327 AlternateProtocolFromNextProto(GetProtocol())); |
| 327 } | 328 } |
| 328 | 329 |
| 329 std::string GetAlternativeServiceHttpHeader() { | 330 std::string GetAlternativeServiceHttpHeader() { |
| 330 return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() + | 331 return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() + |
| 331 "=\"www.example.org:443\"\r\n"; | 332 "=\"mail.example.org:443\"\r\n"; |
| 332 } | 333 } |
| 333 | 334 |
| 334 // Either |write_failure| specifies a write failure or |read_failure| | 335 // Either |write_failure| specifies a write failure or |read_failure| |
| 335 // specifies a read failure when using a reused socket. In either case, the | 336 // specifies a read failure when using a reused socket. In either case, the |
| 336 // failure should cause the network transaction to resend the request, and the | 337 // failure should cause the network transaction to resend the request, and the |
| 337 // other argument should be NULL. | 338 // other argument should be NULL. |
| 338 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure, | 339 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure, |
| 339 const MockRead* read_failure); | 340 const MockRead* read_failure); |
| 340 | 341 |
| 341 // Either |write_failure| specifies a write failure or |read_failure| | 342 // Either |write_failure| specifies a write failure or |read_failure| |
| (...skipping 4162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4504 request.load_flags = 0; | 4505 request.load_flags = 0; |
| 4505 | 4506 |
| 4506 // Configure against https proxy server "proxy:70". | 4507 // Configure against https proxy server "proxy:70". |
| 4507 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70"); | 4508 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70"); |
| 4508 BoundTestNetLog log; | 4509 BoundTestNetLog log; |
| 4509 session_deps_.net_log = log.bound().net_log(); | 4510 session_deps_.net_log = log.bound().net_log(); |
| 4510 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4511 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 4511 | 4512 |
| 4512 // fetch http://www.example.org/ via SPDY | 4513 // fetch http://www.example.org/ via SPDY |
| 4513 std::unique_ptr<SpdySerializedFrame> req( | 4514 std::unique_ptr<SpdySerializedFrame> req( |
| 4514 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, false)); | 4515 spdy_util_.ConstructSpdyGet("http://www.example.org/", 1, LOWEST)); |
| 4515 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; | 4516 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; |
| 4516 | 4517 |
| 4517 std::unique_ptr<SpdySerializedFrame> resp( | 4518 std::unique_ptr<SpdySerializedFrame> resp( |
| 4518 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 4519 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 4519 std::unique_ptr<SpdySerializedFrame> data( | 4520 std::unique_ptr<SpdySerializedFrame> data( |
| 4520 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4521 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 4521 MockRead spdy_reads[] = { | 4522 MockRead spdy_reads[] = { |
| 4522 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), | 4523 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), |
| 4523 }; | 4524 }; |
| 4524 | 4525 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4566 request.load_flags = 0; | 4567 request.load_flags = 0; |
| 4567 | 4568 |
| 4568 // Configure SPDY proxy server "proxy:70". | 4569 // Configure SPDY proxy server "proxy:70". |
| 4569 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70"); | 4570 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70"); |
| 4570 BoundTestNetLog log; | 4571 BoundTestNetLog log; |
| 4571 session_deps_.net_log = log.bound().net_log(); | 4572 session_deps_.net_log = log.bound().net_log(); |
| 4572 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4573 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 4573 | 4574 |
| 4574 // Fetch http://www.example.org/ through the SPDY proxy. | 4575 // Fetch http://www.example.org/ through the SPDY proxy. |
| 4575 std::unique_ptr<SpdySerializedFrame> req( | 4576 std::unique_ptr<SpdySerializedFrame> req( |
| 4576 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, false)); | 4577 spdy_util_.ConstructSpdyGet("http://www.example.org/", 1, LOWEST)); |
| 4577 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; | 4578 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; |
| 4578 | 4579 |
| 4579 std::unique_ptr<SpdySerializedFrame> resp( | 4580 std::unique_ptr<SpdySerializedFrame> resp( |
| 4580 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4581 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 4581 std::unique_ptr<SpdySerializedFrame> data( | 4582 std::unique_ptr<SpdySerializedFrame> data( |
| 4582 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4583 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 4583 MockRead spdy_reads[] = { | 4584 MockRead spdy_reads[] = { |
| 4584 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), | 4585 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), |
| 4585 }; | 4586 }; |
| 4586 | 4587 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4637 request.load_flags = 0; | 4638 request.load_flags = 0; |
| 4638 | 4639 |
| 4639 // Configure against https proxy server "myproxy:70". | 4640 // Configure against https proxy server "myproxy:70". |
| 4640 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); | 4641 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); |
| 4641 BoundTestNetLog log; | 4642 BoundTestNetLog log; |
| 4642 session_deps_.net_log = log.bound().net_log(); | 4643 session_deps_.net_log = log.bound().net_log(); |
| 4643 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 4644 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 4644 | 4645 |
| 4645 // The first request will be a bare GET, the second request will be a | 4646 // The first request will be a bare GET, the second request will be a |
| 4646 // GET with a Proxy-Authorization header. | 4647 // GET with a Proxy-Authorization header. |
| 4648 spdy_util_.set_default_url(request.url); | |
| 4647 std::unique_ptr<SpdySerializedFrame> req_get( | 4649 std::unique_ptr<SpdySerializedFrame> req_get( |
| 4648 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, false)); | 4650 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, false)); |
| 4649 spdy_util_.UpdateWithStreamDestruction(1); | 4651 spdy_util_.UpdateWithStreamDestruction(1); |
| 4650 const char* const kExtraAuthorizationHeaders[] = { | 4652 const char* const kExtraAuthorizationHeaders[] = { |
| 4651 "proxy-authorization", "Basic Zm9vOmJhcg==" | 4653 "proxy-authorization", "Basic Zm9vOmJhcg==" |
| 4652 }; | 4654 }; |
| 4653 std::unique_ptr<SpdySerializedFrame> req_get_authorization( | 4655 std::unique_ptr<SpdySerializedFrame> req_get_authorization( |
| 4654 spdy_util_.ConstructSpdyGet(kExtraAuthorizationHeaders, | 4656 spdy_util_.ConstructSpdyGet(kExtraAuthorizationHeaders, |
| 4655 arraysize(kExtraAuthorizationHeaders) / 2, 3, | 4657 arraysize(kExtraAuthorizationHeaders) / 2, 3, |
| 4656 LOWEST, false)); | 4658 LOWEST, false)); |
| (...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8006 session_deps_.proxy_service = | 8008 session_deps_.proxy_service = |
| 8007 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:443"); | 8009 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:443"); |
| 8008 BoundTestNetLog log; | 8010 BoundTestNetLog log; |
| 8009 session_deps_.net_log = log.bound().net_log(); | 8011 session_deps_.net_log = log.bound().net_log(); |
| 8010 | 8012 |
| 8011 session_deps_.proxy_delegate.reset(proxy_delegate.release()); | 8013 session_deps_.proxy_delegate.reset(proxy_delegate.release()); |
| 8012 | 8014 |
| 8013 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8015 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 8014 | 8016 |
| 8015 std::unique_ptr<SpdySerializedFrame> stream1_syn( | 8017 std::unique_ptr<SpdySerializedFrame> stream1_syn( |
| 8016 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, false)); | 8018 spdy_util_.ConstructSpdyGet("http://www.example.org/", 1, LOWEST)); |
| 8017 | 8019 |
| 8018 MockWrite spdy_writes[] = { | 8020 MockWrite spdy_writes[] = { |
| 8019 CreateMockWrite(*stream1_syn, 0, ASYNC), | 8021 CreateMockWrite(*stream1_syn, 0, ASYNC), |
| 8020 }; | 8022 }; |
| 8021 | 8023 |
| 8022 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 8024 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 8023 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 8025 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 8024 | 8026 |
| 8025 std::unique_ptr<SpdySerializedFrame> stream1_body( | 8027 std::unique_ptr<SpdySerializedFrame> stream1_body( |
| 8026 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 8028 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8119 ProxyService::CreateFixed("https://myproxy:443"); | 8121 ProxyService::CreateFixed("https://myproxy:443"); |
| 8120 BoundTestNetLog log; | 8122 BoundTestNetLog log; |
| 8121 session_deps_.net_log = log.bound().net_log(); | 8123 session_deps_.net_log = log.bound().net_log(); |
| 8122 | 8124 |
| 8123 // Enable cross-origin push. | 8125 // Enable cross-origin push. |
| 8124 session_deps_.proxy_delegate.reset(proxy_delegate.release()); | 8126 session_deps_.proxy_delegate.reset(proxy_delegate.release()); |
| 8125 | 8127 |
| 8126 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8128 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 8127 | 8129 |
| 8128 std::unique_ptr<SpdySerializedFrame> stream1_syn( | 8130 std::unique_ptr<SpdySerializedFrame> stream1_syn( |
| 8129 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, false)); | 8131 spdy_util_.ConstructSpdyGet("http://www.example.org/", 1, LOWEST)); |
| 8130 | 8132 |
| 8131 std::unique_ptr<SpdySerializedFrame> push_rst( | 8133 std::unique_ptr<SpdySerializedFrame> push_rst( |
| 8132 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 8134 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
| 8133 | 8135 |
| 8134 MockWrite spdy_writes[] = { | 8136 MockWrite spdy_writes[] = { |
| 8135 CreateMockWrite(*stream1_syn, 0, ASYNC), CreateMockWrite(*push_rst, 3), | 8137 CreateMockWrite(*stream1_syn, 0, ASYNC), CreateMockWrite(*push_rst, 3), |
| 8136 }; | 8138 }; |
| 8137 | 8139 |
| 8138 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 8140 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 8139 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 8141 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8201 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); | 8203 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); |
| 8202 BoundTestNetLog log; | 8204 BoundTestNetLog log; |
| 8203 session_deps_.net_log = log.bound().net_log(); | 8205 session_deps_.net_log = log.bound().net_log(); |
| 8204 | 8206 |
| 8205 // Enable cross-origin push. | 8207 // Enable cross-origin push. |
| 8206 session_deps_.proxy_delegate.reset(proxy_delegate.release()); | 8208 session_deps_.proxy_delegate.reset(proxy_delegate.release()); |
| 8207 | 8209 |
| 8208 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 8210 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 8209 | 8211 |
| 8210 std::unique_ptr<SpdySerializedFrame> stream1_syn( | 8212 std::unique_ptr<SpdySerializedFrame> stream1_syn( |
| 8211 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, false)); | 8213 spdy_util_.ConstructSpdyGet("http://www.example.org/", 1, LOWEST)); |
| 8212 | 8214 |
| 8213 MockWrite spdy_writes[] = { | 8215 MockWrite spdy_writes[] = { |
| 8214 CreateMockWrite(*stream1_syn, 0, ASYNC), | 8216 CreateMockWrite(*stream1_syn, 0, ASYNC), |
| 8215 }; | 8217 }; |
| 8216 | 8218 |
| 8217 std::unique_ptr<SpdySerializedFrame> stream1_reply( | 8219 std::unique_ptr<SpdySerializedFrame> stream1_reply( |
| 8218 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 8220 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 8219 | 8221 |
| 8220 std::unique_ptr<SpdySerializedFrame> stream2_syn(spdy_util_.ConstructSpdyPush( | 8222 std::unique_ptr<SpdySerializedFrame> stream2_syn(spdy_util_.ConstructSpdyPush( |
| 8221 nullptr, 0, 2, 1, "https://myproxy:70/foo.dat")); | 8223 nullptr, 0, 2, 1, "https://myproxy:70/foo.dat")); |
| (...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9946 MockRead data_reads[] = { | 9948 MockRead data_reads[] = { |
| 9947 MockRead("HTTP/1.1 200 OK\r\n"), | 9949 MockRead("HTTP/1.1 200 OK\r\n"), |
| 9948 MockRead(alternative_service_http_header.c_str()), | 9950 MockRead(alternative_service_http_header.c_str()), |
| 9949 MockRead("\r\n"), | 9951 MockRead("\r\n"), |
| 9950 MockRead("hello world"), | 9952 MockRead("hello world"), |
| 9951 MockRead(SYNCHRONOUS, OK), | 9953 MockRead(SYNCHRONOUS, OK), |
| 9952 }; | 9954 }; |
| 9953 | 9955 |
| 9954 HttpRequestInfo request; | 9956 HttpRequestInfo request; |
| 9955 request.method = "GET"; | 9957 request.method = "GET"; |
| 9956 request.url = GURL("http://www.example.org/"); | 9958 request.url = GURL("https://www.example.org/"); |
| 9957 request.load_flags = 0; | 9959 request.load_flags = 0; |
| 9958 | 9960 |
| 9959 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 9961 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 9962 session_deps_.socket_factory->AddSocketDataProvider(&data); | |
| 9960 | 9963 |
| 9961 session_deps_.socket_factory->AddSocketDataProvider(&data); | 9964 SSLSocketDataProvider ssl(ASYNC, OK); |
| 9965 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 9962 | 9966 |
| 9963 TestCompletionCallback callback; | 9967 TestCompletionCallback callback; |
| 9964 | 9968 |
| 9965 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9969 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 9966 std::unique_ptr<HttpTransaction> trans( | 9970 std::unique_ptr<HttpTransaction> trans( |
| 9967 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9971 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9968 | 9972 |
| 9969 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9973 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9970 EXPECT_EQ(ERR_IO_PENDING, rv); | 9974 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9971 | 9975 |
| 9972 url::SchemeHostPort test_server("http", "www.example.org", 80); | 9976 url::SchemeHostPort test_server(request.url); |
| 9973 HttpServerProperties* http_server_properties = | 9977 HttpServerProperties* http_server_properties = |
| 9974 session->http_server_properties(); | 9978 session->http_server_properties(); |
| 9975 AlternativeServiceVector alternative_service_vector = | 9979 AlternativeServiceVector alternative_service_vector = |
| 9976 http_server_properties->GetAlternativeServices(test_server); | 9980 http_server_properties->GetAlternativeServices(test_server); |
| 9977 EXPECT_TRUE(alternative_service_vector.empty()); | 9981 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9978 | 9982 |
| 9979 EXPECT_EQ(OK, callback.WaitForResult()); | 9983 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9980 | 9984 |
| 9981 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9985 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9982 ASSERT_TRUE(response); | 9986 ASSERT_TRUE(response); |
| 9983 ASSERT_TRUE(response->headers); | 9987 ASSERT_TRUE(response->headers); |
| 9984 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9988 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9985 EXPECT_FALSE(response->was_fetched_via_spdy); | 9989 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9986 EXPECT_FALSE(response->was_npn_negotiated); | 9990 EXPECT_FALSE(response->was_npn_negotiated); |
| 9987 | 9991 |
| 9988 std::string response_data; | 9992 std::string response_data; |
| 9989 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9993 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9990 EXPECT_EQ("hello world", response_data); | 9994 EXPECT_EQ("hello world", response_data); |
| 9991 | 9995 |
| 9992 alternative_service_vector = | 9996 alternative_service_vector = |
| 9993 http_server_properties->GetAlternativeServices(test_server); | 9997 http_server_properties->GetAlternativeServices(test_server); |
| 9994 ASSERT_EQ(1u, alternative_service_vector.size()); | 9998 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 9995 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9999 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9996 alternative_service_vector[0].protocol); | 10000 alternative_service_vector[0].protocol); |
| 9997 EXPECT_EQ("www.example.org", alternative_service_vector[0].host); | 10001 EXPECT_EQ("mail.example.org", alternative_service_vector[0].host); |
| 9998 EXPECT_EQ(443, alternative_service_vector[0].port); | 10002 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 9999 } | 10003 } |
| 10000 | 10004 |
| 10001 // Regression test for https://crbug.com/615497. | 10005 // Regression test for https://crbug.com/615497. |
| 10002 TEST_P(HttpNetworkTransactionTest, | 10006 TEST_P(HttpNetworkTransactionTest, |
| 10003 DoNotParseAlternativeServiceHeaderOnInsecureRequest) { | 10007 DoNotParseAlternativeServiceHeaderOnInsecureRequest) { |
| 10004 session_deps_.enable_alternative_service_for_insecure_origins = false; | |
| 10005 | |
| 10006 std::string alternative_service_http_header = | 10008 std::string alternative_service_http_header = |
| 10007 GetAlternativeServiceHttpHeader(); | 10009 GetAlternativeServiceHttpHeader(); |
| 10008 | 10010 |
| 10009 MockRead data_reads[] = { | 10011 MockRead data_reads[] = { |
| 10010 MockRead("HTTP/1.1 200 OK\r\n"), | 10012 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10011 MockRead(alternative_service_http_header.c_str()), | 10013 MockRead(alternative_service_http_header.c_str()), |
| 10012 MockRead("\r\n"), | 10014 MockRead("\r\n"), |
| 10013 MockRead("hello world"), | 10015 MockRead("hello world"), |
| 10014 MockRead(SYNCHRONOUS, OK), | 10016 MockRead(SYNCHRONOUS, OK), |
| 10015 }; | 10017 }; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10053 alternative_service_vector = | 10055 alternative_service_vector = |
| 10054 http_server_properties->GetAlternativeServices(test_server); | 10056 http_server_properties->GetAlternativeServices(test_server); |
| 10055 EXPECT_TRUE(alternative_service_vector.empty()); | 10057 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10056 } | 10058 } |
| 10057 | 10059 |
| 10058 // HTTP/2 Alternative Services should be disabled if alternative service | 10060 // HTTP/2 Alternative Services should be disabled if alternative service |
| 10059 // hostname is different from that of origin. | 10061 // hostname is different from that of origin. |
| 10060 // TODO(bnc): Remove when https://crbug.com/615413 is fixed. | 10062 // TODO(bnc): Remove when https://crbug.com/615413 is fixed. |
| 10061 TEST_P(HttpNetworkTransactionTest, | 10063 TEST_P(HttpNetworkTransactionTest, |
| 10062 DisableHTTP2AlternativeServicesWithDifferentHost) { | 10064 DisableHTTP2AlternativeServicesWithDifferentHost) { |
| 10065 session_deps_.enable_http2_alternative_service_with_different_host = false; | |
| 10066 | |
| 10063 HttpRequestInfo request; | 10067 HttpRequestInfo request; |
| 10064 request.method = "GET"; | 10068 request.method = "GET"; |
| 10065 request.url = GURL("http://www.example.org/"); | 10069 request.url = GURL("https://www.example.org/"); |
| 10066 request.load_flags = 0; | 10070 request.load_flags = 0; |
| 10067 | 10071 |
| 10068 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10072 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10069 StaticSocketDataProvider first_data; | 10073 StaticSocketDataProvider first_data; |
| 10070 first_data.set_connect_data(mock_connect); | 10074 first_data.set_connect_data(mock_connect); |
| 10071 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10075 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10076 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 10077 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 10078 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 10072 | 10079 |
| 10073 MockRead data_reads[] = { | 10080 MockRead data_reads[] = { |
| 10074 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello world"), | 10081 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello world"), |
| 10075 MockRead(ASYNC, OK), | 10082 MockRead(ASYNC, OK), |
| 10076 }; | 10083 }; |
| 10077 StaticSocketDataProvider second_data(data_reads, arraysize(data_reads), NULL, | 10084 StaticSocketDataProvider second_data(data_reads, arraysize(data_reads), NULL, |
| 10078 0); | 10085 0); |
| 10079 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10086 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10080 | 10087 |
| 10081 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10088 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 10095 | 10102 |
| 10096 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10103 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10097 // Alternative service is not used, request fails. | 10104 // Alternative service is not used, request fails. |
| 10098 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); | 10105 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); |
| 10099 } | 10106 } |
| 10100 | 10107 |
| 10101 // Regression test for https://crbug.com/615497: | 10108 // Regression test for https://crbug.com/615497: |
| 10102 // Alternative Services should be disabled for http origin. | 10109 // Alternative Services should be disabled for http origin. |
| 10103 TEST_P(HttpNetworkTransactionTest, | 10110 TEST_P(HttpNetworkTransactionTest, |
| 10104 DisableAlternativeServicesForInsecureOrigin) { | 10111 DisableAlternativeServicesForInsecureOrigin) { |
| 10105 session_deps_.enable_alternative_service_for_insecure_origins = false; | |
| 10106 | |
| 10107 HttpRequestInfo request; | 10112 HttpRequestInfo request; |
| 10108 request.method = "GET"; | 10113 request.method = "GET"; |
| 10109 request.url = GURL("http://www.example.org/"); | 10114 request.url = GURL("http://www.example.org/"); |
| 10110 request.load_flags = 0; | 10115 request.load_flags = 0; |
| 10111 | 10116 |
| 10112 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10117 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10113 StaticSocketDataProvider first_data; | 10118 StaticSocketDataProvider first_data; |
| 10114 first_data.set_connect_data(mock_connect); | 10119 first_data.set_connect_data(mock_connect); |
| 10115 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10120 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10116 | 10121 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 10139 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10144 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10140 // Alternative service is not used, request fails. | 10145 // Alternative service is not used, request fails. |
| 10141 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); | 10146 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); |
| 10142 } | 10147 } |
| 10143 | 10148 |
| 10144 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { | 10149 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { |
| 10145 // Set an alternative service for origin. | 10150 // Set an alternative service for origin. |
| 10146 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10151 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10147 HttpServerProperties* http_server_properties = | 10152 HttpServerProperties* http_server_properties = |
| 10148 session->http_server_properties(); | 10153 session->http_server_properties(); |
| 10149 url::SchemeHostPort test_server("http", "www.example.org", 80); | 10154 url::SchemeHostPort test_server("https", "www.example.org", 443); |
| 10150 AlternativeService alternative_service(QUIC, "", 80); | 10155 AlternativeService alternative_service(QUIC, "", 80); |
| 10151 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10156 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10152 http_server_properties->SetAlternativeService( | 10157 http_server_properties->SetAlternativeService( |
| 10153 test_server, alternative_service, expiration); | 10158 test_server, alternative_service, expiration); |
| 10154 AlternativeServiceVector alternative_service_vector = | 10159 AlternativeServiceVector alternative_service_vector = |
| 10155 http_server_properties->GetAlternativeServices(test_server); | 10160 http_server_properties->GetAlternativeServices(test_server); |
| 10156 EXPECT_EQ(1u, alternative_service_vector.size()); | 10161 EXPECT_EQ(1u, alternative_service_vector.size()); |
| 10157 | 10162 |
| 10158 // Send a clear header. | 10163 // Send a clear header. |
| 10159 MockRead data_reads[] = { | 10164 MockRead data_reads[] = { |
| 10160 MockRead("HTTP/1.1 200 OK\r\n"), | 10165 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10161 MockRead("Alt-Svc: clear\r\n"), | 10166 MockRead("Alt-Svc: clear\r\n"), |
| 10162 MockRead("\r\n"), | 10167 MockRead("\r\n"), |
| 10163 MockRead("hello world"), | 10168 MockRead("hello world"), |
| 10164 MockRead(SYNCHRONOUS, OK), | 10169 MockRead(SYNCHRONOUS, OK), |
| 10165 }; | 10170 }; |
| 10166 StaticSocketDataProvider data(data_reads, arraysize(data_reads), nullptr, 0); | 10171 StaticSocketDataProvider data(data_reads, arraysize(data_reads), nullptr, 0); |
| 10167 session_deps_.socket_factory->AddSocketDataProvider(&data); | 10172 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 10168 | 10173 |
| 10174 SSLSocketDataProvider ssl(ASYNC, OK); | |
| 10175 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 10176 | |
| 10169 HttpRequestInfo request; | 10177 HttpRequestInfo request; |
| 10170 request.method = "GET"; | 10178 request.method = "GET"; |
| 10171 request.url = GURL("http://www.example.org/"); | 10179 request.url = GURL("https://www.example.org/"); |
| 10172 request.load_flags = 0; | 10180 request.load_flags = 0; |
| 10173 | 10181 |
| 10174 TestCompletionCallback callback; | 10182 TestCompletionCallback callback; |
| 10175 | 10183 |
| 10176 std::unique_ptr<HttpTransaction> trans( | 10184 std::unique_ptr<HttpTransaction> trans( |
| 10177 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10185 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10178 | 10186 |
| 10179 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10187 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10180 EXPECT_EQ(OK, callback.GetResult(rv)); | 10188 EXPECT_EQ(OK, callback.GetResult(rv)); |
| 10181 | 10189 |
| 10182 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10190 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10183 ASSERT_TRUE(response); | 10191 ASSERT_TRUE(response); |
| 10184 ASSERT_TRUE(response->headers); | 10192 ASSERT_TRUE(response->headers); |
| 10185 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10193 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10186 EXPECT_FALSE(response->was_fetched_via_spdy); | 10194 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10187 EXPECT_FALSE(response->was_npn_negotiated); | 10195 EXPECT_FALSE(response->was_npn_negotiated); |
| 10188 | 10196 |
| 10189 std::string response_data; | 10197 std::string response_data; |
| 10190 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10198 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10191 EXPECT_EQ("hello world", response_data); | 10199 EXPECT_EQ("hello world", response_data); |
| 10192 | 10200 |
| 10193 alternative_service_vector = | 10201 alternative_service_vector = |
| 10194 http_server_properties->GetAlternativeServices(test_server); | 10202 http_server_properties->GetAlternativeServices(test_server); |
| 10195 EXPECT_TRUE(alternative_service_vector.empty()); | 10203 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10196 } | 10204 } |
| 10197 | 10205 |
| 10198 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { | 10206 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeaders) { |
| 10199 MockRead data_reads[] = { | 10207 MockRead data_reads[] = { |
| 10200 MockRead("HTTP/1.1 200 OK\r\n"), | 10208 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10201 MockRead("Alt-Svc: "), | 10209 MockRead("Alt-Svc: "), |
| 10202 MockRead(GetAlternateProtocolFromParam()), | 10210 MockRead(GetAlternateProtocolFromParam()), |
| 10203 MockRead("=\"www.example.com:443\";p=\"1.0\","), | 10211 MockRead("=\"www.example.com:443\","), |
| 10204 MockRead(GetAlternateProtocolFromParam()), | 10212 MockRead(GetAlternateProtocolFromParam()), |
| 10205 MockRead("=\":1234\"\r\n\r\n"), | 10213 MockRead("=\":1234\"\r\n\r\n"), |
| 10206 MockRead("hello world"), | 10214 MockRead("hello world"), |
| 10207 MockRead(SYNCHRONOUS, OK), | 10215 MockRead(SYNCHRONOUS, OK), |
| 10208 }; | 10216 }; |
| 10209 | 10217 |
| 10210 HttpRequestInfo request; | 10218 HttpRequestInfo request; |
| 10211 request.method = "GET"; | 10219 request.method = "GET"; |
| 10212 request.url = GURL("http://www.example.org/"); | 10220 request.url = GURL("https://www.example.org/"); |
| 10213 request.load_flags = 0; | 10221 request.load_flags = 0; |
| 10214 | 10222 |
| 10215 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 10223 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 10224 session_deps_.socket_factory->AddSocketDataProvider(&data); | |
| 10216 | 10225 |
| 10217 session_deps_.socket_factory->AddSocketDataProvider(&data); | 10226 SSLSocketDataProvider ssl(ASYNC, OK); |
| 10227 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 10218 | 10228 |
| 10219 TestCompletionCallback callback; | 10229 TestCompletionCallback callback; |
| 10220 | 10230 |
| 10221 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10231 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10222 std::unique_ptr<HttpTransaction> trans( | 10232 std::unique_ptr<HttpTransaction> trans( |
| 10223 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10233 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10224 | 10234 |
| 10225 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10235 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10226 EXPECT_EQ(ERR_IO_PENDING, rv); | 10236 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10227 | 10237 |
| 10228 url::SchemeHostPort test_server("http", "www.example.org", 80); | 10238 url::SchemeHostPort test_server("https", "www.example.org", 443); |
| 10229 HttpServerProperties* http_server_properties = | 10239 HttpServerProperties* http_server_properties = |
| 10230 session->http_server_properties(); | 10240 session->http_server_properties(); |
| 10231 AlternativeServiceVector alternative_service_vector = | 10241 AlternativeServiceVector alternative_service_vector = |
| 10232 http_server_properties->GetAlternativeServices(test_server); | 10242 http_server_properties->GetAlternativeServices(test_server); |
| 10233 EXPECT_TRUE(alternative_service_vector.empty()); | 10243 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10234 | 10244 |
| 10235 EXPECT_EQ(OK, callback.WaitForResult()); | 10245 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10236 | 10246 |
| 10237 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10247 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10238 ASSERT_TRUE(response); | 10248 ASSERT_TRUE(response); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 10251 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 10261 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 10252 alternative_service_vector[0].protocol); | 10262 alternative_service_vector[0].protocol); |
| 10253 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); | 10263 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); |
| 10254 EXPECT_EQ(443, alternative_service_vector[0].port); | 10264 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 10255 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 10265 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 10256 alternative_service_vector[1].protocol); | 10266 alternative_service_vector[1].protocol); |
| 10257 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); | 10267 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); |
| 10258 EXPECT_EQ(1234, alternative_service_vector[1].port); | 10268 EXPECT_EQ(1234, alternative_service_vector[1].port); |
| 10259 } | 10269 } |
| 10260 | 10270 |
| 10261 // When |enable_http2_alternative_service_with_different_host| is false, do not | |
| 10262 // observe alternative service entries that point to a different host. | |
| 10263 TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) { | |
|
Bence
2016/06/28 20:09:20
After changing to https, this is totally redundant
| |
| 10264 session_deps_.enable_http2_alternative_service_with_different_host = false; | |
| 10265 | |
| 10266 HttpRequestInfo request; | |
| 10267 request.method = "GET"; | |
| 10268 request.url = GURL("http://www.example.org/"); | |
| 10269 request.load_flags = 0; | |
| 10270 | |
| 10271 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | |
| 10272 StaticSocketDataProvider first_data; | |
| 10273 first_data.set_connect_data(mock_connect); | |
| 10274 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | |
| 10275 | |
| 10276 MockRead data_reads[] = { | |
| 10277 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello world"), | |
| 10278 MockRead(ASYNC, OK), | |
| 10279 }; | |
| 10280 StaticSocketDataProvider second_data(data_reads, arraysize(data_reads), | |
| 10281 nullptr, 0); | |
| 10282 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | |
| 10283 | |
| 10284 std::unique_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); | |
| 10285 | |
| 10286 HttpServerProperties* http_server_properties = | |
| 10287 session->http_server_properties(); | |
| 10288 AlternativeService alternative_service( | |
| 10289 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org", | |
| 10290 80); | |
| 10291 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | |
| 10292 http_server_properties->SetAlternativeService( | |
| 10293 url::SchemeHostPort(request.url), alternative_service, expiration); | |
| 10294 | |
| 10295 std::unique_ptr<HttpTransaction> trans( | |
| 10296 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | |
| 10297 TestCompletionCallback callback; | |
| 10298 | |
| 10299 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | |
| 10300 // The connetion to origin was refused, and the alternative service should not | |
| 10301 // be used (even though mock data are there), therefore the request should | |
| 10302 // fail. | |
| 10303 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); | |
| 10304 } | |
| 10305 | |
| 10306 TEST_P(HttpNetworkTransactionTest, IdentifyQuicBroken) { | 10271 TEST_P(HttpNetworkTransactionTest, IdentifyQuicBroken) { |
| 10307 url::SchemeHostPort server("https", "origin.example.org", 443); | 10272 url::SchemeHostPort server("https", "origin.example.org", 443); |
| 10308 HostPortPair alternative("alternative.example.org", 443); | 10273 HostPortPair alternative("alternative.example.org", 443); |
| 10309 std::string origin_url = "https://origin.example.org:443"; | 10274 std::string origin_url = "https://origin.example.org:443"; |
| 10310 std::string alternative_url = "https://alternative.example.org:443"; | 10275 std::string alternative_url = "https://alternative.example.org:443"; |
| 10311 | 10276 |
| 10312 // Negotiate HTTP/1.1 with alternative.example.org. | 10277 // Negotiate HTTP/1.1 with alternative.example.org. |
| 10313 SSLSocketDataProvider ssl(ASYNC, OK); | 10278 SSLSocketDataProvider ssl(ASYNC, OK); |
| 10314 ssl.SetNextProto(kProtoHTTP11); | 10279 ssl.SetNextProto(kProtoHTTP11); |
| 10315 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 10280 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10433 | 10398 |
| 10434 trans->Start(&request, callback.callback(), BoundNetLog()); | 10399 trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10435 trans->PopulateNetErrorDetails(&details); | 10400 trans->PopulateNetErrorDetails(&details); |
| 10436 EXPECT_FALSE(details.quic_broken); | 10401 EXPECT_FALSE(details.quic_broken); |
| 10437 } | 10402 } |
| 10438 | 10403 |
| 10439 TEST_P(HttpNetworkTransactionTest, | 10404 TEST_P(HttpNetworkTransactionTest, |
| 10440 MarkBrokenAlternateProtocolAndFallback) { | 10405 MarkBrokenAlternateProtocolAndFallback) { |
| 10441 HttpRequestInfo request; | 10406 HttpRequestInfo request; |
| 10442 request.method = "GET"; | 10407 request.method = "GET"; |
| 10443 request.url = GURL("http://www.example.org/"); | 10408 request.url = GURL("https://www.example.org/"); |
| 10444 request.load_flags = 0; | 10409 request.load_flags = 0; |
| 10445 | 10410 |
| 10446 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10411 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10447 StaticSocketDataProvider first_data; | 10412 StaticSocketDataProvider first_data; |
| 10448 first_data.set_connect_data(mock_connect); | 10413 first_data.set_connect_data(mock_connect); |
| 10449 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10414 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10415 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 10416 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 10417 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 10450 | 10418 |
| 10451 MockRead data_reads[] = { | 10419 MockRead data_reads[] = { |
| 10452 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 10420 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 10453 MockRead("hello world"), | 10421 MockRead("hello world"), |
| 10454 MockRead(ASYNC, OK), | 10422 MockRead(ASYNC, OK), |
| 10455 }; | 10423 }; |
| 10456 StaticSocketDataProvider second_data( | 10424 StaticSocketDataProvider second_data( |
| 10457 data_reads, arraysize(data_reads), NULL, 0); | 10425 data_reads, arraysize(data_reads), NULL, 0); |
| 10458 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10426 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10459 | 10427 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10497 } | 10465 } |
| 10498 | 10466 |
| 10499 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10467 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10500 // to an unrestricted (port >= 1024) when the original traffic was on a | 10468 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10501 // restricted port (port < 1024). Ensure that we can redirect in all other | 10469 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10502 // cases. | 10470 // cases. |
| 10503 TEST_P(HttpNetworkTransactionTest, | 10471 TEST_P(HttpNetworkTransactionTest, |
| 10504 AlternateProtocolPortRestrictedBlocked) { | 10472 AlternateProtocolPortRestrictedBlocked) { |
| 10505 HttpRequestInfo restricted_port_request; | 10473 HttpRequestInfo restricted_port_request; |
| 10506 restricted_port_request.method = "GET"; | 10474 restricted_port_request.method = "GET"; |
| 10507 restricted_port_request.url = GURL("http://www.example.org:1023/"); | 10475 restricted_port_request.url = GURL("https://www.example.org:1023/"); |
| 10508 restricted_port_request.load_flags = 0; | 10476 restricted_port_request.load_flags = 0; |
| 10509 | 10477 |
| 10510 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10478 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10511 StaticSocketDataProvider first_data; | 10479 StaticSocketDataProvider first_data; |
| 10512 first_data.set_connect_data(mock_connect); | 10480 first_data.set_connect_data(mock_connect); |
| 10513 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10481 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10514 | 10482 |
| 10515 MockRead data_reads[] = { | 10483 MockRead data_reads[] = { |
| 10516 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 10484 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 10517 MockRead("hello world"), | 10485 MockRead("hello world"), |
| 10518 MockRead(ASYNC, OK), | 10486 MockRead(ASYNC, OK), |
| 10519 }; | 10487 }; |
| 10520 StaticSocketDataProvider second_data( | 10488 StaticSocketDataProvider second_data( |
| 10521 data_reads, arraysize(data_reads), NULL, 0); | 10489 data_reads, arraysize(data_reads), NULL, 0); |
| 10522 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10490 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10491 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 10492 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 10493 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 10523 | 10494 |
| 10524 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10495 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10525 | 10496 |
| 10526 HttpServerProperties* http_server_properties = | 10497 HttpServerProperties* http_server_properties = |
| 10527 session->http_server_properties(); | 10498 session->http_server_properties(); |
| 10528 const int kUnrestrictedAlternatePort = 1024; | 10499 const int kUnrestrictedAlternatePort = 1024; |
| 10529 AlternativeService alternative_service( | 10500 AlternativeService alternative_service( |
| 10530 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10501 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10531 kUnrestrictedAlternatePort); | 10502 kUnrestrictedAlternatePort); |
| 10532 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10503 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 10548 | 10519 |
| 10549 // Ensure that we are allowed to redirect traffic via an alternate protocol to | 10520 // Ensure that we are allowed to redirect traffic via an alternate protocol to |
| 10550 // an unrestricted (port >= 1024) when the original traffic was on a restricted | 10521 // an unrestricted (port >= 1024) when the original traffic was on a restricted |
| 10551 // port (port < 1024) if we set |enable_user_alternate_protocol_ports|. | 10522 // port (port < 1024) if we set |enable_user_alternate_protocol_ports|. |
| 10552 TEST_P(HttpNetworkTransactionTest, | 10523 TEST_P(HttpNetworkTransactionTest, |
| 10553 AlternateProtocolPortRestrictedPermitted) { | 10524 AlternateProtocolPortRestrictedPermitted) { |
| 10554 session_deps_.enable_user_alternate_protocol_ports = true; | 10525 session_deps_.enable_user_alternate_protocol_ports = true; |
| 10555 | 10526 |
| 10556 HttpRequestInfo restricted_port_request; | 10527 HttpRequestInfo restricted_port_request; |
| 10557 restricted_port_request.method = "GET"; | 10528 restricted_port_request.method = "GET"; |
| 10558 restricted_port_request.url = GURL("http://www.example.org:1023/"); | 10529 restricted_port_request.url = GURL("https://www.example.org:1023/"); |
| 10559 restricted_port_request.load_flags = 0; | 10530 restricted_port_request.load_flags = 0; |
| 10560 | 10531 |
| 10561 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10532 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10562 StaticSocketDataProvider first_data; | 10533 StaticSocketDataProvider first_data; |
| 10563 first_data.set_connect_data(mock_connect); | 10534 first_data.set_connect_data(mock_connect); |
| 10564 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10535 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10565 | 10536 |
| 10566 MockRead data_reads[] = { | 10537 MockRead data_reads[] = { |
| 10567 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 10538 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 10568 MockRead("hello world"), | 10539 MockRead("hello world"), |
| 10569 MockRead(ASYNC, OK), | 10540 MockRead(ASYNC, OK), |
| 10570 }; | 10541 }; |
| 10571 StaticSocketDataProvider second_data( | 10542 StaticSocketDataProvider second_data( |
| 10572 data_reads, arraysize(data_reads), NULL, 0); | 10543 data_reads, arraysize(data_reads), NULL, 0); |
| 10573 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10544 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10545 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 10546 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 10547 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 10574 | 10548 |
| 10575 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10549 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10576 | 10550 |
| 10577 HttpServerProperties* http_server_properties = | 10551 HttpServerProperties* http_server_properties = |
| 10578 session->http_server_properties(); | 10552 session->http_server_properties(); |
| 10579 const int kUnrestrictedAlternatePort = 1024; | 10553 const int kUnrestrictedAlternatePort = 1024; |
| 10580 AlternativeService alternative_service( | 10554 AlternativeService alternative_service( |
| 10581 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10555 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10582 kUnrestrictedAlternatePort); | 10556 kUnrestrictedAlternatePort); |
| 10583 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10557 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 10597 } | 10571 } |
| 10598 | 10572 |
| 10599 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10573 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10600 // to an unrestricted (port >= 1024) when the original traffic was on a | 10574 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10601 // restricted port (port < 1024). Ensure that we can redirect in all other | 10575 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10602 // cases. | 10576 // cases. |
| 10603 TEST_P(HttpNetworkTransactionTest, | 10577 TEST_P(HttpNetworkTransactionTest, |
| 10604 AlternateProtocolPortRestrictedAllowed) { | 10578 AlternateProtocolPortRestrictedAllowed) { |
| 10605 HttpRequestInfo restricted_port_request; | 10579 HttpRequestInfo restricted_port_request; |
| 10606 restricted_port_request.method = "GET"; | 10580 restricted_port_request.method = "GET"; |
| 10607 restricted_port_request.url = GURL("http://www.example.org:1023/"); | 10581 restricted_port_request.url = GURL("https://www.example.org:1023/"); |
| 10608 restricted_port_request.load_flags = 0; | 10582 restricted_port_request.load_flags = 0; |
| 10609 | 10583 |
| 10610 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10584 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10611 StaticSocketDataProvider first_data; | 10585 StaticSocketDataProvider first_data; |
| 10612 first_data.set_connect_data(mock_connect); | 10586 first_data.set_connect_data(mock_connect); |
| 10613 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10587 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10614 | 10588 |
| 10615 MockRead data_reads[] = { | 10589 MockRead data_reads[] = { |
| 10616 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 10590 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 10617 MockRead("hello world"), | 10591 MockRead("hello world"), |
| 10618 MockRead(ASYNC, OK), | 10592 MockRead(ASYNC, OK), |
| 10619 }; | 10593 }; |
| 10620 StaticSocketDataProvider second_data( | 10594 StaticSocketDataProvider second_data( |
| 10621 data_reads, arraysize(data_reads), NULL, 0); | 10595 data_reads, arraysize(data_reads), NULL, 0); |
| 10622 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10596 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10623 | 10597 |
| 10598 SSLSocketDataProvider ssl(ASYNC, OK); | |
| 10599 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 10600 | |
| 10624 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10601 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10625 | 10602 |
| 10626 HttpServerProperties* http_server_properties = | 10603 HttpServerProperties* http_server_properties = |
| 10627 session->http_server_properties(); | 10604 session->http_server_properties(); |
| 10628 const int kRestrictedAlternatePort = 80; | 10605 const int kRestrictedAlternatePort = 80; |
| 10629 AlternativeService alternative_service( | 10606 AlternativeService alternative_service( |
| 10630 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10607 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10631 kRestrictedAlternatePort); | 10608 kRestrictedAlternatePort); |
| 10632 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10609 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10633 http_server_properties->SetAlternativeService( | 10610 http_server_properties->SetAlternativeService( |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 10647 } | 10624 } |
| 10648 | 10625 |
| 10649 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10626 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10650 // to an unrestricted (port >= 1024) when the original traffic was on a | 10627 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10651 // restricted port (port < 1024). Ensure that we can redirect in all other | 10628 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10652 // cases. | 10629 // cases. |
| 10653 TEST_P(HttpNetworkTransactionTest, | 10630 TEST_P(HttpNetworkTransactionTest, |
| 10654 AlternateProtocolPortUnrestrictedAllowed1) { | 10631 AlternateProtocolPortUnrestrictedAllowed1) { |
| 10655 HttpRequestInfo unrestricted_port_request; | 10632 HttpRequestInfo unrestricted_port_request; |
| 10656 unrestricted_port_request.method = "GET"; | 10633 unrestricted_port_request.method = "GET"; |
| 10657 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); | 10634 unrestricted_port_request.url = GURL("https://www.example.org:1024/"); |
| 10658 unrestricted_port_request.load_flags = 0; | 10635 unrestricted_port_request.load_flags = 0; |
| 10659 | 10636 |
| 10660 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10637 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10661 StaticSocketDataProvider first_data; | 10638 StaticSocketDataProvider first_data; |
| 10662 first_data.set_connect_data(mock_connect); | 10639 first_data.set_connect_data(mock_connect); |
| 10663 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10640 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10664 | 10641 |
| 10665 MockRead data_reads[] = { | 10642 MockRead data_reads[] = { |
| 10666 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 10643 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 10667 MockRead("hello world"), | 10644 MockRead("hello world"), |
| 10668 MockRead(ASYNC, OK), | 10645 MockRead(ASYNC, OK), |
| 10669 }; | 10646 }; |
| 10670 StaticSocketDataProvider second_data( | 10647 StaticSocketDataProvider second_data( |
| 10671 data_reads, arraysize(data_reads), NULL, 0); | 10648 data_reads, arraysize(data_reads), NULL, 0); |
| 10672 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10649 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10650 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 10651 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 10652 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 10673 | 10653 |
| 10674 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10654 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10675 | 10655 |
| 10676 HttpServerProperties* http_server_properties = | 10656 HttpServerProperties* http_server_properties = |
| 10677 session->http_server_properties(); | 10657 session->http_server_properties(); |
| 10678 const int kRestrictedAlternatePort = 80; | 10658 const int kRestrictedAlternatePort = 80; |
| 10679 AlternativeService alternative_service( | 10659 AlternativeService alternative_service( |
| 10680 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10660 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10681 kRestrictedAlternatePort); | 10661 kRestrictedAlternatePort); |
| 10682 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10662 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 10696 } | 10676 } |
| 10697 | 10677 |
| 10698 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10678 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10699 // to an unrestricted (port >= 1024) when the original traffic was on a | 10679 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10700 // restricted port (port < 1024). Ensure that we can redirect in all other | 10680 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10701 // cases. | 10681 // cases. |
| 10702 TEST_P(HttpNetworkTransactionTest, | 10682 TEST_P(HttpNetworkTransactionTest, |
| 10703 AlternateProtocolPortUnrestrictedAllowed2) { | 10683 AlternateProtocolPortUnrestrictedAllowed2) { |
| 10704 HttpRequestInfo unrestricted_port_request; | 10684 HttpRequestInfo unrestricted_port_request; |
| 10705 unrestricted_port_request.method = "GET"; | 10685 unrestricted_port_request.method = "GET"; |
| 10706 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); | 10686 unrestricted_port_request.url = GURL("https://www.example.org:1024/"); |
| 10707 unrestricted_port_request.load_flags = 0; | 10687 unrestricted_port_request.load_flags = 0; |
| 10708 | 10688 |
| 10709 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10689 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10710 StaticSocketDataProvider first_data; | 10690 StaticSocketDataProvider first_data; |
| 10711 first_data.set_connect_data(mock_connect); | 10691 first_data.set_connect_data(mock_connect); |
| 10712 session_deps_.socket_factory->AddSocketDataProvider(&first_data); | 10692 session_deps_.socket_factory->AddSocketDataProvider(&first_data); |
| 10713 | 10693 |
| 10714 MockRead data_reads[] = { | 10694 MockRead data_reads[] = { |
| 10715 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 10695 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 10716 MockRead("hello world"), | 10696 MockRead("hello world"), |
| 10717 MockRead(ASYNC, OK), | 10697 MockRead(ASYNC, OK), |
| 10718 }; | 10698 }; |
| 10719 StaticSocketDataProvider second_data( | 10699 StaticSocketDataProvider second_data( |
| 10720 data_reads, arraysize(data_reads), NULL, 0); | 10700 data_reads, arraysize(data_reads), NULL, 0); |
| 10721 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10701 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10722 | 10702 |
| 10703 SSLSocketDataProvider ssl(ASYNC, OK); | |
| 10704 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 10705 | |
| 10723 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10706 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10724 | 10707 |
| 10725 HttpServerProperties* http_server_properties = | 10708 HttpServerProperties* http_server_properties = |
| 10726 session->http_server_properties(); | 10709 session->http_server_properties(); |
| 10727 const int kUnrestrictedAlternatePort = 1025; | 10710 const int kUnrestrictedAlternatePort = 1025; |
| 10728 AlternativeService alternative_service( | 10711 AlternativeService alternative_service( |
| 10729 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10712 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10730 kUnrestrictedAlternatePort); | 10713 kUnrestrictedAlternatePort); |
| 10731 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10714 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10732 http_server_properties->SetAlternativeService( | 10715 http_server_properties->SetAlternativeService( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10791 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10774 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10792 | 10775 |
| 10793 std::string response_data; | 10776 std::string response_data; |
| 10794 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10777 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10795 EXPECT_EQ("hello world", response_data); | 10778 EXPECT_EQ("hello world", response_data); |
| 10796 } | 10779 } |
| 10797 | 10780 |
| 10798 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { | 10781 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { |
| 10799 HttpRequestInfo request; | 10782 HttpRequestInfo request; |
| 10800 request.method = "GET"; | 10783 request.method = "GET"; |
| 10801 request.url = GURL("http://www.example.org/"); | 10784 request.url = GURL("https://www.example.org/"); |
| 10802 request.load_flags = 0; | 10785 request.load_flags = 0; |
| 10803 | 10786 |
| 10804 std::string alternative_service_http_header = | 10787 std::string alternative_service_http_header = |
| 10805 GetAlternativeServiceHttpHeader(); | 10788 GetAlternativeServiceHttpHeader(); |
| 10806 | 10789 |
| 10807 MockRead data_reads[] = { | 10790 MockRead data_reads[] = { |
| 10808 MockRead("HTTP/1.1 200 OK\r\n"), | 10791 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10809 MockRead(alternative_service_http_header.c_str()), | 10792 MockRead(alternative_service_http_header.c_str()), |
| 10810 MockRead("\r\n"), | 10793 MockRead("\r\n"), |
| 10811 MockRead("hello world"), | 10794 MockRead("hello world"), |
| 10812 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10795 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10813 MockRead(ASYNC, OK)}; | 10796 MockRead(ASYNC, OK)}; |
| 10814 | 10797 |
| 10815 StaticSocketDataProvider first_transaction( | 10798 StaticSocketDataProvider first_transaction( |
| 10816 data_reads, arraysize(data_reads), NULL, 0); | 10799 data_reads, arraysize(data_reads), NULL, 0); |
| 10817 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10800 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 10801 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 10802 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 10803 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 10818 | 10804 |
| 10819 SSLSocketDataProvider ssl(ASYNC, OK); | 10805 SSLSocketDataProvider ssl_http2(ASYNC, OK); |
| 10820 ssl.SetNextProto(GetProtocol()); | 10806 ssl_http2.SetNextProto(GetProtocol()); |
| 10821 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 10807 ssl_http2.cert = |
| 10822 ASSERT_TRUE(ssl.cert.get()); | 10808 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 10823 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 10809 ASSERT_TRUE(ssl_http2.cert.get()); |
| 10810 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 10824 | 10811 |
| 10825 std::unique_ptr<SpdySerializedFrame> req( | 10812 std::unique_ptr<SpdySerializedFrame> req( |
| 10826 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 10813 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 10827 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; | 10814 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; |
| 10828 | 10815 |
| 10829 std::unique_ptr<SpdySerializedFrame> resp( | 10816 std::unique_ptr<SpdySerializedFrame> resp( |
| 10830 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 10817 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 10831 std::unique_ptr<SpdySerializedFrame> data( | 10818 std::unique_ptr<SpdySerializedFrame> data( |
| 10832 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 10819 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 10833 MockRead spdy_reads[] = { | 10820 MockRead spdy_reads[] = { |
| 10834 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), | 10821 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), |
| 10835 }; | 10822 }; |
| 10836 | 10823 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10878 EXPECT_TRUE(response->was_fetched_via_spdy); | 10865 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10879 EXPECT_TRUE(response->was_npn_negotiated); | 10866 EXPECT_TRUE(response->was_npn_negotiated); |
| 10880 | 10867 |
| 10881 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10868 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10882 EXPECT_EQ("hello!", response_data); | 10869 EXPECT_EQ("hello!", response_data); |
| 10883 } | 10870 } |
| 10884 | 10871 |
| 10885 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { | 10872 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { |
| 10886 HttpRequestInfo request; | 10873 HttpRequestInfo request; |
| 10887 request.method = "GET"; | 10874 request.method = "GET"; |
| 10888 request.url = GURL("http://www.example.org/"); | 10875 request.url = GURL("https://www.example.org/"); |
| 10889 request.load_flags = 0; | 10876 request.load_flags = 0; |
| 10890 | 10877 |
| 10878 // First transaction receives Alt-Svc header over HTTP/1.1. | |
| 10891 std::string alternative_service_http_header = | 10879 std::string alternative_service_http_header = |
| 10892 GetAlternativeServiceHttpHeader(); | 10880 GetAlternativeServiceHttpHeader(); |
| 10893 | 10881 |
| 10894 MockRead data_reads[] = { | 10882 MockRead data_reads[] = { |
| 10895 MockRead("HTTP/1.1 200 OK\r\n"), | 10883 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10896 MockRead(alternative_service_http_header.c_str()), | 10884 MockRead(alternative_service_http_header.c_str()), |
| 10897 MockRead("\r\n"), | 10885 MockRead("\r\n"), |
| 10898 MockRead("hello world"), | 10886 MockRead("hello world"), |
| 10899 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10887 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10900 MockRead(ASYNC, OK), | 10888 MockRead(ASYNC, OK), |
| 10901 }; | 10889 }; |
| 10902 | 10890 |
| 10903 StaticSocketDataProvider first_transaction( | 10891 StaticSocketDataProvider http11_data(data_reads, arraysize(data_reads), NULL, |
| 10904 data_reads, arraysize(data_reads), NULL, 0); | 10892 0); |
| 10905 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. | 10893 session_deps_.socket_factory->AddSocketDataProvider(&http11_data); |
| 10906 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | |
| 10907 | 10894 |
| 10895 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 10896 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 10897 | |
| 10898 // Second transaction starts an alternative and a non-alternative Job. | |
| 10899 // Both sockets hang. | |
| 10908 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 10900 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 10909 StaticSocketDataProvider hanging_socket1(NULL, 0, NULL, 0); | 10901 StaticSocketDataProvider hanging_socket1(NULL, 0, NULL, 0); |
| 10910 hanging_socket1.set_connect_data(never_finishing_connect); | 10902 hanging_socket1.set_connect_data(never_finishing_connect); |
| 10911 // Socket 2 and 3 are the hanging Alternate-Protocol and | |
| 10912 // non-Alternate-Protocol jobs from the 2nd transaction. | |
| 10913 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket1); | 10903 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket1); |
| 10914 | 10904 |
| 10915 StaticSocketDataProvider hanging_socket2(NULL, 0, NULL, 0); | 10905 StaticSocketDataProvider hanging_socket2(NULL, 0, NULL, 0); |
| 10916 hanging_socket2.set_connect_data(never_finishing_connect); | 10906 hanging_socket2.set_connect_data(never_finishing_connect); |
| 10917 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket2); | 10907 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket2); |
| 10918 | 10908 |
| 10919 SSLSocketDataProvider ssl(ASYNC, OK); | 10909 // Third transaction starts an alternative and a non-alternative job. |
| 10920 ssl.SetNextProto(GetProtocol()); | 10910 // The non-alternative job hangs, but the alternative one succeeds. |
| 10921 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 10911 // The second transaction, still pending, binds to this socket. |
| 10922 ASSERT_TRUE(ssl.cert); | |
| 10923 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 10924 | |
| 10925 std::unique_ptr<SpdySerializedFrame> req1( | 10912 std::unique_ptr<SpdySerializedFrame> req1( |
| 10926 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 10913 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 10927 std::unique_ptr<SpdySerializedFrame> req2( | 10914 std::unique_ptr<SpdySerializedFrame> req2( |
| 10928 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); | 10915 spdy_util_.ConstructSpdyGet("https://www.example.org/", 3, LOWEST)); |
| 10929 MockWrite spdy_writes[] = { | 10916 MockWrite spdy_writes[] = { |
| 10930 CreateMockWrite(*req1, 0), CreateMockWrite(*req2, 1), | 10917 CreateMockWrite(*req1, 0), CreateMockWrite(*req2, 1), |
| 10931 }; | 10918 }; |
| 10932 std::unique_ptr<SpdySerializedFrame> resp1( | 10919 std::unique_ptr<SpdySerializedFrame> resp1( |
| 10933 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 10920 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 10934 std::unique_ptr<SpdySerializedFrame> data1( | 10921 std::unique_ptr<SpdySerializedFrame> data1( |
| 10935 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 10922 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 10936 std::unique_ptr<SpdySerializedFrame> resp2( | 10923 std::unique_ptr<SpdySerializedFrame> resp2( |
| 10937 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 10924 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 10938 std::unique_ptr<SpdySerializedFrame> data2( | 10925 std::unique_ptr<SpdySerializedFrame> data2( |
| 10939 spdy_util_.ConstructSpdyBodyFrame(3, true)); | 10926 spdy_util_.ConstructSpdyBodyFrame(3, true)); |
| 10940 MockRead spdy_reads[] = { | 10927 MockRead spdy_reads[] = { |
| 10941 CreateMockRead(*resp1, 2), | 10928 CreateMockRead(*resp1, 2), |
| 10942 CreateMockRead(*data1, 3), | 10929 CreateMockRead(*data1, 3), |
| 10943 CreateMockRead(*resp2, 4), | 10930 CreateMockRead(*resp2, 4), |
| 10944 CreateMockRead(*data2, 5), | 10931 CreateMockRead(*data2, 5), |
| 10945 MockRead(ASYNC, 0, 6), | 10932 MockRead(ASYNC, 0, 6), |
| 10946 }; | 10933 }; |
| 10947 | 10934 |
| 10948 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, | 10935 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, |
| 10949 arraysize(spdy_writes)); | 10936 arraysize(spdy_writes)); |
| 10950 // Socket 4 is the successful Alternate-Protocol for transaction 3. | |
| 10951 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10937 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
| 10952 | 10938 |
| 10953 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. | 10939 SSLSocketDataProvider ssl_http2(ASYNC, OK); |
| 10940 ssl_http2.SetNextProto(GetProtocol()); | |
| 10941 ssl_http2.cert = | |
| 10942 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 10943 ASSERT_TRUE(ssl_http2.cert); | |
| 10944 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 10945 | |
| 10954 StaticSocketDataProvider hanging_socket3(NULL, 0, NULL, 0); | 10946 StaticSocketDataProvider hanging_socket3(NULL, 0, NULL, 0); |
| 10955 hanging_socket3.set_connect_data(never_finishing_connect); | 10947 hanging_socket3.set_connect_data(never_finishing_connect); |
| 10956 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket3); | 10948 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket3); |
| 10957 | 10949 |
| 10958 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10950 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10959 TestCompletionCallback callback1; | 10951 TestCompletionCallback callback1; |
| 10960 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 10952 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 10961 | 10953 |
| 10962 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); | 10954 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); |
| 10963 EXPECT_EQ(ERR_IO_PENDING, rv); | 10955 EXPECT_EQ(ERR_IO_PENDING, rv); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11000 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10992 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 11001 EXPECT_TRUE(response->was_fetched_via_spdy); | 10993 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 11002 EXPECT_TRUE(response->was_npn_negotiated); | 10994 EXPECT_TRUE(response->was_npn_negotiated); |
| 11003 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); | 10995 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); |
| 11004 EXPECT_EQ("hello!", response_data); | 10996 EXPECT_EQ("hello!", response_data); |
| 11005 } | 10997 } |
| 11006 | 10998 |
| 11007 TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { | 10999 TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { |
| 11008 HttpRequestInfo request; | 11000 HttpRequestInfo request; |
| 11009 request.method = "GET"; | 11001 request.method = "GET"; |
| 11010 request.url = GURL("http://www.example.org/"); | 11002 request.url = GURL("https://www.example.org/"); |
| 11011 request.load_flags = 0; | 11003 request.load_flags = 0; |
| 11012 | 11004 |
| 11013 std::string alternative_service_http_header = | 11005 std::string alternative_service_http_header = |
| 11014 GetAlternativeServiceHttpHeader(); | 11006 GetAlternativeServiceHttpHeader(); |
| 11015 | 11007 |
| 11016 MockRead data_reads[] = { | 11008 MockRead data_reads[] = { |
| 11017 MockRead("HTTP/1.1 200 OK\r\n"), | 11009 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11018 MockRead(alternative_service_http_header.c_str()), | 11010 MockRead(alternative_service_http_header.c_str()), |
| 11019 MockRead("\r\n"), | 11011 MockRead("\r\n"), |
| 11020 MockRead("hello world"), | 11012 MockRead("hello world"), |
| 11021 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 11013 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 11022 MockRead(ASYNC, OK), | 11014 MockRead(ASYNC, OK), |
| 11023 }; | 11015 }; |
| 11024 | 11016 |
| 11025 StaticSocketDataProvider first_transaction( | 11017 StaticSocketDataProvider first_transaction( |
| 11026 data_reads, arraysize(data_reads), NULL, 0); | 11018 data_reads, arraysize(data_reads), NULL, 0); |
| 11027 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11019 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11028 | 11020 |
| 11029 SSLSocketDataProvider ssl(ASYNC, OK); | 11021 SSLSocketDataProvider ssl(ASYNC, OK); |
| 11030 ssl.SetNextProto(GetProtocol()); | |
| 11031 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11022 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 11032 | 11023 |
| 11033 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 11024 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 11034 StaticSocketDataProvider hanging_alternate_protocol_socket( | 11025 StaticSocketDataProvider hanging_alternate_protocol_socket( |
| 11035 NULL, 0, NULL, 0); | 11026 NULL, 0, NULL, 0); |
| 11036 hanging_alternate_protocol_socket.set_connect_data( | 11027 hanging_alternate_protocol_socket.set_connect_data( |
| 11037 never_finishing_connect); | 11028 never_finishing_connect); |
| 11038 session_deps_.socket_factory->AddSocketDataProvider( | 11029 session_deps_.socket_factory->AddSocketDataProvider( |
| 11039 &hanging_alternate_protocol_socket); | 11030 &hanging_alternate_protocol_socket); |
| 11040 | 11031 |
| 11041 // 2nd request is just a copy of the first one, over HTTP again. | 11032 // 2nd request is just a copy of the first one, over HTTP/1.1 again. |
| 11042 StaticSocketDataProvider second_transaction(data_reads, arraysize(data_reads), | 11033 StaticSocketDataProvider second_transaction(data_reads, arraysize(data_reads), |
| 11043 NULL, 0); | 11034 NULL, 0); |
| 11044 session_deps_.socket_factory->AddSocketDataProvider(&second_transaction); | 11035 session_deps_.socket_factory->AddSocketDataProvider(&second_transaction); |
| 11036 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 11045 | 11037 |
| 11046 TestCompletionCallback callback; | 11038 TestCompletionCallback callback; |
| 11047 | 11039 |
| 11048 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 11040 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 11049 std::unique_ptr<HttpTransaction> trans( | 11041 std::unique_ptr<HttpTransaction> trans( |
| 11050 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11042 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11051 | 11043 |
| 11052 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11044 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11053 EXPECT_EQ(ERR_IO_PENDING, rv); | 11045 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11054 EXPECT_EQ(OK, callback.WaitForResult()); | 11046 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11138 session_deps_.proxy_service.reset(new ProxyService( | 11130 session_deps_.proxy_service.reset(new ProxyService( |
| 11139 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), | 11131 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), |
| 11140 base::WrapUnique( | 11132 base::WrapUnique( |
| 11141 new CapturingProxyResolverFactory(&capturing_proxy_resolver)), | 11133 new CapturingProxyResolverFactory(&capturing_proxy_resolver)), |
| 11142 NULL)); | 11134 NULL)); |
| 11143 TestNetLog net_log; | 11135 TestNetLog net_log; |
| 11144 session_deps_.net_log = &net_log; | 11136 session_deps_.net_log = &net_log; |
| 11145 | 11137 |
| 11146 HttpRequestInfo request; | 11138 HttpRequestInfo request; |
| 11147 request.method = "GET"; | 11139 request.method = "GET"; |
| 11148 request.url = GURL("http://www.example.org/"); | 11140 request.url = GURL("https://www.example.org/"); |
| 11149 request.load_flags = 0; | 11141 request.load_flags = 0; |
| 11150 | 11142 |
| 11151 std::string alternative_service_http_header = | 11143 std::string alternative_service_http_header = |
| 11152 GetAlternativeServiceHttpHeader(); | 11144 GetAlternativeServiceHttpHeader(); |
| 11153 | 11145 |
| 11154 MockRead data_reads[] = { | 11146 MockRead data_reads[] = { |
| 11155 MockRead("HTTP/1.1 200 OK\r\n"), | 11147 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11156 MockRead(alternative_service_http_header.c_str()), | 11148 MockRead(alternative_service_http_header.c_str()), |
| 11157 MockRead("\r\n"), | 11149 MockRead("\r\n"), |
| 11158 MockRead("hello world"), | 11150 MockRead("hello world"), |
| 11159 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 11151 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 11160 MockRead(ASYNC, OK), | 11152 MockRead(ASYNC, OK), |
| 11161 }; | 11153 }; |
| 11162 | 11154 |
| 11163 StaticSocketDataProvider first_transaction( | 11155 StaticSocketDataProvider first_transaction( |
| 11164 data_reads, arraysize(data_reads), NULL, 0); | 11156 data_reads, arraysize(data_reads), NULL, 0); |
| 11165 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11157 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11158 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 11159 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 11160 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 11166 | 11161 |
| 11167 SSLSocketDataProvider ssl(ASYNC, OK); | 11162 SSLSocketDataProvider ssl_http2(ASYNC, OK); |
| 11168 ssl.SetNextProto(GetProtocol()); | 11163 ssl_http2.SetNextProto(GetProtocol()); |
| 11169 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 11164 ssl_http2.cert = |
| 11170 ASSERT_TRUE(ssl.cert); | 11165 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 11171 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11166 ASSERT_TRUE(ssl_http2.cert); |
| 11167 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 11172 | 11168 |
| 11173 std::unique_ptr<SpdySerializedFrame> req( | 11169 std::unique_ptr<SpdySerializedFrame> req( |
| 11174 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 11170 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 11175 MockWrite spdy_writes[] = { | 11171 MockWrite spdy_writes[] = { |
| 11176 MockWrite(ASYNC, 0, | 11172 MockWrite(ASYNC, 0, |
| 11177 "CONNECT www.example.org:443 HTTP/1.1\r\n" | 11173 "CONNECT www.example.org:443 HTTP/1.1\r\n" |
| 11178 "Host: www.example.org:443\r\n" | 11174 "Host: www.example.org:443\r\n" |
| 11179 "Proxy-Connection: keep-alive\r\n\r\n"), | 11175 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 11180 CreateMockWrite(*req, 2), | 11176 CreateMockWrite(*req, 2), |
| 11181 }; | 11177 }; |
| 11182 | 11178 |
| 11183 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; | 11179 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; |
| 11184 | 11180 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 11209 std::unique_ptr<HttpTransaction> trans( | 11205 std::unique_ptr<HttpTransaction> trans( |
| 11210 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11206 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11211 | 11207 |
| 11212 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11208 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11213 EXPECT_EQ(ERR_IO_PENDING, rv); | 11209 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11214 EXPECT_EQ(OK, callback.WaitForResult()); | 11210 EXPECT_EQ(OK, callback.WaitForResult()); |
| 11215 | 11211 |
| 11216 const HttpResponseInfo* response = trans->GetResponseInfo(); | 11212 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 11217 ASSERT_TRUE(response); | 11213 ASSERT_TRUE(response); |
| 11218 ASSERT_TRUE(response->headers); | 11214 ASSERT_TRUE(response->headers); |
| 11219 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11215 EXPECT_EQ("HTTP/0.9 200 OK", response->headers->GetStatusLine()); |
| 11220 EXPECT_FALSE(response->was_fetched_via_spdy); | 11216 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 11221 EXPECT_FALSE(response->was_npn_negotiated); | 11217 EXPECT_TRUE(response->was_npn_negotiated); |
| 11222 | 11218 |
| 11223 std::string response_data; | 11219 std::string response_data; |
| 11224 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11220 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11225 EXPECT_EQ("hello world", response_data); | 11221 EXPECT_EQ("hello world", response_data); |
| 11226 | 11222 |
| 11227 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11223 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11228 | 11224 |
| 11229 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11225 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11230 EXPECT_EQ(ERR_IO_PENDING, rv); | 11226 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11231 EXPECT_EQ(OK, callback.WaitForResult()); | 11227 EXPECT_EQ(OK, callback.WaitForResult()); |
| 11232 | 11228 |
| 11233 response = trans->GetResponseInfo(); | 11229 response = trans->GetResponseInfo(); |
| 11234 ASSERT_TRUE(response); | 11230 ASSERT_TRUE(response); |
| 11235 ASSERT_TRUE(response->headers); | 11231 ASSERT_TRUE(response->headers); |
| 11236 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 11232 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 11237 EXPECT_TRUE(response->was_fetched_via_spdy); | 11233 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 11238 EXPECT_TRUE(response->was_npn_negotiated); | 11234 EXPECT_TRUE(response->was_npn_negotiated); |
| 11239 | 11235 |
| 11240 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 11236 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11241 EXPECT_EQ("hello!", response_data); | 11237 EXPECT_EQ("hello!", response_data); |
| 11242 ASSERT_EQ(3u, capturing_proxy_resolver.resolved().size()); | 11238 ASSERT_EQ(2u, capturing_proxy_resolver.resolved().size()); |
| 11243 EXPECT_EQ("http://www.example.org/", | 11239 EXPECT_EQ("https://www.example.org/", |
| 11244 capturing_proxy_resolver.resolved()[0].spec()); | 11240 capturing_proxy_resolver.resolved()[0].spec()); |
| 11245 EXPECT_EQ("https://www.example.org/", | 11241 EXPECT_EQ("https://www.example.org/", |
| 11246 capturing_proxy_resolver.resolved()[1].spec()); | 11242 capturing_proxy_resolver.resolved()[1].spec()); |
| 11247 | 11243 |
| 11248 LoadTimingInfo load_timing_info; | 11244 LoadTimingInfo load_timing_info; |
| 11249 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 11245 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 11250 TestLoadTimingNotReusedWithPac(load_timing_info, | 11246 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 11251 CONNECT_TIMING_HAS_SSL_TIMES); | 11247 CONNECT_TIMING_HAS_SSL_TIMES); |
| 11252 } | 11248 } |
| 11253 | 11249 |
| 11254 TEST_P(HttpNetworkTransactionTest, | 11250 TEST_P(HttpNetworkTransactionTest, |
| 11255 UseAlternativeServiceForNpnSpdyWithExistingSpdySession) { | 11251 UseAlternativeServiceForNpnSpdyWithExistingSpdySession) { |
| 11256 HttpRequestInfo request; | 11252 HttpRequestInfo request; |
| 11257 request.method = "GET"; | 11253 request.method = "GET"; |
| 11258 request.url = GURL("http://www.example.org/"); | 11254 request.url = GURL("https://www.example.org/"); |
| 11259 request.load_flags = 0; | 11255 request.load_flags = 0; |
| 11260 | 11256 |
| 11261 std::string alternative_service_http_header = | 11257 std::string alternative_service_http_header = |
| 11262 GetAlternativeServiceHttpHeader(); | 11258 GetAlternativeServiceHttpHeader(); |
| 11263 | 11259 |
| 11264 MockRead data_reads[] = { | 11260 MockRead data_reads[] = { |
| 11265 MockRead("HTTP/1.1 200 OK\r\n"), | 11261 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11266 MockRead(alternative_service_http_header.c_str()), | 11262 MockRead(alternative_service_http_header.c_str()), |
| 11267 MockRead("\r\n"), | 11263 MockRead("\r\n"), |
| 11268 MockRead("hello world"), | 11264 MockRead("hello world"), |
| 11269 MockRead(ASYNC, OK), | 11265 MockRead(ASYNC, OK), |
| 11270 }; | 11266 }; |
| 11271 | 11267 |
| 11272 StaticSocketDataProvider first_transaction( | 11268 StaticSocketDataProvider first_transaction( |
| 11273 data_reads, arraysize(data_reads), NULL, 0); | 11269 data_reads, arraysize(data_reads), NULL, 0); |
| 11274 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11270 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11271 SSLSocketDataProvider ssl_http11(ASYNC, OK); | |
| 11272 ssl_http11.SetNextProto(kProtoHTTP11); | |
| 11273 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | |
| 11275 | 11274 |
| 11276 SSLSocketDataProvider ssl(ASYNC, OK); | 11275 SSLSocketDataProvider ssl_http2(ASYNC, OK); |
| 11277 ssl.SetNextProto(GetProtocol()); | 11276 ssl_http2.SetNextProto(GetProtocol()); |
| 11278 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 11277 ssl_http2.cert = |
| 11279 ASSERT_TRUE(ssl.cert); | 11278 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 11280 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11279 ASSERT_TRUE(ssl_http2.cert); |
| 11280 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 11281 | 11281 |
| 11282 std::unique_ptr<SpdySerializedFrame> req( | 11282 std::unique_ptr<SpdySerializedFrame> req( |
| 11283 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 11283 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 11284 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; | 11284 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; |
| 11285 | 11285 |
| 11286 std::unique_ptr<SpdySerializedFrame> resp( | 11286 std::unique_ptr<SpdySerializedFrame> resp( |
| 11287 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 11287 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 11288 std::unique_ptr<SpdySerializedFrame> data( | 11288 std::unique_ptr<SpdySerializedFrame> data( |
| 11289 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 11289 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 11290 MockRead spdy_reads[] = { | 11290 MockRead spdy_reads[] = { |
| 11291 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), | 11291 CreateMockRead(*resp, 1), CreateMockRead(*data, 2), MockRead(ASYNC, 0, 3), |
| 11292 }; | 11292 }; |
| 11293 | 11293 |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12061 std::string* auth_token) override { | 12061 std::string* auth_token) override { |
| 12062 *url_ = request->url; | 12062 *url_ = request->url; |
| 12063 return HttpAuthHandlerMock::GenerateAuthTokenImpl( | 12063 return HttpAuthHandlerMock::GenerateAuthTokenImpl( |
| 12064 credentials, request, callback, auth_token); | 12064 credentials, request, callback, auth_token); |
| 12065 } | 12065 } |
| 12066 | 12066 |
| 12067 private: | 12067 private: |
| 12068 GURL* url_; | 12068 GURL* url_; |
| 12069 }; | 12069 }; |
| 12070 | 12070 |
| 12071 // This test ensures that the URL passed into the proxy is upgraded to https | |
| 12072 // when doing an Alternate Protocol upgrade. | |
| 12073 TEST_P(HttpNetworkTransactionTest, SpdyAlternativeServiceThroughProxy) { | |
|
Bence
2016/06/28 20:09:20
Alternative Service is not allowed for http scheme
| |
| 12074 session_deps_.proxy_service = | |
| 12075 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); | |
| 12076 TestNetLog net_log; | |
| 12077 session_deps_.net_log = &net_log; | |
| 12078 GURL request_url; | |
| 12079 { | |
| 12080 HttpAuthHandlerMock::Factory* auth_factory = | |
| 12081 new HttpAuthHandlerMock::Factory(); | |
| 12082 UrlRecordingHttpAuthHandlerMock* auth_handler = | |
| 12083 new UrlRecordingHttpAuthHandlerMock(&request_url); | |
| 12084 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); | |
| 12085 auth_factory->set_do_init_from_challenge(true); | |
| 12086 session_deps_.http_auth_handler_factory.reset(auth_factory); | |
| 12087 } | |
| 12088 | |
| 12089 HttpRequestInfo request; | |
| 12090 request.method = "GET"; | |
| 12091 request.url = GURL("http://www.example.org"); | |
| 12092 request.load_flags = 0; | |
| 12093 | |
| 12094 // First round goes unauthenticated through the proxy. | |
| 12095 MockWrite data_writes_1[] = { | |
| 12096 MockWrite( | |
| 12097 "GET http://www.example.org/ HTTP/1.1\r\n" | |
| 12098 "Host: www.example.org\r\n" | |
| 12099 "Proxy-Connection: keep-alive\r\n" | |
| 12100 "\r\n"), | |
| 12101 }; | |
| 12102 MockRead data_reads_1[] = { | |
| 12103 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | |
| 12104 MockRead("HTTP/1.1 200 OK\r\n"), | |
| 12105 MockRead("Alt-Svc: "), | |
| 12106 MockRead(GetAlternateProtocolFromParam()), | |
| 12107 MockRead("=\":443\"\r\n"), | |
| 12108 MockRead("Proxy-Connection: close\r\n"), | |
| 12109 MockRead("\r\n"), | |
| 12110 }; | |
| 12111 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), | |
| 12112 data_writes_1, arraysize(data_writes_1)); | |
| 12113 | |
| 12114 // Second round tries to tunnel to www.example.org due to the | |
| 12115 // Alternate-Protocol announcement in the first round. It fails due | |
| 12116 // to a proxy authentication challenge. | |
| 12117 // After the failure, a tunnel is established to www.example.org using | |
| 12118 // Proxy-Authorization headers. There is then a SPDY request round. | |
| 12119 // | |
| 12120 // NOTE: Despite the "Proxy-Connection: Close", these are done on the | |
| 12121 // same MockTCPClientSocket since the underlying HttpNetworkClientSocket | |
| 12122 // does a Disconnect and Connect on the same socket, rather than trying | |
| 12123 // to obtain a new one. | |
| 12124 // | |
| 12125 // NOTE: Originally, the proxy response to the second CONNECT request | |
| 12126 // simply returned another 407 so the unit test could skip the SSL connection | |
| 12127 // establishment and SPDY framing issues. Alas, the | |
| 12128 // retry-http-when-alternate-protocol fails logic kicks in, which was more | |
| 12129 // complicated to set up expectations for than the SPDY session. | |
| 12130 | |
| 12131 std::unique_ptr<SpdySerializedFrame> req( | |
| 12132 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | |
| 12133 std::unique_ptr<SpdySerializedFrame> resp( | |
| 12134 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | |
| 12135 std::unique_ptr<SpdySerializedFrame> data( | |
| 12136 spdy_util_.ConstructSpdyBodyFrame(1, true)); | |
| 12137 | |
| 12138 MockWrite data_writes_2[] = { | |
| 12139 // First connection attempt without Proxy-Authorization. | |
| 12140 MockWrite(ASYNC, 0, | |
| 12141 "CONNECT www.example.org:443 HTTP/1.1\r\n" | |
| 12142 "Host: www.example.org:443\r\n" | |
| 12143 "Proxy-Connection: keep-alive\r\n" | |
| 12144 "\r\n"), | |
| 12145 | |
| 12146 // Second connection attempt with Proxy-Authorization. | |
| 12147 MockWrite(ASYNC, 2, | |
| 12148 "CONNECT www.example.org:443 HTTP/1.1\r\n" | |
| 12149 "Host: www.example.org:443\r\n" | |
| 12150 "Proxy-Connection: keep-alive\r\n" | |
| 12151 "Proxy-Authorization: auth_token\r\n" | |
| 12152 "\r\n"), | |
| 12153 | |
| 12154 // SPDY request | |
| 12155 CreateMockWrite(*req, 4), | |
| 12156 }; | |
| 12157 MockRead data_reads_2[] = { | |
| 12158 // First connection attempt fails | |
| 12159 MockRead(ASYNC, 1, | |
| 12160 "HTTP/1.1 407 Unauthorized\r\n" | |
| 12161 "Proxy-Authenticate: Mock\r\n" | |
| 12162 "Content-Length: 0\r\n" | |
| 12163 "Proxy-Connection: keep-alive\r\n" | |
| 12164 "\r\n"), | |
| 12165 | |
| 12166 // Second connection attempt passes | |
| 12167 MockRead(ASYNC, 3, "HTTP/1.1 200 Connected\r\n\r\n"), | |
| 12168 | |
| 12169 // SPDY response | |
| 12170 CreateMockRead(*resp.get(), 5), CreateMockRead(*data.get(), 6), | |
| 12171 MockRead(ASYNC, 0, 0, 7), | |
| 12172 }; | |
| 12173 SequencedSocketData data_2(data_reads_2, arraysize(data_reads_2), | |
| 12174 data_writes_2, arraysize(data_writes_2)); | |
| 12175 | |
| 12176 SSLSocketDataProvider ssl(ASYNC, OK); | |
| 12177 ssl.SetNextProto(GetProtocol()); | |
| 12178 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 12179 ASSERT_TRUE(ssl.cert); | |
| 12180 | |
| 12181 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | |
| 12182 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | |
| 12183 NULL, 0, NULL, 0); | |
| 12184 hanging_non_alternate_protocol_socket.set_connect_data( | |
| 12185 never_finishing_connect); | |
| 12186 | |
| 12187 session_deps_.socket_factory->AddSocketDataProvider(&data_1); | |
| 12188 session_deps_.socket_factory->AddSocketDataProvider(&data_2); | |
| 12189 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 12190 session_deps_.socket_factory->AddSocketDataProvider( | |
| 12191 &hanging_non_alternate_protocol_socket); | |
| 12192 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | |
| 12193 | |
| 12194 // First round should work and provide the Alternate-Protocol state. | |
| 12195 TestCompletionCallback callback_1; | |
| 12196 std::unique_ptr<HttpTransaction> trans_1( | |
| 12197 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | |
| 12198 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); | |
| 12199 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 12200 EXPECT_EQ(OK, callback_1.WaitForResult()); | |
| 12201 | |
| 12202 // Second round should attempt a tunnel connect and get an auth challenge. | |
| 12203 TestCompletionCallback callback_2; | |
| 12204 std::unique_ptr<HttpTransaction> trans_2( | |
| 12205 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | |
| 12206 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); | |
| 12207 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 12208 EXPECT_EQ(OK, callback_2.WaitForResult()); | |
| 12209 const HttpResponseInfo* response = trans_2->GetResponseInfo(); | |
| 12210 ASSERT_TRUE(response); | |
| 12211 ASSERT_TRUE(response->auth_challenge); | |
| 12212 | |
| 12213 // Restart with auth. Tunnel should work and response received. | |
| 12214 TestCompletionCallback callback_3; | |
| 12215 rv = trans_2->RestartWithAuth( | |
| 12216 AuthCredentials(kFoo, kBar), callback_3.callback()); | |
| 12217 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 12218 EXPECT_EQ(OK, callback_3.WaitForResult()); | |
| 12219 | |
| 12220 // After all that work, these two lines (or actually, just the scheme) are | |
| 12221 // what this test is all about. Make sure it happens correctly. | |
| 12222 EXPECT_EQ("https", request_url.scheme()); | |
| 12223 EXPECT_EQ("www.example.org", request_url.host()); | |
| 12224 | |
| 12225 LoadTimingInfo load_timing_info; | |
| 12226 EXPECT_TRUE(trans_2->GetLoadTimingInfo(&load_timing_info)); | |
| 12227 TestLoadTimingNotReusedWithPac(load_timing_info, | |
| 12228 CONNECT_TIMING_HAS_SSL_TIMES); | |
| 12229 } | |
| 12230 | |
| 12231 // Test that if we cancel the transaction as the connection is completing, that | 12071 // Test that if we cancel the transaction as the connection is completing, that |
| 12232 // everything tears down correctly. | 12072 // everything tears down correctly. |
| 12233 TEST_P(HttpNetworkTransactionTest, SimpleCancel) { | 12073 TEST_P(HttpNetworkTransactionTest, SimpleCancel) { |
| 12234 // Setup everything about the connection to complete synchronously, so that | 12074 // Setup everything about the connection to complete synchronously, so that |
| 12235 // after calling HttpNetworkTransaction::Start, the only thing we're waiting | 12075 // after calling HttpNetworkTransaction::Start, the only thing we're waiting |
| 12236 // for is the callback from the HttpStreamRequest. | 12076 // for is the callback from the HttpStreamRequest. |
| 12237 // Then cancel the transaction. | 12077 // Then cancel the transaction. |
| 12238 // Verify that we don't crash. | 12078 // Verify that we don't crash. |
| 12239 MockConnect mock_connect(SYNCHRONOUS, OK); | 12079 MockConnect mock_connect(SYNCHRONOUS, OK); |
| 12240 MockRead data_reads[] = { | 12080 MockRead data_reads[] = { |
| (...skipping 3842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16083 base::RunLoop().RunUntilIdle(); | 15923 base::RunLoop().RunUntilIdle(); |
| 16084 | 15924 |
| 16085 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15925 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 16086 HttpRequestHeaders headers; | 15926 HttpRequestHeaders headers; |
| 16087 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15927 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 16088 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15928 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 16089 } | 15929 } |
| 16090 #endif // !defined(OS_IOS) | 15930 #endif // !defined(OS_IOS) |
| 16091 | 15931 |
| 16092 } // namespace net | 15932 } // namespace net |
| OLD | NEW |