| Index: net/quic/quic_network_transaction_unittest.cc
|
| diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc
|
| index 0a5ab02d4d141b75efb0b7cc6b0a8f44ced537bb..33821955398f698f3d04e3f1dd80729cbbb5ac43 100644
|
| --- a/net/quic/quic_network_transaction_unittest.cc
|
| +++ b/net/quic/quic_network_transaction_unittest.cc
|
| @@ -533,10 +533,11 @@ class QuicNetworkTransactionTest
|
| MockCryptoClientStream::HandshakeMode handshake_mode) {
|
| crypto_client_stream_factory_.set_handshake_mode(handshake_mode);
|
| HostPortPair host_port_pair = HostPortPair::FromURL(request_.url);
|
| + url::SchemeHostPort scheme_origin_pair(request_.url);
|
| AlternativeService alternative_service(QUIC, host_port_pair.host(), 443);
|
| base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
|
| http_server_properties_.SetAlternativeService(
|
| - host_port_pair, alternative_service, expiration);
|
| + scheme_origin_pair, alternative_service, expiration);
|
| }
|
|
|
| void AddQuicRemoteAlternativeServiceMapping(
|
| @@ -544,26 +545,27 @@ class QuicNetworkTransactionTest
|
| const HostPortPair& alternative) {
|
| crypto_client_stream_factory_.set_handshake_mode(handshake_mode);
|
| HostPortPair host_port_pair = HostPortPair::FromURL(request_.url);
|
| + url::SchemeHostPort scheme_origin_pair(request_.url);
|
| AlternativeService alternative_service(QUIC, alternative.host(),
|
| alternative.port());
|
| base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
|
| http_server_properties_.SetAlternativeService(
|
| - host_port_pair, alternative_service, expiration);
|
| + scheme_origin_pair, alternative_service, expiration);
|
| }
|
|
|
| void ExpectBrokenAlternateProtocolMapping() {
|
| - const HostPortPair origin = HostPortPair::FromURL(request_.url);
|
| + url::SchemeHostPort scheme_origin(request_.url);
|
| const AlternativeServiceVector alternative_service_vector =
|
| - http_server_properties_.GetAlternativeServices(origin);
|
| + http_server_properties_.GetAlternativeServices(scheme_origin);
|
| EXPECT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_TRUE(http_server_properties_.IsAlternativeServiceBroken(
|
| alternative_service_vector[0]));
|
| }
|
|
|
| void ExpectQuicAlternateProtocolMapping() {
|
| - const HostPortPair origin = HostPortPair::FromURL(request_.url);
|
| + url::SchemeHostPort scheme_origin(request_.url);
|
| const AlternativeServiceVector alternative_service_vector =
|
| - http_server_properties_.GetAlternativeServices(origin);
|
| + http_server_properties_.GetAlternativeServices(scheme_origin);
|
| EXPECT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
|
| }
|
| @@ -934,6 +936,70 @@ TEST_P(QuicNetworkTransactionTest,
|
| SendRequestAndExpectQuicResponse("hello!");
|
| }
|
|
|
| +TEST_P(QuicNetworkTransactionTest, SetAlternativeServiceForOriginWithScheme) {
|
| + MockRead http_reads[] = {
|
| + MockRead("HTTP/1.1 200 OK\r\n"),
|
| + MockRead("Alt-Svc: quic=\"foo.example.org:443\", quic=\":444\"\r\n\r\n"),
|
| + MockRead("hello world"),
|
| + MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
|
| + MockRead(ASYNC, OK)};
|
| +
|
| + StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr,
|
| + 0);
|
| + socket_factory_.AddSocketDataProvider(&http_data);
|
| + socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
|
| +
|
| + CreateSession();
|
| + // Send http request, ignore alternative service advertising if response
|
| + // header advertises alternative service for mail.example.org.
|
| + request_.url = GURL("http://mail.example.org:443");
|
| + SendRequestAndExpectHttpResponse("hello world");
|
| + base::WeakPtr<HttpServerProperties> http_server_properties =
|
| + session_->http_server_properties();
|
| + url::SchemeHostPort http_origin("http", "mail.example.org", 443);
|
| + url::SchemeHostPort https_origin("https", "mail.example.org", 443);
|
| + // Check alternative service is set for the correct origin.
|
| + EXPECT_EQ(2u,
|
| + http_server_properties->GetAlternativeServices(http_origin).size());
|
| + EXPECT_EQ(
|
| + 0u, http_server_properties->GetAlternativeServices(https_origin).size());
|
| +}
|
| +
|
| +TEST_P(QuicNetworkTransactionTest, DoNotGetAltSvcForDifferentOrigin) {
|
| + MockRead http_reads[] = {
|
| + MockRead("HTTP/1.1 200 OK\r\n"),
|
| + MockRead("Alt-Svc: quic=\"foo.example.org:443\", quic=\":444\"\r\n\r\n"),
|
| + MockRead("hello world"),
|
| + MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
|
| + MockRead(ASYNC, OK)};
|
| +
|
| + StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr,
|
| + 0);
|
| + socket_factory_.AddSocketDataProvider(&http_data);
|
| + socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
|
| + socket_factory_.AddSocketDataProvider(&http_data);
|
| + socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
|
| +
|
| + CreateSession();
|
| +
|
| + // Send https request and set alternative services if response header
|
| + // advertises alternative service for mail.example.org.
|
| + SendRequestAndExpectHttpResponse("hello world");
|
| + base::WeakPtr<HttpServerProperties> http_server_properties =
|
| + session_->http_server_properties();
|
| +
|
| + const url::SchemeHostPort https_origin(request_.url);
|
| + // Check alternative service is set.
|
| + AlternativeServiceVector alternative_service_vector =
|
| + http_server_properties->GetAlternativeServices(https_origin);
|
| + EXPECT_EQ(2u, alternative_service_vector.size());
|
| +
|
| + // Send http request to the same origin but with diffrent scheme, should not
|
| + // use QUIC.
|
| + request_.url = GURL("http://mail.example.org:443");
|
| + SendRequestAndExpectHttpResponse("hello world");
|
| +}
|
| +
|
| TEST_P(QuicNetworkTransactionTest, UseAlternativeServiceQuicSupportedVersion) {
|
| std::string altsvc_header = base::StringPrintf(
|
| "Alt-Svc: quic=\":443\"; v=\"%u\"\r\n\r\n", GetParam());
|
| @@ -1749,7 +1815,8 @@ class QuicAltSvcCertificateVerificationTest
|
| AlternativeService alternative_service(QUIC, alternative);
|
| base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
|
| session_->http_server_properties()->SetAlternativeService(
|
| - origin, alternative_service, expiration);
|
| + url::SchemeHostPort("https", origin.host(), origin.port()),
|
| + alternative_service, expiration);
|
| scoped_ptr<HttpNetworkTransaction> trans(
|
| new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get()));
|
| TestCompletionCallback callback;
|
|
|