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

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

Issue 1720163002: When Alt-Svc header processing is enabled, do not process Alternate-Protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « net/http/http_network_transaction.cc ('k') | net/quic/quic_network_transaction_unittest.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 #include <limits> 10 #include <limits>
(...skipping 9953 matching lines...) Expand 10 before | Expand all | Expand 10 after
9964 9964
9965 alternative_service_vector = 9965 alternative_service_vector =
9966 http_server_properties.GetAlternativeServices(http_host_port_pair); 9966 http_server_properties.GetAlternativeServices(http_host_port_pair);
9967 ASSERT_EQ(1u, alternative_service_vector.size()); 9967 ASSERT_EQ(1u, alternative_service_vector.size());
9968 EXPECT_EQ(443, alternative_service_vector[0].port); 9968 EXPECT_EQ(443, alternative_service_vector[0].port);
9969 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), 9969 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
9970 alternative_service_vector[0].protocol); 9970 alternative_service_vector[0].protocol);
9971 } 9971 }
9972 9972
9973 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) { 9973 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) {
9974 session_deps_.parse_alternative_services = true; 9974 session_deps_.parse_alternative_services = false;
9975 session_deps_.enable_alternative_service_with_different_host = false; 9975 session_deps_.enable_alternative_service_with_different_host = false;
9976 9976
9977 MockRead data_reads[] = { 9977 MockRead data_reads[] = {
9978 MockRead("HTTP/1.1 200 OK\r\n"), 9978 MockRead("HTTP/1.1 200 OK\r\n"),
9979 MockRead("Alternate-Protocol: \r\n\r\n"), 9979 MockRead("Alternate-Protocol: \r\n\r\n"),
9980 MockRead("hello world"), 9980 MockRead("hello world"),
9981 MockRead(SYNCHRONOUS, OK), 9981 MockRead(SYNCHRONOUS, OK),
9982 }; 9982 };
9983 9983
9984 HttpRequestInfo request; 9984 HttpRequestInfo request;
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
10653 ASSERT_TRUE(response != NULL); 10653 ASSERT_TRUE(response != NULL);
10654 ASSERT_TRUE(response->headers.get() != NULL); 10654 ASSERT_TRUE(response->headers.get() != NULL);
10655 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10655 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10656 10656
10657 std::string response_data; 10657 std::string response_data;
10658 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10658 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10659 EXPECT_EQ("hello world", response_data); 10659 EXPECT_EQ("hello world", response_data);
10660 } 10660 }
10661 10661
10662 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { 10662 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) {
10663 session_deps_.parse_alternative_services = true; 10663 session_deps_.parse_alternative_services = false;
10664 session_deps_.enable_alternative_service_with_different_host = false; 10664 session_deps_.enable_alternative_service_with_different_host = false;
10665 10665
10666 HttpRequestInfo request; 10666 HttpRequestInfo request;
10667 request.method = "GET"; 10667 request.method = "GET";
10668 request.url = GURL("http://www.example.org/"); 10668 request.url = GURL("http://www.example.org/");
10669 request.load_flags = 0; 10669 request.load_flags = 0;
10670 10670
10671 std::string alternate_protocol_http_header = 10671 std::string alternate_protocol_http_header =
10672 GetAlternateProtocolHttpHeader(); 10672 GetAlternateProtocolHttpHeader();
10673 10673
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
10741 ASSERT_TRUE(response->headers.get() != NULL); 10741 ASSERT_TRUE(response->headers.get() != NULL);
10742 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); 10742 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
10743 EXPECT_TRUE(response->was_fetched_via_spdy); 10743 EXPECT_TRUE(response->was_fetched_via_spdy);
10744 EXPECT_TRUE(response->was_npn_negotiated); 10744 EXPECT_TRUE(response->was_npn_negotiated);
10745 10745
10746 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10746 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10747 EXPECT_EQ("hello!", response_data); 10747 EXPECT_EQ("hello!", response_data);
10748 } 10748 }
10749 10749
10750 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { 10750 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) {
10751 session_deps_.parse_alternative_services = true; 10751 session_deps_.parse_alternative_services = false;
10752 session_deps_.enable_alternative_service_with_different_host = false; 10752 session_deps_.enable_alternative_service_with_different_host = false;
10753 10753
10754 HttpRequestInfo request; 10754 HttpRequestInfo request;
10755 request.method = "GET"; 10755 request.method = "GET";
10756 request.url = GURL("http://www.example.org/"); 10756 request.url = GURL("http://www.example.org/");
10757 request.load_flags = 0; 10757 request.load_flags = 0;
10758 10758
10759 std::string alternate_protocol_http_header = 10759 std::string alternate_protocol_http_header =
10760 GetAlternateProtocolHttpHeader(); 10760 GetAlternateProtocolHttpHeader();
10761 10761
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
10862 ASSERT_TRUE(response != NULL); 10862 ASSERT_TRUE(response != NULL);
10863 ASSERT_TRUE(response->headers.get() != NULL); 10863 ASSERT_TRUE(response->headers.get() != NULL);
10864 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); 10864 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
10865 EXPECT_TRUE(response->was_fetched_via_spdy); 10865 EXPECT_TRUE(response->was_fetched_via_spdy);
10866 EXPECT_TRUE(response->was_npn_negotiated); 10866 EXPECT_TRUE(response->was_npn_negotiated);
10867 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); 10867 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data));
10868 EXPECT_EQ("hello!", response_data); 10868 EXPECT_EQ("hello!", response_data);
10869 } 10869 }
10870 10870
10871 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { 10871 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) {
10872 session_deps_.parse_alternative_services = true; 10872 session_deps_.parse_alternative_services = false;
10873 session_deps_.enable_alternative_service_with_different_host = false; 10873 session_deps_.enable_alternative_service_with_different_host = false;
10874 10874
10875 HttpRequestInfo request; 10875 HttpRequestInfo request;
10876 request.method = "GET"; 10876 request.method = "GET";
10877 request.url = GURL("http://www.example.org/"); 10877 request.url = GURL("http://www.example.org/");
10878 request.load_flags = 0; 10878 request.load_flags = 0;
10879 10879
10880 std::string alternate_protocol_http_header = 10880 std::string alternate_protocol_http_header =
10881 GetAlternateProtocolHttpHeader(); 10881 GetAlternateProtocolHttpHeader();
10882 10882
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
10991 resolver->reset(new ForwardingProxyResolver(resolver_)); 10991 resolver->reset(new ForwardingProxyResolver(resolver_));
10992 return OK; 10992 return OK;
10993 } 10993 }
10994 10994
10995 private: 10995 private:
10996 ProxyResolver* resolver_; 10996 ProxyResolver* resolver_;
10997 }; 10997 };
10998 10998
10999 TEST_P(HttpNetworkTransactionTest, 10999 TEST_P(HttpNetworkTransactionTest,
11000 UseAlternateProtocolForTunneledNpnSpdy) { 11000 UseAlternateProtocolForTunneledNpnSpdy) {
11001 session_deps_.parse_alternative_services = true; 11001 session_deps_.parse_alternative_services = false;
11002 session_deps_.enable_alternative_service_with_different_host = false; 11002 session_deps_.enable_alternative_service_with_different_host = false;
11003 11003
11004 ProxyConfig proxy_config; 11004 ProxyConfig proxy_config;
11005 proxy_config.set_auto_detect(true); 11005 proxy_config.set_auto_detect(true);
11006 proxy_config.set_pac_url(GURL("http://fooproxyurl")); 11006 proxy_config.set_pac_url(GURL("http://fooproxyurl"));
11007 11007
11008 CapturingProxyResolver capturing_proxy_resolver; 11008 CapturingProxyResolver capturing_proxy_resolver;
11009 session_deps_.proxy_service.reset(new ProxyService( 11009 session_deps_.proxy_service.reset(new ProxyService(
11010 make_scoped_ptr(new ProxyConfigServiceFixed(proxy_config)), 11010 make_scoped_ptr(new ProxyConfigServiceFixed(proxy_config)),
11011 make_scoped_ptr( 11011 make_scoped_ptr(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
11115 capturing_proxy_resolver.resolved()[1].spec()); 11115 capturing_proxy_resolver.resolved()[1].spec());
11116 11116
11117 LoadTimingInfo load_timing_info; 11117 LoadTimingInfo load_timing_info;
11118 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); 11118 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info));
11119 TestLoadTimingNotReusedWithPac(load_timing_info, 11119 TestLoadTimingNotReusedWithPac(load_timing_info,
11120 CONNECT_TIMING_HAS_SSL_TIMES); 11120 CONNECT_TIMING_HAS_SSL_TIMES);
11121 } 11121 }
11122 11122
11123 TEST_P(HttpNetworkTransactionTest, 11123 TEST_P(HttpNetworkTransactionTest,
11124 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { 11124 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) {
11125 session_deps_.parse_alternative_services = true; 11125 session_deps_.parse_alternative_services = false;
11126 session_deps_.enable_alternative_service_with_different_host = false; 11126 session_deps_.enable_alternative_service_with_different_host = false;
11127 11127
11128 HttpRequestInfo request; 11128 HttpRequestInfo request;
11129 request.method = "GET"; 11129 request.method = "GET";
11130 request.url = GURL("http://www.example.org/"); 11130 request.url = GURL("http://www.example.org/");
11131 request.load_flags = 0; 11131 request.load_flags = 0;
11132 11132
11133 std::string alternate_protocol_http_header = 11133 std::string alternate_protocol_http_header =
11134 GetAlternateProtocolHttpHeader(); 11134 GetAlternateProtocolHttpHeader();
11135 11135
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
11939 credentials, request, callback, auth_token); 11939 credentials, request, callback, auth_token);
11940 } 11940 }
11941 11941
11942 private: 11942 private:
11943 GURL* url_; 11943 GURL* url_;
11944 }; 11944 };
11945 11945
11946 // This test ensures that the URL passed into the proxy is upgraded to https 11946 // This test ensures that the URL passed into the proxy is upgraded to https
11947 // when doing an Alternate Protocol upgrade. 11947 // when doing an Alternate Protocol upgrade.
11948 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { 11948 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) {
11949 session_deps_.parse_alternative_services = true; 11949 session_deps_.parse_alternative_services = false;
11950 session_deps_.enable_alternative_service_with_different_host = false; 11950 session_deps_.enable_alternative_service_with_different_host = false;
11951 11951
11952 session_deps_.proxy_service = 11952 session_deps_.proxy_service =
11953 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); 11953 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
11954 TestNetLog net_log; 11954 TestNetLog net_log;
11955 session_deps_.net_log = &net_log; 11955 session_deps_.net_log = &net_log;
11956 GURL request_url; 11956 GURL request_url;
11957 { 11957 {
11958 HttpAuthHandlerMock::Factory* auth_factory = 11958 HttpAuthHandlerMock::Factory* auth_factory =
11959 new HttpAuthHandlerMock::Factory(); 11959 new HttpAuthHandlerMock::Factory();
(...skipping 3999 matching lines...) Expand 10 before | Expand all | Expand 10 after
15959 base::MessageLoop::current()->RunUntilIdle(); 15959 base::MessageLoop::current()->RunUntilIdle();
15960 15960
15961 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); 15961 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
15962 HttpRequestHeaders headers; 15962 HttpRequestHeaders headers;
15963 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); 15963 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
15964 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); 15964 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
15965 } 15965 }
15966 #endif // !defined(OS_IOS) 15966 #endif // !defined(OS_IOS)
15967 15967
15968 } // namespace net 15968 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/quic/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698