OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <memory> | 6 #include <memory> |
7 #include <ostream> | 7 #include <ostream> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/test/histogram_tester.h" | 19 #include "base/test/histogram_tester.h" |
19 #include "net/base/chunked_upload_data_stream.h" | 20 #include "net/base/chunked_upload_data_stream.h" |
20 #include "net/base/mock_network_change_notifier.h" | 21 #include "net/base/mock_network_change_notifier.h" |
21 #include "net/base/test_completion_callback.h" | 22 #include "net/base/test_completion_callback.h" |
22 #include "net/base/test_proxy_delegate.h" | 23 #include "net/base/test_proxy_delegate.h" |
23 #include "net/cert/ct_policy_enforcer.h" | 24 #include "net/cert/ct_policy_enforcer.h" |
24 #include "net/cert/mock_cert_verifier.h" | 25 #include "net/cert/mock_cert_verifier.h" |
25 #include "net/cert/multi_log_ct_verifier.h" | 26 #include "net/cert/multi_log_ct_verifier.h" |
26 #include "net/dns/mock_host_resolver.h" | 27 #include "net/dns/mock_host_resolver.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 break; | 121 break; |
121 } | 122 } |
122 os << " }"; | 123 os << " }"; |
123 return os; | 124 return os; |
124 } | 125 } |
125 | 126 |
126 QuicVersion version; | 127 QuicVersion version; |
127 DestinationType destination_type; | 128 DestinationType destination_type; |
128 }; | 129 }; |
129 | 130 |
| 131 std::string GenerateQuicVersionsListForAltSvcHeader( |
| 132 const QuicVersionVector& versions) { |
| 133 std::string result = ""; |
| 134 for (const QuicVersion& version : versions) { |
| 135 if (!result.empty()) |
| 136 result.append(","); |
| 137 result.append(base::IntToString(version)); |
| 138 } |
| 139 return result; |
| 140 } |
| 141 |
130 std::vector<PoolingTestParams> GetPoolingTestParams() { | 142 std::vector<PoolingTestParams> GetPoolingTestParams() { |
131 std::vector<PoolingTestParams> params; | 143 std::vector<PoolingTestParams> params; |
132 QuicVersionVector all_supported_versions = AllSupportedVersions(); | 144 QuicVersionVector all_supported_versions = AllSupportedVersions(); |
133 for (const QuicVersion version : all_supported_versions) { | 145 for (const QuicVersion version : all_supported_versions) { |
134 params.push_back(PoolingTestParams{version, SAME_AS_FIRST}); | 146 params.push_back(PoolingTestParams{version, SAME_AS_FIRST}); |
135 params.push_back(PoolingTestParams{version, SAME_AS_SECOND}); | 147 params.push_back(PoolingTestParams{version, SAME_AS_SECOND}); |
136 params.push_back(PoolingTestParams{version, DIFFERENT}); | 148 params.push_back(PoolingTestParams{version, DIFFERENT}); |
137 } | 149 } |
138 return params; | 150 return params; |
139 } | 151 } |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 QuicStreamId stream_id, | 504 QuicStreamId stream_id, |
493 bool should_include_version, | 505 bool should_include_version, |
494 bool fin, | 506 bool fin, |
495 SpdyHeaderBlock headers, | 507 SpdyHeaderBlock headers, |
496 QuicStreamOffset* offset) { | 508 QuicStreamOffset* offset) { |
497 return server_maker_.MakeResponseHeadersPacketWithOffsetTracking( | 509 return server_maker_.MakeResponseHeadersPacketWithOffsetTracking( |
498 packet_number, stream_id, should_include_version, fin, | 510 packet_number, stream_id, should_include_version, fin, |
499 std::move(headers), offset); | 511 std::move(headers), offset); |
500 } | 512 } |
501 | 513 |
502 void CreateSession() { | 514 void CreateSession(const QuicVersionVector& supported_versions) { |
503 session_params_.enable_quic = true; | 515 session_params_.enable_quic = true; |
504 session_params_.quic_supported_versions = SupportedVersions(version_); | 516 session_params_.quic_supported_versions = supported_versions; |
505 | 517 |
506 session_context_.quic_clock = &clock_; | 518 session_context_.quic_clock = &clock_; |
507 session_context_.quic_random = &random_generator_; | 519 session_context_.quic_random = &random_generator_; |
508 session_context_.client_socket_factory = &socket_factory_; | 520 session_context_.client_socket_factory = &socket_factory_; |
509 session_context_.quic_crypto_client_stream_factory = | 521 session_context_.quic_crypto_client_stream_factory = |
510 &crypto_client_stream_factory_; | 522 &crypto_client_stream_factory_; |
511 session_context_.host_resolver = &host_resolver_; | 523 session_context_.host_resolver = &host_resolver_; |
512 session_context_.cert_verifier = &cert_verifier_; | 524 session_context_.cert_verifier = &cert_verifier_; |
513 session_context_.transport_security_state = &transport_security_state_; | 525 session_context_.transport_security_state = &transport_security_state_; |
514 session_context_.cert_transparency_verifier = | 526 session_context_.cert_transparency_verifier = |
515 cert_transparency_verifier_.get(); | 527 cert_transparency_verifier_.get(); |
516 session_context_.ct_policy_enforcer = &ct_policy_enforcer_; | 528 session_context_.ct_policy_enforcer = &ct_policy_enforcer_; |
517 session_context_.socket_performance_watcher_factory = | 529 session_context_.socket_performance_watcher_factory = |
518 &test_socket_performance_watcher_factory_; | 530 &test_socket_performance_watcher_factory_; |
519 session_context_.proxy_service = proxy_service_.get(); | 531 session_context_.proxy_service = proxy_service_.get(); |
520 session_context_.ssl_config_service = ssl_config_service_.get(); | 532 session_context_.ssl_config_service = ssl_config_service_.get(); |
521 session_context_.http_auth_handler_factory = auth_handler_factory_.get(); | 533 session_context_.http_auth_handler_factory = auth_handler_factory_.get(); |
522 session_context_.http_server_properties = &http_server_properties_; | 534 session_context_.http_server_properties = &http_server_properties_; |
523 session_context_.net_log = net_log_.bound().net_log(); | 535 session_context_.net_log = net_log_.bound().net_log(); |
524 | 536 |
525 session_.reset(new HttpNetworkSession(session_params_, session_context_)); | 537 session_.reset(new HttpNetworkSession(session_params_, session_context_)); |
526 session_->quic_stream_factory()->set_require_confirmation(false); | 538 session_->quic_stream_factory()->set_require_confirmation(false); |
527 } | 539 } |
528 | 540 |
| 541 void CreateSession() { return CreateSession(SupportedVersions(version_)); } |
| 542 |
529 void CheckWasQuicResponse(HttpNetworkTransaction* trans) { | 543 void CheckWasQuicResponse(HttpNetworkTransaction* trans) { |
530 const HttpResponseInfo* response = trans->GetResponseInfo(); | 544 const HttpResponseInfo* response = trans->GetResponseInfo(); |
531 ASSERT_TRUE(response != nullptr); | 545 ASSERT_TRUE(response != nullptr); |
532 ASSERT_TRUE(response->headers.get() != nullptr); | 546 ASSERT_TRUE(response->headers.get() != nullptr); |
533 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 547 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
534 EXPECT_TRUE(response->was_fetched_via_spdy); | 548 EXPECT_TRUE(response->was_fetched_via_spdy); |
535 EXPECT_TRUE(response->was_alpn_negotiated); | 549 EXPECT_TRUE(response->was_alpn_negotiated); |
536 EXPECT_EQ(QuicHttpStream::ConnectionInfoFromQuicVersion(version_), | 550 EXPECT_EQ(QuicHttpStream::ConnectionInfoFromQuicVersion(version_), |
537 response->connection_info); | 551 response->connection_info); |
538 } | 552 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 uint16_t port) { | 618 uint16_t port) { |
605 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port); | 619 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port); |
606 } | 620 } |
607 | 621 |
608 void AddQuicAlternateProtocolMapping( | 622 void AddQuicAlternateProtocolMapping( |
609 MockCryptoClientStream::HandshakeMode handshake_mode) { | 623 MockCryptoClientStream::HandshakeMode handshake_mode) { |
610 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); | 624 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); |
611 url::SchemeHostPort server(request_.url); | 625 url::SchemeHostPort server(request_.url); |
612 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 626 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
613 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 627 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
614 http_server_properties_.SetAlternativeService(server, alternative_service, | 628 http_server_properties_.SetAlternativeService( |
615 expiration); | 629 server, alternative_service, expiration, |
| 630 HttpNetworkSession::Params().quic_supported_versions); |
616 } | 631 } |
617 | 632 |
618 void AddQuicRemoteAlternativeServiceMapping( | 633 void AddQuicRemoteAlternativeServiceMapping( |
619 MockCryptoClientStream::HandshakeMode handshake_mode, | 634 MockCryptoClientStream::HandshakeMode handshake_mode, |
620 const HostPortPair& alternative) { | 635 const HostPortPair& alternative) { |
621 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); | 636 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); |
622 url::SchemeHostPort server(request_.url); | 637 url::SchemeHostPort server(request_.url); |
623 AlternativeService alternative_service(kProtoQUIC, alternative.host(), | 638 AlternativeService alternative_service(kProtoQUIC, alternative.host(), |
624 alternative.port()); | 639 alternative.port()); |
625 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 640 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
626 http_server_properties_.SetAlternativeService(server, alternative_service, | 641 http_server_properties_.SetAlternativeService( |
627 expiration); | 642 server, alternative_service, expiration, |
| 643 HttpNetworkSession::Params().quic_supported_versions); |
628 } | 644 } |
629 | 645 |
630 void ExpectBrokenAlternateProtocolMapping() { | 646 void ExpectBrokenAlternateProtocolMapping() { |
631 const url::SchemeHostPort server(request_.url); | 647 const url::SchemeHostPort server(request_.url); |
632 const AlternativeServiceInfoVector alternative_service_info_vector = | 648 const AlternativeServiceInfoVector alternative_service_info_vector = |
633 http_server_properties_.GetAlternativeServiceInfos(server); | 649 http_server_properties_.GetAlternativeServiceInfos(server); |
634 EXPECT_EQ(1u, alternative_service_info_vector.size()); | 650 EXPECT_EQ(1u, alternative_service_info_vector.size()); |
635 EXPECT_TRUE(http_server_properties_.IsAlternativeServiceBroken( | 651 EXPECT_TRUE(http_server_properties_.IsAlternativeServiceBroken( |
636 alternative_service_info_vector[0].alternative_service)); | 652 alternative_service_info_vector[0].alternative_service)); |
637 } | 653 } |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 // HttpNetworkTransaction should reset the request and retry without using | 1195 // HttpNetworkTransaction should reset the request and retry without using |
1180 // alternative services. | 1196 // alternative services. |
1181 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) { | 1197 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) { |
1182 // Set up alternative service to use QUIC. | 1198 // Set up alternative service to use QUIC. |
1183 // Note that |origins_to_force_quic_on| cannot be used in this test, because | 1199 // Note that |origins_to_force_quic_on| cannot be used in this test, because |
1184 // that overrides |enable_alternative_services|. | 1200 // that overrides |enable_alternative_services|. |
1185 url::SchemeHostPort server(request_.url); | 1201 url::SchemeHostPort server(request_.url); |
1186 AlternativeService alternative_service(kProtoQUIC, kDefaultServerHostName, | 1202 AlternativeService alternative_service(kProtoQUIC, kDefaultServerHostName, |
1187 443); | 1203 443); |
1188 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 1204 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
1189 http_server_properties_.SetAlternativeService(server, alternative_service, | 1205 http_server_properties_.SetAlternativeService( |
1190 expiration); | 1206 server, alternative_service, expiration, |
| 1207 HttpNetworkSession::Params().quic_supported_versions); |
1191 | 1208 |
1192 // First try: The alternative job uses QUIC and reports an HTTP 421 | 1209 // First try: The alternative job uses QUIC and reports an HTTP 421 |
1193 // Misdirected Request error. The main job uses TCP, but |http_data| below is | 1210 // Misdirected Request error. The main job uses TCP, but |http_data| below is |
1194 // paused at Connect(), so it will never exit the socket pool. This ensures | 1211 // paused at Connect(), so it will never exit the socket pool. This ensures |
1195 // that the alternate job always wins the race and keeps whether the | 1212 // that the alternate job always wins the race and keeps whether the |
1196 // |http_data| exits the socket pool before the main job is aborted | 1213 // |http_data| exits the socket pool before the main job is aborted |
1197 // deterministic. The first main job gets aborted without the socket pool ever | 1214 // deterministic. The first main job gets aborted without the socket pool ever |
1198 // dispensing the socket, making it available for the second try. | 1215 // dispensing the socket, making it available for the second try. |
1199 MockQuicData mock_quic_data; | 1216 MockQuicData mock_quic_data; |
1200 QuicStreamOffset request_header_offset = 0; | 1217 QuicStreamOffset request_header_offset = 0; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 EXPECT_EQ( | 1457 EXPECT_EQ( |
1441 2u, | 1458 2u, |
1442 http_server_properties->GetAlternativeServiceInfos(https_server).size()); | 1459 http_server_properties->GetAlternativeServiceInfos(https_server).size()); |
1443 | 1460 |
1444 // Send http request to the same origin but with diffrent scheme, should not | 1461 // Send http request to the same origin but with diffrent scheme, should not |
1445 // use QUIC. | 1462 // use QUIC. |
1446 request_.url = GURL("http://mail.example.org:443"); | 1463 request_.url = GURL("http://mail.example.org:443"); |
1447 SendRequestAndExpectHttpResponse("hello world"); | 1464 SendRequestAndExpectHttpResponse("hello world"); |
1448 } | 1465 } |
1449 | 1466 |
| 1467 TEST_P(QuicNetworkTransactionTest, |
| 1468 StoreMutuallySupportedVersionsWhenProcessAltSvc) { |
| 1469 std::string advertised_versions_list_str = |
| 1470 GenerateQuicVersionsListForAltSvcHeader(AllSupportedVersions()); |
| 1471 std::string altsvc_header = |
| 1472 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%s\"\r\n\r\n", |
| 1473 advertised_versions_list_str.c_str()); |
| 1474 MockRead http_reads[] = { |
| 1475 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()), |
| 1476 MockRead("hello world"), |
| 1477 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 1478 MockRead(ASYNC, OK)}; |
| 1479 |
| 1480 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
| 1481 0); |
| 1482 socket_factory_.AddSocketDataProvider(&http_data); |
| 1483 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
| 1484 |
| 1485 MockQuicData mock_quic_data; |
| 1486 QuicStreamOffset header_stream_offset = 0; |
| 1487 mock_quic_data.AddWrite( |
| 1488 ConstructInitialSettingsPacket(1, &header_stream_offset)); |
| 1489 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( |
| 1490 2, GetNthClientInitiatedStreamId(0), true, true, |
| 1491 GetRequestHeaders("GET", "https", "/"), &header_stream_offset)); |
| 1492 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1493 1, GetNthClientInitiatedStreamId(0), false, false, |
| 1494 GetResponseHeaders("200 OK"))); |
| 1495 mock_quic_data.AddRead(ConstructServerDataPacket( |
| 1496 2, GetNthClientInitiatedStreamId(0), false, true, 0, "hello!")); |
| 1497 mock_quic_data.AddWrite(ConstructClientAckPacket(3, 2, 1, 1)); |
| 1498 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1499 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1500 |
| 1501 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1502 |
| 1503 AddHangingNonAlternateProtocolSocketData(); |
| 1504 |
| 1505 // Generate a list of QUIC versions suppored by netstack. |
| 1506 QuicVersionVector current_supported_versions = SupportedVersions(version_); |
| 1507 if (version_ != QUIC_VERSION_40) { |
| 1508 current_supported_versions.push_back(QUIC_VERSION_40); |
| 1509 } else { |
| 1510 current_supported_versions.push_back(QUIC_VERSION_37); |
| 1511 } |
| 1512 |
| 1513 CreateSession(current_supported_versions); |
| 1514 |
| 1515 SendRequestAndExpectHttpResponse("hello world"); |
| 1516 SendRequestAndExpectQuicResponse("hello!"); |
| 1517 |
| 1518 // Check alternative service is set with only mutually supported versions. |
| 1519 const url::SchemeHostPort https_server(request_.url); |
| 1520 const AlternativeServiceInfoVector alt_svc_info_vector = |
| 1521 session_->http_server_properties()->GetAlternativeServiceInfos( |
| 1522 https_server); |
| 1523 EXPECT_EQ(1u, alt_svc_info_vector.size()); |
| 1524 EXPECT_EQ(kProtoQUIC, alt_svc_info_vector[0].alternative_service.protocol); |
| 1525 EXPECT_EQ(2u, alt_svc_info_vector[0].advertised_versions().size()); |
| 1526 // Advertised versions will be lised in a sorted order. |
| 1527 std::sort(current_supported_versions.begin(), |
| 1528 current_supported_versions.end()); |
| 1529 EXPECT_EQ(current_supported_versions[0], |
| 1530 alt_svc_info_vector[0].advertised_versions()[0]); |
| 1531 EXPECT_EQ(current_supported_versions[1], |
| 1532 alt_svc_info_vector[0].advertised_versions()[1]); |
| 1533 } |
| 1534 |
1450 TEST_P(QuicNetworkTransactionTest, UseAlternativeServiceAllSupportedVersion) { | 1535 TEST_P(QuicNetworkTransactionTest, UseAlternativeServiceAllSupportedVersion) { |
1451 std::string altsvc_header = | 1536 std::string altsvc_header = |
1452 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%u\"\r\n\r\n", version_); | 1537 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%u\"\r\n\r\n", version_); |
1453 MockRead http_reads[] = { | 1538 MockRead http_reads[] = { |
1454 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()), | 1539 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()), |
1455 MockRead("hello world"), | 1540 MockRead("hello world"), |
1456 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 1541 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
1457 MockRead(ASYNC, OK)}; | 1542 MockRead(ASYNC, OK)}; |
1458 | 1543 |
1459 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, | 1544 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 | 2861 |
2777 CreateSession(); | 2862 CreateSession(); |
2778 | 2863 |
2779 const char destination1[] = "first.example.com"; | 2864 const char destination1[] = "first.example.com"; |
2780 const char destination2[] = "second.example.com"; | 2865 const char destination2[] = "second.example.com"; |
2781 | 2866 |
2782 // Set up alternative service entry to destination1. | 2867 // Set up alternative service entry to destination1. |
2783 url::SchemeHostPort server(request_.url); | 2868 url::SchemeHostPort server(request_.url); |
2784 AlternativeService alternative_service(kProtoQUIC, destination1, 443); | 2869 AlternativeService alternative_service(kProtoQUIC, destination1, 443); |
2785 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 2870 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
2786 http_server_properties_.SetAlternativeService(server, alternative_service, | 2871 http_server_properties_.SetAlternativeService( |
2787 expiration); | 2872 server, alternative_service, expiration, |
| 2873 HttpNetworkSession::Params().quic_supported_versions); |
2788 // First request opens connection to |destination1| | 2874 // First request opens connection to |destination1| |
2789 // with QuicServerId.host() == kDefaultServerHostName. | 2875 // with QuicServerId.host() == kDefaultServerHostName. |
2790 SendRequestAndExpectQuicResponse("hello!"); | 2876 SendRequestAndExpectQuicResponse("hello!"); |
2791 | 2877 |
2792 // Set up alternative service entry to a different destination. | 2878 // Set up alternative service entry to a different destination. |
2793 alternative_service = AlternativeService(kProtoQUIC, destination2, 443); | 2879 alternative_service = AlternativeService(kProtoQUIC, destination2, 443); |
2794 http_server_properties_.SetAlternativeService(server, alternative_service, | 2880 http_server_properties_.SetAlternativeService( |
2795 expiration); | 2881 server, alternative_service, expiration, |
| 2882 HttpNetworkSession::Params().quic_supported_versions); |
2796 // Second request pools to existing connection with same QuicServerId, | 2883 // Second request pools to existing connection with same QuicServerId, |
2797 // even though alternative service destination is different. | 2884 // even though alternative service destination is different. |
2798 SendRequestAndExpectQuicResponse("hello!"); | 2885 SendRequestAndExpectQuicResponse("hello!"); |
2799 } | 2886 } |
2800 | 2887 |
2801 // Pool to existing session with matching destination and matching certificate | 2888 // Pool to existing session with matching destination and matching certificate |
2802 // even if origin is different, and even if the alternative service with | 2889 // even if origin is different, and even if the alternative service with |
2803 // matching destination is not the first one on the list. | 2890 // matching destination is not the first one on the list. |
2804 TEST_P(QuicNetworkTransactionTest, PoolByDestination) { | 2891 TEST_P(QuicNetworkTransactionTest, PoolByDestination) { |
2805 GURL origin1 = request_.url; | 2892 GURL origin1 = request_.url; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 | 2936 |
2850 CreateSession(); | 2937 CreateSession(); |
2851 | 2938 |
2852 const char destination1[] = "first.example.com"; | 2939 const char destination1[] = "first.example.com"; |
2853 const char destination2[] = "second.example.com"; | 2940 const char destination2[] = "second.example.com"; |
2854 | 2941 |
2855 // Set up alternative service for |origin1|. | 2942 // Set up alternative service for |origin1|. |
2856 AlternativeService alternative_service1(kProtoQUIC, destination1, 443); | 2943 AlternativeService alternative_service1(kProtoQUIC, destination1, 443); |
2857 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 2944 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
2858 http_server_properties_.SetAlternativeService( | 2945 http_server_properties_.SetAlternativeService( |
2859 url::SchemeHostPort(origin1), alternative_service1, expiration); | 2946 url::SchemeHostPort(origin1), alternative_service1, expiration, |
| 2947 HttpNetworkSession::Params().quic_supported_versions); |
2860 | 2948 |
2861 // Set up multiple alternative service entries for |origin2|, | 2949 // Set up multiple alternative service entries for |origin2|, |
2862 // the first one with a different destination as for |origin1|, | 2950 // the first one with a different destination as for |origin1|, |
2863 // the second one with the same. The second one should be used, | 2951 // the second one with the same. The second one should be used, |
2864 // because the request can be pooled to that one. | 2952 // because the request can be pooled to that one. |
2865 AlternativeService alternative_service2(kProtoQUIC, destination2, 443); | 2953 AlternativeService alternative_service2(kProtoQUIC, destination2, 443); |
2866 AlternativeServiceInfoVector alternative_services; | 2954 AlternativeServiceInfoVector alternative_services; |
2867 alternative_services.push_back( | 2955 alternative_services.push_back( |
2868 AlternativeServiceInfo(alternative_service2, expiration)); | 2956 AlternativeServiceInfo(alternative_service2, expiration)); |
2869 alternative_services.push_back( | 2957 alternative_services.push_back( |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4367 destination = HostPortPair(origin2_, 443); | 4455 destination = HostPortPair(origin2_, 443); |
4368 break; | 4456 break; |
4369 case DIFFERENT: | 4457 case DIFFERENT: |
4370 destination = HostPortPair(kDifferentHostname, 443); | 4458 destination = HostPortPair(kDifferentHostname, 443); |
4371 break; | 4459 break; |
4372 } | 4460 } |
4373 AlternativeService alternative_service(kProtoQUIC, destination); | 4461 AlternativeService alternative_service(kProtoQUIC, destination); |
4374 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 4462 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
4375 http_server_properties_.SetAlternativeService( | 4463 http_server_properties_.SetAlternativeService( |
4376 url::SchemeHostPort("https", origin, 443), alternative_service, | 4464 url::SchemeHostPort("https", origin, 443), alternative_service, |
4377 expiration); | 4465 expiration, HttpNetworkSession::Params().quic_supported_versions); |
4378 } | 4466 } |
4379 | 4467 |
4380 std::unique_ptr<QuicEncryptedPacket> ConstructClientRequestHeadersPacket( | 4468 std::unique_ptr<QuicEncryptedPacket> ConstructClientRequestHeadersPacket( |
4381 QuicPacketNumber packet_number, | 4469 QuicPacketNumber packet_number, |
4382 QuicStreamId stream_id, | 4470 QuicStreamId stream_id, |
4383 bool should_include_version, | 4471 bool should_include_version, |
4384 QuicStreamOffset* offset, | 4472 QuicStreamOffset* offset, |
4385 QuicTestPacketMaker* maker) { | 4473 QuicTestPacketMaker* maker) { |
4386 SpdyPriority priority = | 4474 SpdyPriority priority = |
4387 ConvertRequestPriorityToQuicPriority(DEFAULT_PRIORITY); | 4475 ConvertRequestPriorityToQuicPriority(DEFAULT_PRIORITY); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4802 | 4890 |
4803 request_.url = GURL("https://mail.example.org/pushed.jpg"); | 4891 request_.url = GURL("https://mail.example.org/pushed.jpg"); |
4804 ChunkedUploadDataStream upload_data(0); | 4892 ChunkedUploadDataStream upload_data(0); |
4805 upload_data.AppendData("1", 1, true); | 4893 upload_data.AppendData("1", 1, true); |
4806 request_.upload_data_stream = &upload_data; | 4894 request_.upload_data_stream = &upload_data; |
4807 SendRequestAndExpectQuicResponse("and hello!"); | 4895 SendRequestAndExpectQuicResponse("and hello!"); |
4808 } | 4896 } |
4809 | 4897 |
4810 } // namespace test | 4898 } // namespace test |
4811 } // namespace net | 4899 } // namespace net |
OLD | NEW |