Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 2017323002: Disable HTTP/2 Alternative Service for different host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not change port except for a small number of tests. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 return GetParam() == kTestCaseHTTP2PriorityDependencies; 320 return GetParam() == kTestCaseHTTP2PriorityDependencies;
321 } 321 }
322 322
323 const char* GetAlternateProtocolFromParam() { 323 const char* GetAlternateProtocolFromParam() {
324 return AlternateProtocolToString( 324 return AlternateProtocolToString(
325 AlternateProtocolFromNextProto(GetProtocol())); 325 AlternateProtocolFromNextProto(GetProtocol()));
326 } 326 }
327 327
328 std::string GetAlternativeServiceHttpHeader() { 328 std::string GetAlternativeServiceHttpHeader() {
329 return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() + 329 return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() +
330 "=\"www.example.com:443\"\r\n"; 330 "=\"www.example.org:443\"\r\n";
331 } 331 }
332 332
333 // Either |write_failure| specifies a write failure or |read_failure| 333 // Either |write_failure| specifies a write failure or |read_failure|
334 // specifies a read failure when using a reused socket. In either case, the 334 // specifies a read failure when using a reused socket. In either case, the
335 // failure should cause the network transaction to resend the request, and the 335 // failure should cause the network transaction to resend the request, and the
336 // other argument should be NULL. 336 // other argument should be NULL.
337 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure, 337 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure,
338 const MockRead* read_failure); 338 const MockRead* read_failure);
339 339
340 // Either |write_failure| specifies a write failure or |read_failure| 340 // Either |write_failure| specifies a write failure or |read_failure|
(...skipping 9357 matching lines...) Expand 10 before | Expand all | Expand 10 after
9698 9698
9699 std::string response_data; 9699 std::string response_data;
9700 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9700 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9701 EXPECT_EQ("hello world", response_data); 9701 EXPECT_EQ("hello world", response_data);
9702 9702
9703 alternative_service_vector = 9703 alternative_service_vector =
9704 http_server_properties.GetAlternativeServices(test_server); 9704 http_server_properties.GetAlternativeServices(test_server);
9705 ASSERT_EQ(1u, alternative_service_vector.size()); 9705 ASSERT_EQ(1u, alternative_service_vector.size());
9706 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), 9706 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
9707 alternative_service_vector[0].protocol); 9707 alternative_service_vector[0].protocol);
9708 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 9708 EXPECT_EQ("www.example.org", alternative_service_vector[0].host);
9709 EXPECT_EQ(443, alternative_service_vector[0].port); 9709 EXPECT_EQ(443, alternative_service_vector[0].port);
9710 } 9710 }
9711 9711
9712 // HTTP/2 Alternative Services should be disabled if alternative service
9713 // hostname is different from that of origin.
9714 // TODO(bnc): Remove when https://crbug.com/615413 is fixed.
9715 TEST_P(HttpNetworkTransactionTest,
9716 DisableHTTP2AlternativeServicesWithDifferentHost) {
9717 session_deps_.enable_alternative_service_with_different_host = true;
9718
9719 HttpRequestInfo request;
9720 request.method = "GET";
9721 request.url = GURL("http://www.example.org/");
9722 request.load_flags = 0;
9723
9724 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9725 StaticSocketDataProvider first_data;
9726 first_data.set_connect_data(mock_connect);
9727 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
9728
9729 MockRead data_reads[] = {
9730 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello world"),
9731 MockRead(ASYNC, OK),
9732 };
9733 StaticSocketDataProvider second_data(data_reads, arraysize(data_reads), NULL,
9734 0);
9735 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
9736
9737 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9738
9739 base::WeakPtr<HttpServerProperties> http_server_properties =
9740 session->http_server_properties();
9741 AlternativeService alternative_service(
9742 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org",
9743 444);
9744 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9745 http_server_properties->SetAlternativeService(
9746 url::SchemeHostPort(request.url), alternative_service, expiration);
9747
9748 std::unique_ptr<HttpTransaction> trans(
9749 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9750 TestCompletionCallback callback;
9751
9752 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9753 // Alternative service is not used, request fails.
9754 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv));
9755 }
9756
9712 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { 9757 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) {
9713 session_deps_.enable_alternative_service_with_different_host = false; 9758 session_deps_.enable_alternative_service_with_different_host = false;
9714 9759
9715 // Set an alternative service for origin. 9760 // Set an alternative service for origin.
9716 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9761 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9717 HttpServerProperties& http_server_properties = 9762 HttpServerProperties& http_server_properties =
9718 *session->http_server_properties(); 9763 *session->http_server_properties();
9719 url::SchemeHostPort test_server("http", "www.example.org", 80); 9764 url::SchemeHostPort test_server("http", "www.example.org", 80);
9720 AlternativeService alternative_service(QUIC, "", 80); 9765 AlternativeService alternative_service(QUIC, "", 80);
9721 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9766 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
10593 EXPECT_TRUE(response->was_npn_negotiated); 10638 EXPECT_TRUE(response->was_npn_negotiated);
10594 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); 10639 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data));
10595 EXPECT_EQ("hello!", response_data); 10640 EXPECT_EQ("hello!", response_data);
10596 } 10641 }
10597 10642
10598 TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { 10643 TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) {
10599 session_deps_.enable_alternative_service_with_different_host = true; 10644 session_deps_.enable_alternative_service_with_different_host = true;
10600 10645
10601 HttpRequestInfo request; 10646 HttpRequestInfo request;
10602 request.method = "GET"; 10647 request.method = "GET";
10603 request.url = GURL("http://www.example.com/"); 10648 request.url = GURL("http://www.example.org/");
10604 request.load_flags = 0; 10649 request.load_flags = 0;
10605 10650
10606 std::string alternative_service_http_header = 10651 std::string alternative_service_http_header =
10607 GetAlternativeServiceHttpHeader(); 10652 GetAlternativeServiceHttpHeader();
10608 10653
10609 MockRead data_reads[] = { 10654 MockRead data_reads[] = {
10610 MockRead("HTTP/1.1 200 OK\r\n"), 10655 MockRead("HTTP/1.1 200 OK\r\n"),
10611 MockRead(alternative_service_http_header.c_str()), 10656 MockRead(alternative_service_http_header.c_str()),
10612 MockRead("\r\n"), 10657 MockRead("\r\n"),
10613 MockRead("hello world"), 10658 MockRead("hello world"),
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
10762 SSLSocketDataProvider ssl(ASYNC, OK); 10807 SSLSocketDataProvider ssl(ASYNC, OK);
10763 ssl.SetNextProto(GetProtocol()); 10808 ssl.SetNextProto(GetProtocol());
10764 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); 10809 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem");
10765 ASSERT_TRUE(ssl.cert); 10810 ASSERT_TRUE(ssl.cert);
10766 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 10811 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
10767 10812
10768 std::unique_ptr<SpdySerializedFrame> req( 10813 std::unique_ptr<SpdySerializedFrame> req(
10769 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); 10814 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
10770 MockWrite spdy_writes[] = { 10815 MockWrite spdy_writes[] = {
10771 MockWrite(ASYNC, 0, 10816 MockWrite(ASYNC, 0,
10772 "CONNECT www.example.com:443 HTTP/1.1\r\n" 10817 "CONNECT www.example.org:443 HTTP/1.1\r\n"
10773 "Host: www.example.com:443\r\n" 10818 "Host: www.example.org:443\r\n"
10774 "Proxy-Connection: keep-alive\r\n\r\n"), 10819 "Proxy-Connection: keep-alive\r\n\r\n"),
10775 CreateMockWrite(*req, 2), 10820 CreateMockWrite(*req, 2),
10776 }; 10821 };
10777 10822
10778 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; 10823 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n";
10779 10824
10780 std::unique_ptr<SpdySerializedFrame> resp( 10825 std::unique_ptr<SpdySerializedFrame> resp(
10781 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 10826 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
10782 std::unique_ptr<SpdySerializedFrame> data( 10827 std::unique_ptr<SpdySerializedFrame> data(
10783 spdy_util_.ConstructSpdyBodyFrame(1, true)); 10828 spdy_util_.ConstructSpdyBodyFrame(1, true));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
10906 const HttpResponseInfo* response = trans->GetResponseInfo(); 10951 const HttpResponseInfo* response = trans->GetResponseInfo();
10907 ASSERT_TRUE(response); 10952 ASSERT_TRUE(response);
10908 ASSERT_TRUE(response->headers); 10953 ASSERT_TRUE(response->headers);
10909 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10954 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10910 10955
10911 std::string response_data; 10956 std::string response_data;
10912 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10957 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10913 EXPECT_EQ("hello world", response_data); 10958 EXPECT_EQ("hello world", response_data);
10914 10959
10915 // Set up an initial SpdySession in the pool to reuse. 10960 // Set up an initial SpdySession in the pool to reuse.
10916 HostPortPair host_port_pair("www.example.com", 443); 10961 HostPortPair host_port_pair("www.example.org", 443);
10917 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), 10962 SpdySessionKey key(host_port_pair, ProxyServer::Direct(),
10918 PRIVACY_MODE_DISABLED); 10963 PRIVACY_MODE_DISABLED);
10919 base::WeakPtr<SpdySession> spdy_session = 10964 base::WeakPtr<SpdySession> spdy_session =
10920 CreateSecureSpdySession(session.get(), key, BoundNetLog()); 10965 CreateSecureSpdySession(session.get(), key, BoundNetLog());
10921 10966
10922 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10967 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10923 10968
10924 rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10969 rv = trans->Start(&request, callback.callback(), BoundNetLog());
10925 EXPECT_EQ(ERR_IO_PENDING, rv); 10970 EXPECT_EQ(ERR_IO_PENDING, rv);
10926 EXPECT_EQ(OK, callback.WaitForResult()); 10971 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after
13152 TEST_P(AltSvcCertificateVerificationTest, PoolingInvalid) { 13197 TEST_P(AltSvcCertificateVerificationTest, PoolingInvalid) {
13153 Run(true, false); 13198 Run(true, false);
13154 } 13199 }
13155 13200
13156 // The alternative service host must exhibit a certificate that is valid for the 13201 // The alternative service host must exhibit a certificate that is valid for the
13157 // origin host. Test that this is enforced when opening a new connection. 13202 // origin host. Test that this is enforced when opening a new connection.
13158 TEST_P(AltSvcCertificateVerificationTest, NewConnectionValid) { 13203 TEST_P(AltSvcCertificateVerificationTest, NewConnectionValid) {
13159 Run(false, true); 13204 Run(false, true);
13160 } 13205 }
13161 13206
13162 TEST_P(AltSvcCertificateVerificationTest, NewConnectionInvalid) { 13207 // TODO(bnc): Re-enable when https://crbug.com/615413 is fixed.
13208 TEST_P(AltSvcCertificateVerificationTest, DISABLED_NewConnectionInvalid) {
13163 Run(false, false); 13209 Run(false, false);
13164 } 13210 }
13165 13211
13166 // Alternative service requires HTTP/2 (or SPDY), but HTTP/1.1 is negotiated 13212 // Alternative service requires HTTP/2 (or SPDY), but HTTP/1.1 is negotiated
13167 // with the alternative server. That connection should not be used. 13213 // with the alternative server. That connection should not be used.
13168 TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) { 13214 TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) {
13169 url::SchemeHostPort server("https", "origin.example.org", 443); 13215 url::SchemeHostPort server("https", "www.example.org", 443);
13170 HostPortPair alternative("alternative.example.org", 443); 13216 HostPortPair alternative("www.example.org", 444);
13171 13217
13172 // Negotiate HTTP/1.1 with alternative.example.org. 13218 // Negotiate HTTP/1.1 with alternative.
13173 SSLSocketDataProvider ssl(ASYNC, OK); 13219 SSLSocketDataProvider ssl(ASYNC, OK);
13174 ssl.SetNextProto(kProtoHTTP11); 13220 ssl.SetNextProto(kProtoHTTP11);
13175 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 13221 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
13176 13222
13177 // No data should be read from the alternative, because HTTP/1.1 is 13223 // No data should be read from the alternative, because HTTP/1.1 is
13178 // negotiated. 13224 // negotiated.
13179 StaticSocketDataProvider data; 13225 StaticSocketDataProvider data;
13180 session_deps_.socket_factory->AddSocketDataProvider(&data); 13226 session_deps_.socket_factory->AddSocketDataProvider(&data);
13181 13227
13182 // This test documents that an alternate Job should not be used if HTTP/1.1 is 13228 // This test documents that an alternate Job should not be used if HTTP/1.1 is
(...skipping 11 matching lines...) Expand all
13194 AlternativeService alternative_service( 13240 AlternativeService alternative_service(
13195 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13241 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13196 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13242 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13197 http_server_properties->SetAlternativeService(server, alternative_service, 13243 http_server_properties->SetAlternativeService(server, alternative_service,
13198 expiration); 13244 expiration);
13199 13245
13200 std::unique_ptr<HttpTransaction> trans( 13246 std::unique_ptr<HttpTransaction> trans(
13201 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13247 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13202 HttpRequestInfo request; 13248 HttpRequestInfo request;
13203 request.method = "GET"; 13249 request.method = "GET";
13204 request.url = GURL("https://origin.example.org:443"); 13250 request.url = GURL("https://www.example.org:443");
13205 request.load_flags = 0; 13251 request.load_flags = 0;
13206 TestCompletionCallback callback; 13252 TestCompletionCallback callback;
13207 13253
13208 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is 13254 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is
13209 // negotiated, the alternate Job should fail with ERR_NPN_NEGOTIATION_FAILED. 13255 // negotiated, the alternate Job should fail with ERR_NPN_NEGOTIATION_FAILED.
13210 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 13256 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
13211 EXPECT_EQ(ERR_NPN_NEGOTIATION_FAILED, callback.GetResult(rv)); 13257 EXPECT_EQ(ERR_NPN_NEGOTIATION_FAILED, callback.GetResult(rv));
13212 } 13258 }
13213 13259
13214 // A request to a server with an alternative service fires two Jobs: one to the 13260 // A request to a server with an alternative service fires two Jobs: one to the
13215 // server, and an alternate one to the alternative server. If the former 13261 // server, and an alternate one to the alternative server. If the former
13216 // succeeds, the request should succeed, even if the latter fails because 13262 // succeeds, the request should succeed, even if the latter fails because
13217 // HTTP/1.1 is negotiated which is insufficient for alternative service. 13263 // HTTP/1.1 is negotiated which is insufficient for alternative service.
13218 TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) { 13264 TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) {
13219 url::SchemeHostPort server("https", "origin.example.org", 443); 13265 url::SchemeHostPort server("https", "www.example.org", 443);
13220 HostPortPair alternative("alternative.example.org", 443); 13266 HostPortPair alternative("www.example.org", 444);
13221 13267
13222 // Negotiate HTTP/1.1 with alternative. 13268 // Negotiate HTTP/1.1 with alternative.
13223 SSLSocketDataProvider alternative_ssl(ASYNC, OK); 13269 SSLSocketDataProvider alternative_ssl(ASYNC, OK);
13224 alternative_ssl.SetNextProto(kProtoHTTP11); 13270 alternative_ssl.SetNextProto(kProtoHTTP11);
13225 session_deps_.socket_factory->AddSSLSocketDataProvider(&alternative_ssl); 13271 session_deps_.socket_factory->AddSSLSocketDataProvider(&alternative_ssl);
13226 13272
13227 // No data should be read from the alternative, because HTTP/1.1 is 13273 // No data should be read from the alternative, because HTTP/1.1 is
13228 // negotiated. 13274 // negotiated.
13229 StaticSocketDataProvider data; 13275 StaticSocketDataProvider data;
13230 session_deps_.socket_factory->AddSocketDataProvider(&data); 13276 session_deps_.socket_factory->AddSocketDataProvider(&data);
13231 13277
13232 // Negotiate HTTP/1.1 with server. 13278 // Negotiate HTTP/1.1 with server.
13233 SSLSocketDataProvider origin_ssl(ASYNC, OK); 13279 SSLSocketDataProvider origin_ssl(ASYNC, OK);
13234 origin_ssl.SetNextProto(kProtoHTTP11); 13280 origin_ssl.SetNextProto(kProtoHTTP11);
13235 session_deps_.socket_factory->AddSSLSocketDataProvider(&origin_ssl); 13281 session_deps_.socket_factory->AddSSLSocketDataProvider(&origin_ssl);
13236 13282
13237 MockWrite http_writes[] = { 13283 MockWrite http_writes[] = {
13238 MockWrite( 13284 MockWrite("GET / HTTP/1.1\r\n"
13239 "GET / HTTP/1.1\r\n" 13285 "Host: www.example.org\r\n"
13240 "Host: origin.example.org\r\n" 13286 "Connection: keep-alive\r\n\r\n"),
13241 "Connection: keep-alive\r\n\r\n"), 13287 MockWrite("GET /second HTTP/1.1\r\n"
13242 MockWrite( 13288 "Host: www.example.org\r\n"
13243 "GET /second HTTP/1.1\r\n" 13289 "Connection: keep-alive\r\n\r\n"),
13244 "Host: origin.example.org\r\n"
13245 "Connection: keep-alive\r\n\r\n"),
13246 }; 13290 };
13247 13291
13248 MockRead http_reads[] = { 13292 MockRead http_reads[] = {
13249 MockRead("HTTP/1.1 200 OK\r\n"), 13293 MockRead("HTTP/1.1 200 OK\r\n"),
13250 MockRead("Content-Type: text/html\r\n"), 13294 MockRead("Content-Type: text/html\r\n"),
13251 MockRead("Content-Length: 6\r\n\r\n"), 13295 MockRead("Content-Length: 6\r\n\r\n"),
13252 MockRead("foobar"), 13296 MockRead("foobar"),
13253 MockRead("HTTP/1.1 200 OK\r\n"), 13297 MockRead("HTTP/1.1 200 OK\r\n"),
13254 MockRead("Content-Type: text/html\r\n"), 13298 MockRead("Content-Type: text/html\r\n"),
13255 MockRead("Content-Length: 7\r\n\r\n"), 13299 MockRead("Content-Length: 7\r\n\r\n"),
(...skipping 10 matching lines...) Expand all
13266 session->http_server_properties(); 13310 session->http_server_properties();
13267 AlternativeService alternative_service( 13311 AlternativeService alternative_service(
13268 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13312 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13269 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13313 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13270 http_server_properties->SetAlternativeService(server, alternative_service, 13314 http_server_properties->SetAlternativeService(server, alternative_service,
13271 expiration); 13315 expiration);
13272 13316
13273 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 13317 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
13274 HttpRequestInfo request1; 13318 HttpRequestInfo request1;
13275 request1.method = "GET"; 13319 request1.method = "GET";
13276 request1.url = GURL("https://origin.example.org:443"); 13320 request1.url = GURL("https://www.example.org:443");
13277 request1.load_flags = 0; 13321 request1.load_flags = 0;
13278 TestCompletionCallback callback1; 13322 TestCompletionCallback callback1;
13279 13323
13280 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); 13324 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog());
13281 rv = callback1.GetResult(rv); 13325 rv = callback1.GetResult(rv);
13282 EXPECT_EQ(OK, rv); 13326 EXPECT_EQ(OK, rv);
13283 13327
13284 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); 13328 const HttpResponseInfo* response1 = trans1.GetResponseInfo();
13285 ASSERT_TRUE(response1); 13329 ASSERT_TRUE(response1);
13286 ASSERT_TRUE(response1->headers); 13330 ASSERT_TRUE(response1->headers);
13287 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); 13331 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine());
13288 13332
13289 std::string response_data1; 13333 std::string response_data1;
13290 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data1)); 13334 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data1));
13291 EXPECT_EQ("foobar", response_data1); 13335 EXPECT_EQ("foobar", response_data1);
13292 13336
13293 // Alternative should be marked as broken, because HTTP/1.1 is not sufficient 13337 // Alternative should be marked as broken, because HTTP/1.1 is not sufficient
13294 // for alternative service. 13338 // for alternative service.
13295 EXPECT_TRUE( 13339 EXPECT_TRUE(
13296 http_server_properties->IsAlternativeServiceBroken(alternative_service)); 13340 http_server_properties->IsAlternativeServiceBroken(alternative_service));
13297 13341
13298 // Since |alternative_service| is broken, a second transaction to server 13342 // Since |alternative_service| is broken, a second transaction to server
13299 // should not start an alternate Job. It should pool to existing connection 13343 // should not start an alternate Job. It should pool to existing connection
13300 // to server. 13344 // to server.
13301 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); 13345 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get());
13302 HttpRequestInfo request2; 13346 HttpRequestInfo request2;
13303 request2.method = "GET"; 13347 request2.method = "GET";
13304 request2.url = GURL("https://origin.example.org:443/second"); 13348 request2.url = GURL("https://www.example.org:443/second");
13305 request2.load_flags = 0; 13349 request2.load_flags = 0;
13306 TestCompletionCallback callback2; 13350 TestCompletionCallback callback2;
13307 13351
13308 rv = trans2.Start(&request2, callback2.callback(), BoundNetLog()); 13352 rv = trans2.Start(&request2, callback2.callback(), BoundNetLog());
13309 rv = callback2.GetResult(rv); 13353 rv = callback2.GetResult(rv);
13310 EXPECT_EQ(OK, rv); 13354 EXPECT_EQ(OK, rv);
13311 13355
13312 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); 13356 const HttpResponseInfo* response2 = trans2.GetResponseInfo();
13313 ASSERT_TRUE(response2); 13357 ASSERT_TRUE(response2);
13314 ASSERT_TRUE(response2->headers); 13358 ASSERT_TRUE(response2->headers);
(...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after
15689 base::MessageLoop::current()->RunUntilIdle(); 15733 base::MessageLoop::current()->RunUntilIdle();
15690 15734
15691 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); 15735 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
15692 HttpRequestHeaders headers; 15736 HttpRequestHeaders headers;
15693 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); 15737 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
15694 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); 15738 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
15695 } 15739 }
15696 #endif // !defined(OS_IOS) 15740 #endif // !defined(OS_IOS)
15697 15741
15698 } // namespace net 15742 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698