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

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

Issue 1268313004: s/use_alternate_protocols/use_alternative_services/g (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: #15. Created 5 years, 4 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_session.cc ('k') | 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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 7917 matching lines...) Expand 10 before | Expand all | Expand 10 after
7928 true, 7928 true,
7929 }, 7929 },
7930 { 7930 {
7931 "", // unused 7931 "", // unused
7932 "http://host.with.alternate/direct", 7932 "http://host.with.alternate/direct",
7933 "ssl/host.with.alternate:443", 7933 "ssl/host.with.alternate:443",
7934 true, 7934 true,
7935 }, 7935 },
7936 }; 7936 };
7937 7937
7938 session_deps_.use_alternate_protocols = true; 7938 session_deps_.use_alternative_services = true;
7939 7939
7940 for (size_t i = 0; i < arraysize(tests); ++i) { 7940 for (size_t i = 0; i < arraysize(tests); ++i) {
7941 session_deps_.proxy_service.reset( 7941 session_deps_.proxy_service.reset(
7942 ProxyService::CreateFixed(tests[i].proxy_server)); 7942 ProxyService::CreateFixed(tests[i].proxy_server));
7943 scoped_refptr<HttpNetworkSession> session( 7943 scoped_refptr<HttpNetworkSession> session(
7944 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 7944 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
7945 7945
7946 HttpNetworkSessionPeer peer(session); 7946 HttpNetworkSessionPeer peer(session);
7947 CaptureGroupNameTransportSocketPool* transport_conn_pool = 7947 CaptureGroupNameTransportSocketPool* transport_conn_pool =
7948 new CaptureGroupNameTransportSocketPool(NULL, NULL); 7948 new CaptureGroupNameTransportSocketPool(NULL, NULL);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
7990 }, 7990 },
7991 7991
7992 { 7992 {
7993 "http_proxy", 7993 "http_proxy",
7994 "ftp://ftp.google.com/http_proxy_normal", 7994 "ftp://ftp.google.com/http_proxy_normal",
7995 "ftp/ftp.google.com:21", 7995 "ftp/ftp.google.com:21",
7996 false, 7996 false,
7997 }, 7997 },
7998 }; 7998 };
7999 7999
8000 session_deps_.use_alternate_protocols = true; 8000 session_deps_.use_alternative_services = true;
8001 8001
8002 for (size_t i = 0; i < arraysize(tests); ++i) { 8002 for (size_t i = 0; i < arraysize(tests); ++i) {
8003 session_deps_.proxy_service.reset( 8003 session_deps_.proxy_service.reset(
8004 ProxyService::CreateFixed(tests[i].proxy_server)); 8004 ProxyService::CreateFixed(tests[i].proxy_server));
8005 scoped_refptr<HttpNetworkSession> session( 8005 scoped_refptr<HttpNetworkSession> session(
8006 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8006 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8007 8007
8008 HttpNetworkSessionPeer peer(session); 8008 HttpNetworkSessionPeer peer(session);
8009 8009
8010 HostPortPair proxy_host("http_proxy", 80); 8010 HostPortPair proxy_host("http_proxy", 80);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
8060 }, 8060 },
8061 8061
8062 { 8062 {
8063 "socks4://socks_proxy:1080", 8063 "socks4://socks_proxy:1080",
8064 "http://host.with.alternate/direct", 8064 "http://host.with.alternate/direct",
8065 "socks4/ssl/host.with.alternate:443", 8065 "socks4/ssl/host.with.alternate:443",
8066 true, 8066 true,
8067 }, 8067 },
8068 }; 8068 };
8069 8069
8070 session_deps_.use_alternate_protocols = true; 8070 session_deps_.use_alternative_services = true;
8071 8071
8072 for (size_t i = 0; i < arraysize(tests); ++i) { 8072 for (size_t i = 0; i < arraysize(tests); ++i) {
8073 session_deps_.proxy_service.reset( 8073 session_deps_.proxy_service.reset(
8074 ProxyService::CreateFixed(tests[i].proxy_server)); 8074 ProxyService::CreateFixed(tests[i].proxy_server));
8075 scoped_refptr<HttpNetworkSession> session( 8075 scoped_refptr<HttpNetworkSession> session(
8076 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8076 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8077 8077
8078 HttpNetworkSessionPeer peer(session); 8078 HttpNetworkSessionPeer peer(session);
8079 8079
8080 HostPortPair proxy_host("socks_proxy", 1080); 8080 HostPortPair proxy_host("socks_proxy", 1080);
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
8714 EXPECT_EQ(ERR_IO_PENDING, rv); 8714 EXPECT_EQ(ERR_IO_PENDING, rv);
8715 rv = callback4.WaitForResult(); 8715 rv = callback4.WaitForResult();
8716 EXPECT_EQ(OK, rv); 8716 EXPECT_EQ(OK, rv);
8717 response = trans->GetResponseInfo(); 8717 response = trans->GetResponseInfo();
8718 ASSERT_TRUE(response != NULL); 8718 ASSERT_TRUE(response != NULL);
8719 EXPECT_TRUE(response->auth_challenge.get() == NULL); 8719 EXPECT_TRUE(response->auth_challenge.get() == NULL);
8720 } 8720 }
8721 8721
8722 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { 8722 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) {
8723 session_deps_.next_protos = SpdyNextProtos(); 8723 session_deps_.next_protos = SpdyNextProtos();
8724 session_deps_.use_alternate_protocols = true; 8724 session_deps_.use_alternative_services = true;
8725 8725
8726 std::string alternative_service_http_header = 8726 std::string alternative_service_http_header =
8727 GetAlternativeServiceHttpHeader(); 8727 GetAlternativeServiceHttpHeader();
8728 8728
8729 MockRead data_reads[] = { 8729 MockRead data_reads[] = {
8730 MockRead("HTTP/1.1 200 OK\r\n"), 8730 MockRead("HTTP/1.1 200 OK\r\n"),
8731 MockRead(alternative_service_http_header.c_str()), 8731 MockRead(alternative_service_http_header.c_str()),
8732 MockRead("\r\n"), 8732 MockRead("\r\n"),
8733 MockRead("hello world"), 8733 MockRead("hello world"),
8734 MockRead(SYNCHRONOUS, OK), 8734 MockRead(SYNCHRONOUS, OK),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
8776 http_server_properties.GetAlternativeServices(http_host_port_pair); 8776 http_server_properties.GetAlternativeServices(http_host_port_pair);
8777 ASSERT_EQ(1u, alternative_service_vector.size()); 8777 ASSERT_EQ(1u, alternative_service_vector.size());
8778 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), 8778 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()),
8779 alternative_service_vector[0].protocol); 8779 alternative_service_vector[0].protocol);
8780 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 8780 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
8781 EXPECT_EQ(443, alternative_service_vector[0].port); 8781 EXPECT_EQ(443, alternative_service_vector[0].port);
8782 } 8782 }
8783 8783
8784 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { 8784 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) {
8785 session_deps_.next_protos = SpdyNextProtos(); 8785 session_deps_.next_protos = SpdyNextProtos();
8786 session_deps_.use_alternate_protocols = true; 8786 session_deps_.use_alternative_services = true;
8787 8787
8788 MockRead data_reads[] = { 8788 MockRead data_reads[] = {
8789 MockRead("HTTP/1.1 200 OK\r\n"), 8789 MockRead("HTTP/1.1 200 OK\r\n"),
8790 MockRead("Alt-Svc: "), 8790 MockRead("Alt-Svc: "),
8791 MockRead(GetAlternateProtocolFromParam()), 8791 MockRead(GetAlternateProtocolFromParam()),
8792 MockRead("=\"www.example.com:443\";p=1.0,"), 8792 MockRead("=\"www.example.com:443\";p=1.0,"),
8793 MockRead("quic=\":1234\"\r\n\r\n"), 8793 MockRead("quic=\":1234\"\r\n\r\n"),
8794 MockRead("hello world"), 8794 MockRead("hello world"),
8795 MockRead(SYNCHRONOUS, OK), 8795 MockRead(SYNCHRONOUS, OK),
8796 }; 8796 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
8840 alternative_service_vector[0].protocol); 8840 alternative_service_vector[0].protocol);
8841 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 8841 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
8842 EXPECT_EQ(443, alternative_service_vector[0].port); 8842 EXPECT_EQ(443, alternative_service_vector[0].port);
8843 EXPECT_EQ(QUIC, alternative_service_vector[1].protocol); 8843 EXPECT_EQ(QUIC, alternative_service_vector[1].protocol);
8844 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); 8844 EXPECT_EQ("www.example.org", alternative_service_vector[1].host);
8845 EXPECT_EQ(1234, alternative_service_vector[1].port); 8845 EXPECT_EQ(1234, alternative_service_vector[1].port);
8846 } 8846 }
8847 8847
8848 TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { 8848 TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
8849 session_deps_.next_protos = SpdyNextProtos(); 8849 session_deps_.next_protos = SpdyNextProtos();
8850 session_deps_.use_alternate_protocols = true; 8850 session_deps_.use_alternative_services = true;
8851 8851
8852 std::string alternate_protocol_http_header = 8852 std::string alternate_protocol_http_header =
8853 GetAlternateProtocolHttpHeader(); 8853 GetAlternateProtocolHttpHeader();
8854 8854
8855 MockRead data_reads[] = { 8855 MockRead data_reads[] = {
8856 MockRead("HTTP/1.1 200 OK\r\n"), 8856 MockRead("HTTP/1.1 200 OK\r\n"),
8857 MockRead(alternate_protocol_http_header.c_str()), 8857 MockRead(alternate_protocol_http_header.c_str()),
8858 MockRead("\r\n"), 8858 MockRead("\r\n"),
8859 MockRead("hello world"), 8859 MockRead("hello world"),
8860 MockRead(SYNCHRONOUS, OK), 8860 MockRead(SYNCHRONOUS, OK),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8901 alternative_service_vector = 8901 alternative_service_vector =
8902 http_server_properties.GetAlternativeServices(http_host_port_pair); 8902 http_server_properties.GetAlternativeServices(http_host_port_pair);
8903 ASSERT_EQ(1u, alternative_service_vector.size()); 8903 ASSERT_EQ(1u, alternative_service_vector.size());
8904 EXPECT_EQ(443, alternative_service_vector[0].port); 8904 EXPECT_EQ(443, alternative_service_vector[0].port);
8905 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), 8905 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()),
8906 alternative_service_vector[0].protocol); 8906 alternative_service_vector[0].protocol);
8907 } 8907 }
8908 8908
8909 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) { 8909 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) {
8910 session_deps_.next_protos = SpdyNextProtos(); 8910 session_deps_.next_protos = SpdyNextProtos();
8911 session_deps_.use_alternate_protocols = true; 8911 session_deps_.use_alternative_services = true;
8912 8912
8913 MockRead data_reads[] = { 8913 MockRead data_reads[] = {
8914 MockRead("HTTP/1.1 200 OK\r\n"), 8914 MockRead("HTTP/1.1 200 OK\r\n"),
8915 MockRead("Alternate-Protocol: \r\n\r\n"), 8915 MockRead("Alternate-Protocol: \r\n\r\n"),
8916 MockRead("hello world"), 8916 MockRead("hello world"),
8917 MockRead(SYNCHRONOUS, OK), 8917 MockRead(SYNCHRONOUS, OK),
8918 }; 8918 };
8919 8919
8920 HttpRequestInfo request; 8920 HttpRequestInfo request;
8921 request.method = "GET"; 8921 request.method = "GET";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8962 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 8962 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
8963 EXPECT_EQ("hello world", response_data); 8963 EXPECT_EQ("hello world", response_data);
8964 8964
8965 alternative_service_vector = 8965 alternative_service_vector =
8966 http_server_properties.GetAlternativeServices(http_host_port_pair); 8966 http_server_properties.GetAlternativeServices(http_host_port_pair);
8967 EXPECT_TRUE(alternative_service_vector.empty()); 8967 EXPECT_TRUE(alternative_service_vector.empty());
8968 } 8968 }
8969 8969
8970 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) { 8970 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) {
8971 session_deps_.next_protos = SpdyNextProtos(); 8971 session_deps_.next_protos = SpdyNextProtos();
8972 session_deps_.use_alternate_protocols = true; 8972 session_deps_.use_alternative_services = true;
8973 8973
8974 std::string alternative_service_http_header = 8974 std::string alternative_service_http_header =
8975 GetAlternativeServiceHttpHeader(); 8975 GetAlternativeServiceHttpHeader();
8976 std::string alternate_protocol_http_header = GetAlternateProtocolHttpHeader(); 8976 std::string alternate_protocol_http_header = GetAlternateProtocolHttpHeader();
8977 8977
8978 MockRead data_reads[] = { 8978 MockRead data_reads[] = {
8979 MockRead("HTTP/1.1 200 OK\r\n"), 8979 MockRead("HTTP/1.1 200 OK\r\n"),
8980 MockRead(alternative_service_http_header.c_str()), 8980 MockRead(alternative_service_http_header.c_str()),
8981 MockRead(alternate_protocol_http_header.c_str()), 8981 MockRead(alternate_protocol_http_header.c_str()),
8982 MockRead("\r\n"), 8982 MockRead("\r\n"),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
9026 http_server_properties.GetAlternativeServices(http_host_port_pair); 9026 http_server_properties.GetAlternativeServices(http_host_port_pair);
9027 ASSERT_EQ(1u, alternative_service_vector.size()); 9027 ASSERT_EQ(1u, alternative_service_vector.size());
9028 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), 9028 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()),
9029 alternative_service_vector[0].protocol); 9029 alternative_service_vector[0].protocol);
9030 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 9030 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
9031 EXPECT_EQ(443, alternative_service_vector[0].port); 9031 EXPECT_EQ(443, alternative_service_vector[0].port);
9032 } 9032 }
9033 9033
9034 TEST_P(HttpNetworkTransactionTest, 9034 TEST_P(HttpNetworkTransactionTest,
9035 MarkBrokenAlternateProtocolAndFallback) { 9035 MarkBrokenAlternateProtocolAndFallback) {
9036 session_deps_.use_alternate_protocols = true; 9036 session_deps_.use_alternative_services = true;
9037 9037
9038 HttpRequestInfo request; 9038 HttpRequestInfo request;
9039 request.method = "GET"; 9039 request.method = "GET";
9040 request.url = GURL("http://www.example.org/"); 9040 request.url = GURL("http://www.example.org/");
9041 request.load_flags = 0; 9041 request.load_flags = 0;
9042 9042
9043 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9043 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9044 StaticSocketDataProvider first_data; 9044 StaticSocketDataProvider first_data;
9045 first_data.set_connect_data(mock_connect); 9045 first_data.set_connect_data(mock_connect);
9046 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9046 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9086 EXPECT_EQ("hello world", response_data); 9086 EXPECT_EQ("hello world", response_data);
9087 9087
9088 const AlternativeServiceVector alternative_service_vector = 9088 const AlternativeServiceVector alternative_service_vector =
9089 http_server_properties->GetAlternativeServices(host_port_pair); 9089 http_server_properties->GetAlternativeServices(host_port_pair);
9090 ASSERT_EQ(1u, alternative_service_vector.size()); 9090 ASSERT_EQ(1u, alternative_service_vector.size());
9091 EXPECT_EQ(alternative_service, alternative_service_vector[0]); 9091 EXPECT_EQ(alternative_service, alternative_service_vector[0]);
9092 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken( 9092 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken(
9093 alternative_service_vector[0])); 9093 alternative_service_vector[0]));
9094 } 9094 }
9095 9095
9096 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9097 // to an unrestricted (port >= 1024) when the original traffic was on a
9098 // restricted port (port < 1024). Ensure that we can redirect in all other
9099 // cases.
9096 TEST_P(HttpNetworkTransactionTest, 9100 TEST_P(HttpNetworkTransactionTest,
9097 AlternateProtocolPortRestrictedBlocked) { 9101 AlternateProtocolPortRestrictedBlocked) {
9098 // Ensure that we're not allowed to redirect traffic via an alternate 9102 session_deps_.use_alternative_services = true;
9099 // protocol to an unrestricted (port >= 1024) when the original traffic was
9100 // on a restricted port (port < 1024). Ensure that we can redirect in all
9101 // other cases.
9102 session_deps_.use_alternate_protocols = true;
9103 9103
9104 HttpRequestInfo restricted_port_request; 9104 HttpRequestInfo restricted_port_request;
9105 restricted_port_request.method = "GET"; 9105 restricted_port_request.method = "GET";
9106 restricted_port_request.url = GURL("http://www.example.org:1023/"); 9106 restricted_port_request.url = GURL("http://www.example.org:1023/");
9107 restricted_port_request.load_flags = 0; 9107 restricted_port_request.load_flags = 0;
9108 9108
9109 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9109 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9110 StaticSocketDataProvider first_data; 9110 StaticSocketDataProvider first_data;
9111 first_data.set_connect_data(mock_connect); 9111 first_data.set_connect_data(mock_connect);
9112 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9112 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 25 matching lines...) Expand all
9138 TestCompletionCallback callback; 9138 TestCompletionCallback callback;
9139 9139
9140 int rv = trans->Start( 9140 int rv = trans->Start(
9141 &restricted_port_request, 9141 &restricted_port_request,
9142 callback.callback(), BoundNetLog()); 9142 callback.callback(), BoundNetLog());
9143 EXPECT_EQ(ERR_IO_PENDING, rv); 9143 EXPECT_EQ(ERR_IO_PENDING, rv);
9144 // Invalid change to unrestricted port should fail. 9144 // Invalid change to unrestricted port should fail.
9145 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); 9145 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult());
9146 } 9146 }
9147 9147
9148 // Ensure that we are allowed to redirect traffic via an alternate protocol to
9149 // an unrestricted (port >= 1024) when the original traffic was on a restricted
9150 // port (port < 1024) if we set |enable_user_alternate_protocol_ports|.
9148 TEST_P(HttpNetworkTransactionTest, 9151 TEST_P(HttpNetworkTransactionTest,
9149 AlternateProtocolPortRestrictedPermitted) { 9152 AlternateProtocolPortRestrictedPermitted) {
9150 // Ensure that we're allowed to redirect traffic via an alternate 9153 session_deps_.use_alternative_services = true;
9151 // protocol to an unrestricted (port >= 1024) when the original traffic was
9152 // on a restricted port (port < 1024) if we set
9153 // enable_user_alternate_protocol_ports.
9154
9155 session_deps_.use_alternate_protocols = true;
9156 session_deps_.enable_user_alternate_protocol_ports = true; 9154 session_deps_.enable_user_alternate_protocol_ports = true;
9157 9155
9158 HttpRequestInfo restricted_port_request; 9156 HttpRequestInfo restricted_port_request;
9159 restricted_port_request.method = "GET"; 9157 restricted_port_request.method = "GET";
9160 restricted_port_request.url = GURL("http://www.example.org:1023/"); 9158 restricted_port_request.url = GURL("http://www.example.org:1023/");
9161 restricted_port_request.load_flags = 0; 9159 restricted_port_request.load_flags = 0;
9162 9160
9163 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9161 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9164 StaticSocketDataProvider first_data; 9162 StaticSocketDataProvider first_data;
9165 first_data.set_connect_data(mock_connect); 9163 first_data.set_connect_data(mock_connect);
(...skipping 25 matching lines...) Expand all
9191 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9189 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9192 TestCompletionCallback callback; 9190 TestCompletionCallback callback;
9193 9191
9194 EXPECT_EQ(ERR_IO_PENDING, trans->Start( 9192 EXPECT_EQ(ERR_IO_PENDING, trans->Start(
9195 &restricted_port_request, 9193 &restricted_port_request,
9196 callback.callback(), BoundNetLog())); 9194 callback.callback(), BoundNetLog()));
9197 // Change to unrestricted port should succeed. 9195 // Change to unrestricted port should succeed.
9198 EXPECT_EQ(OK, callback.WaitForResult()); 9196 EXPECT_EQ(OK, callback.WaitForResult());
9199 } 9197 }
9200 9198
9199 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9200 // to an unrestricted (port >= 1024) when the original traffic was on a
9201 // restricted port (port < 1024). Ensure that we can redirect in all other
9202 // cases.
9201 TEST_P(HttpNetworkTransactionTest, 9203 TEST_P(HttpNetworkTransactionTest,
9202 AlternateProtocolPortRestrictedAllowed) { 9204 AlternateProtocolPortRestrictedAllowed) {
9203 // Ensure that we're not allowed to redirect traffic via an alternate 9205 session_deps_.use_alternative_services = true;
9204 // protocol to an unrestricted (port >= 1024) when the original traffic was
9205 // on a restricted port (port < 1024). Ensure that we can redirect in all
9206 // other cases.
9207 session_deps_.use_alternate_protocols = true;
9208 9206
9209 HttpRequestInfo restricted_port_request; 9207 HttpRequestInfo restricted_port_request;
9210 restricted_port_request.method = "GET"; 9208 restricted_port_request.method = "GET";
9211 restricted_port_request.url = GURL("http://www.example.org:1023/"); 9209 restricted_port_request.url = GURL("http://www.example.org:1023/");
9212 restricted_port_request.load_flags = 0; 9210 restricted_port_request.load_flags = 0;
9213 9211
9214 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9212 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9215 StaticSocketDataProvider first_data; 9213 StaticSocketDataProvider first_data;
9216 first_data.set_connect_data(mock_connect); 9214 first_data.set_connect_data(mock_connect);
9217 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9215 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 25 matching lines...) Expand all
9243 TestCompletionCallback callback; 9241 TestCompletionCallback callback;
9244 9242
9245 int rv = trans->Start( 9243 int rv = trans->Start(
9246 &restricted_port_request, 9244 &restricted_port_request,
9247 callback.callback(), BoundNetLog()); 9245 callback.callback(), BoundNetLog());
9248 EXPECT_EQ(ERR_IO_PENDING, rv); 9246 EXPECT_EQ(ERR_IO_PENDING, rv);
9249 // Valid change to restricted port should pass. 9247 // Valid change to restricted port should pass.
9250 EXPECT_EQ(OK, callback.WaitForResult()); 9248 EXPECT_EQ(OK, callback.WaitForResult());
9251 } 9249 }
9252 9250
9251 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9252 // to an unrestricted (port >= 1024) when the original traffic was on a
9253 // restricted port (port < 1024). Ensure that we can redirect in all other
9254 // cases.
9253 TEST_P(HttpNetworkTransactionTest, 9255 TEST_P(HttpNetworkTransactionTest,
9254 AlternateProtocolPortUnrestrictedAllowed1) { 9256 AlternateProtocolPortUnrestrictedAllowed1) {
9255 // Ensure that we're not allowed to redirect traffic via an alternate 9257 session_deps_.use_alternative_services = true;
9256 // protocol to an unrestricted (port >= 1024) when the original traffic was
9257 // on a restricted port (port < 1024). Ensure that we can redirect in all
9258 // other cases.
9259 session_deps_.use_alternate_protocols = true;
9260 9258
9261 HttpRequestInfo unrestricted_port_request; 9259 HttpRequestInfo unrestricted_port_request;
9262 unrestricted_port_request.method = "GET"; 9260 unrestricted_port_request.method = "GET";
9263 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); 9261 unrestricted_port_request.url = GURL("http://www.example.org:1024/");
9264 unrestricted_port_request.load_flags = 0; 9262 unrestricted_port_request.load_flags = 0;
9265 9263
9266 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9264 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9267 StaticSocketDataProvider first_data; 9265 StaticSocketDataProvider first_data;
9268 first_data.set_connect_data(mock_connect); 9266 first_data.set_connect_data(mock_connect);
9269 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9267 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 24 matching lines...) Expand all
9294 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9292 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9295 TestCompletionCallback callback; 9293 TestCompletionCallback callback;
9296 9294
9297 int rv = trans->Start( 9295 int rv = trans->Start(
9298 &unrestricted_port_request, callback.callback(), BoundNetLog()); 9296 &unrestricted_port_request, callback.callback(), BoundNetLog());
9299 EXPECT_EQ(ERR_IO_PENDING, rv); 9297 EXPECT_EQ(ERR_IO_PENDING, rv);
9300 // Valid change to restricted port should pass. 9298 // Valid change to restricted port should pass.
9301 EXPECT_EQ(OK, callback.WaitForResult()); 9299 EXPECT_EQ(OK, callback.WaitForResult());
9302 } 9300 }
9303 9301
9302 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9303 // to an unrestricted (port >= 1024) when the original traffic was on a
9304 // restricted port (port < 1024). Ensure that we can redirect in all other
9305 // cases.
9304 TEST_P(HttpNetworkTransactionTest, 9306 TEST_P(HttpNetworkTransactionTest,
9305 AlternateProtocolPortUnrestrictedAllowed2) { 9307 AlternateProtocolPortUnrestrictedAllowed2) {
9306 // Ensure that we're not allowed to redirect traffic via an alternate 9308 session_deps_.use_alternative_services = true;
9307 // protocol to an unrestricted (port >= 1024) when the original traffic was
9308 // on a restricted port (port < 1024). Ensure that we can redirect in all
9309 // other cases.
9310 session_deps_.use_alternate_protocols = true;
9311 9309
9312 HttpRequestInfo unrestricted_port_request; 9310 HttpRequestInfo unrestricted_port_request;
9313 unrestricted_port_request.method = "GET"; 9311 unrestricted_port_request.method = "GET";
9314 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); 9312 unrestricted_port_request.url = GURL("http://www.example.org:1024/");
9315 unrestricted_port_request.load_flags = 0; 9313 unrestricted_port_request.load_flags = 0;
9316 9314
9317 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9315 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9318 StaticSocketDataProvider first_data; 9316 StaticSocketDataProvider first_data;
9319 first_data.set_connect_data(mock_connect); 9317 first_data.set_connect_data(mock_connect);
9320 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9318 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 24 matching lines...) Expand all
9345 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9343 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9346 TestCompletionCallback callback; 9344 TestCompletionCallback callback;
9347 9345
9348 int rv = trans->Start( 9346 int rv = trans->Start(
9349 &unrestricted_port_request, callback.callback(), BoundNetLog()); 9347 &unrestricted_port_request, callback.callback(), BoundNetLog());
9350 EXPECT_EQ(ERR_IO_PENDING, rv); 9348 EXPECT_EQ(ERR_IO_PENDING, rv);
9351 // Valid change to an unrestricted port should pass. 9349 // Valid change to an unrestricted port should pass.
9352 EXPECT_EQ(OK, callback.WaitForResult()); 9350 EXPECT_EQ(OK, callback.WaitForResult());
9353 } 9351 }
9354 9352
9353 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9354 // to an unsafe port, and that we resume the second HttpStreamFactoryImpl::Job
9355 // once the alternate protocol request fails.
9355 TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) { 9356 TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) {
9356 // Ensure that we're not allowed to redirect traffic via an alternate 9357 session_deps_.use_alternative_services = true;
9357 // protocol to an unsafe port, and that we resume the second
9358 // HttpStreamFactoryImpl::Job once the alternate protocol request fails.
9359 session_deps_.use_alternate_protocols = true;
9360 9358
9361 HttpRequestInfo request; 9359 HttpRequestInfo request;
9362 request.method = "GET"; 9360 request.method = "GET";
9363 request.url = GURL("http://www.example.org/"); 9361 request.url = GURL("http://www.example.org/");
9364 request.load_flags = 0; 9362 request.load_flags = 0;
9365 9363
9366 // The alternate protocol request will error out before we attempt to connect, 9364 // The alternate protocol request will error out before we attempt to connect,
9367 // so only the standard HTTP request will try to connect. 9365 // so only the standard HTTP request will try to connect.
9368 MockRead data_reads[] = { 9366 MockRead data_reads[] = {
9369 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9367 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
(...skipping 18 matching lines...) Expand all
9388 9386
9389 scoped_ptr<HttpTransaction> trans( 9387 scoped_ptr<HttpTransaction> trans(
9390 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9388 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9391 TestCompletionCallback callback; 9389 TestCompletionCallback callback;
9392 9390
9393 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9391 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9394 EXPECT_EQ(ERR_IO_PENDING, rv); 9392 EXPECT_EQ(ERR_IO_PENDING, rv);
9395 // The HTTP request should succeed. 9393 // The HTTP request should succeed.
9396 EXPECT_EQ(OK, callback.WaitForResult()); 9394 EXPECT_EQ(OK, callback.WaitForResult());
9397 9395
9398 // Disable alternate protocol before the asserts.
9399 // HttpStreamFactory::set_use_alternate_protocols(false);
9400
9401 const HttpResponseInfo* response = trans->GetResponseInfo(); 9396 const HttpResponseInfo* response = trans->GetResponseInfo();
9402 ASSERT_TRUE(response != NULL); 9397 ASSERT_TRUE(response != NULL);
9403 ASSERT_TRUE(response->headers.get() != NULL); 9398 ASSERT_TRUE(response->headers.get() != NULL);
9404 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9399 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9405 9400
9406 std::string response_data; 9401 std::string response_data;
9407 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9402 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9408 EXPECT_EQ("hello world", response_data); 9403 EXPECT_EQ("hello world", response_data);
9409 } 9404 }
9410 9405
9411 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { 9406 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) {
9412 session_deps_.use_alternate_protocols = true; 9407 session_deps_.use_alternative_services = true;
9413 session_deps_.next_protos = SpdyNextProtos(); 9408 session_deps_.next_protos = SpdyNextProtos();
9414 9409
9415 HttpRequestInfo request; 9410 HttpRequestInfo request;
9416 request.method = "GET"; 9411 request.method = "GET";
9417 request.url = GURL("http://www.example.org/"); 9412 request.url = GURL("http://www.example.org/");
9418 request.load_flags = 0; 9413 request.load_flags = 0;
9419 9414
9420 std::string alternate_protocol_http_header = 9415 std::string alternate_protocol_http_header =
9421 GetAlternateProtocolHttpHeader(); 9416 GetAlternateProtocolHttpHeader();
9422 9417
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
9490 ASSERT_TRUE(response->headers.get() != NULL); 9485 ASSERT_TRUE(response->headers.get() != NULL);
9491 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9486 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9492 EXPECT_TRUE(response->was_fetched_via_spdy); 9487 EXPECT_TRUE(response->was_fetched_via_spdy);
9493 EXPECT_TRUE(response->was_npn_negotiated); 9488 EXPECT_TRUE(response->was_npn_negotiated);
9494 9489
9495 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9490 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9496 EXPECT_EQ("hello!", response_data); 9491 EXPECT_EQ("hello!", response_data);
9497 } 9492 }
9498 9493
9499 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { 9494 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) {
9500 session_deps_.use_alternate_protocols = true; 9495 session_deps_.use_alternative_services = true;
9501 session_deps_.next_protos = SpdyNextProtos(); 9496 session_deps_.next_protos = SpdyNextProtos();
9502 9497
9503 HttpRequestInfo request; 9498 HttpRequestInfo request;
9504 request.method = "GET"; 9499 request.method = "GET";
9505 request.url = GURL("http://www.example.org/"); 9500 request.url = GURL("http://www.example.org/");
9506 request.load_flags = 0; 9501 request.load_flags = 0;
9507 9502
9508 std::string alternate_protocol_http_header = 9503 std::string alternate_protocol_http_header =
9509 GetAlternateProtocolHttpHeader(); 9504 GetAlternateProtocolHttpHeader();
9510 9505
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
9607 ASSERT_TRUE(response != NULL); 9602 ASSERT_TRUE(response != NULL);
9608 ASSERT_TRUE(response->headers.get() != NULL); 9603 ASSERT_TRUE(response->headers.get() != NULL);
9609 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9604 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9610 EXPECT_TRUE(response->was_fetched_via_spdy); 9605 EXPECT_TRUE(response->was_fetched_via_spdy);
9611 EXPECT_TRUE(response->was_npn_negotiated); 9606 EXPECT_TRUE(response->was_npn_negotiated);
9612 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); 9607 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data));
9613 EXPECT_EQ("hello!", response_data); 9608 EXPECT_EQ("hello!", response_data);
9614 } 9609 }
9615 9610
9616 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { 9611 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) {
9617 session_deps_.use_alternate_protocols = true; 9612 session_deps_.use_alternative_services = true;
9618 session_deps_.next_protos = SpdyNextProtos(); 9613 session_deps_.next_protos = SpdyNextProtos();
9619 9614
9620 HttpRequestInfo request; 9615 HttpRequestInfo request;
9621 request.method = "GET"; 9616 request.method = "GET";
9622 request.url = GURL("http://www.example.org/"); 9617 request.url = GURL("http://www.example.org/");
9623 request.load_flags = 0; 9618 request.load_flags = 0;
9624 9619
9625 std::string alternate_protocol_http_header = 9620 std::string alternate_protocol_http_header =
9626 GetAlternateProtocolHttpHeader(); 9621 GetAlternateProtocolHttpHeader();
9627 9622
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
9734 resolver->reset(new ForwardingProxyResolver(resolver_)); 9729 resolver->reset(new ForwardingProxyResolver(resolver_));
9735 return OK; 9730 return OK;
9736 } 9731 }
9737 9732
9738 private: 9733 private:
9739 ProxyResolver* resolver_; 9734 ProxyResolver* resolver_;
9740 }; 9735 };
9741 9736
9742 TEST_P(HttpNetworkTransactionTest, 9737 TEST_P(HttpNetworkTransactionTest,
9743 UseAlternateProtocolForTunneledNpnSpdy) { 9738 UseAlternateProtocolForTunneledNpnSpdy) {
9744 session_deps_.use_alternate_protocols = true; 9739 session_deps_.use_alternative_services = true;
9745 session_deps_.next_protos = SpdyNextProtos(); 9740 session_deps_.next_protos = SpdyNextProtos();
9746 9741
9747 ProxyConfig proxy_config; 9742 ProxyConfig proxy_config;
9748 proxy_config.set_auto_detect(true); 9743 proxy_config.set_auto_detect(true);
9749 proxy_config.set_pac_url(GURL("http://fooproxyurl")); 9744 proxy_config.set_pac_url(GURL("http://fooproxyurl"));
9750 9745
9751 CapturingProxyResolver capturing_proxy_resolver; 9746 CapturingProxyResolver capturing_proxy_resolver;
9752 session_deps_.proxy_service.reset(new ProxyService( 9747 session_deps_.proxy_service.reset(new ProxyService(
9753 new ProxyConfigServiceFixed(proxy_config), 9748 new ProxyConfigServiceFixed(proxy_config),
9754 make_scoped_ptr( 9749 make_scoped_ptr(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
9860 capturing_proxy_resolver.resolved()[1].spec()); 9855 capturing_proxy_resolver.resolved()[1].spec());
9861 9856
9862 LoadTimingInfo load_timing_info; 9857 LoadTimingInfo load_timing_info;
9863 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); 9858 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info));
9864 TestLoadTimingNotReusedWithPac(load_timing_info, 9859 TestLoadTimingNotReusedWithPac(load_timing_info,
9865 CONNECT_TIMING_HAS_SSL_TIMES); 9860 CONNECT_TIMING_HAS_SSL_TIMES);
9866 } 9861 }
9867 9862
9868 TEST_P(HttpNetworkTransactionTest, 9863 TEST_P(HttpNetworkTransactionTest,
9869 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { 9864 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) {
9870 session_deps_.use_alternate_protocols = true; 9865 session_deps_.use_alternative_services = true;
9871 session_deps_.next_protos = SpdyNextProtos(); 9866 session_deps_.next_protos = SpdyNextProtos();
9872 9867
9873 HttpRequestInfo request; 9868 HttpRequestInfo request;
9874 request.method = "GET"; 9869 request.method = "GET";
9875 request.url = GURL("http://www.example.org/"); 9870 request.url = GURL("http://www.example.org/");
9876 request.load_flags = 0; 9871 request.load_flags = 0;
9877 9872
9878 std::string alternate_protocol_http_header = 9873 std::string alternate_protocol_http_header =
9879 GetAlternateProtocolHttpHeader(); 9874 GetAlternateProtocolHttpHeader();
9880 9875
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
10558 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); 10553 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback());
10559 EXPECT_EQ(0, rv); 10554 EXPECT_EQ(0, rv);
10560 10555
10561 // Finally, the socket is released to the group. 10556 // Finally, the socket is released to the group.
10562 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); 10557 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup));
10563 } 10558 }
10564 10559
10565 // This tests the case that a request is issued via http instead of spdy after 10560 // This tests the case that a request is issued via http instead of spdy after
10566 // npn is negotiated. 10561 // npn is negotiated.
10567 TEST_P(HttpNetworkTransactionTest, NpnWithHttpOverSSL) { 10562 TEST_P(HttpNetworkTransactionTest, NpnWithHttpOverSSL) {
10568 session_deps_.use_alternate_protocols = true; 10563 session_deps_.use_alternative_services = true;
10569 NextProtoVector next_protos; 10564 NextProtoVector next_protos;
10570 next_protos.push_back(kProtoHTTP11); 10565 next_protos.push_back(kProtoHTTP11);
10571 session_deps_.next_protos = next_protos; 10566 session_deps_.next_protos = next_protos;
10572 10567
10573 HttpRequestInfo request; 10568 HttpRequestInfo request;
10574 request.method = "GET"; 10569 request.method = "GET";
10575 request.url = GURL("https://www.example.org/"); 10570 request.url = GURL("https://www.example.org/");
10576 request.load_flags = 0; 10571 request.load_flags = 0;
10577 10572
10578 MockWrite data_writes[] = { 10573 MockWrite data_writes[] = {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
10619 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10614 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10620 10615
10621 std::string response_data; 10616 std::string response_data;
10622 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10617 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10623 EXPECT_EQ("hello world", response_data); 10618 EXPECT_EQ("hello world", response_data);
10624 10619
10625 EXPECT_FALSE(response->was_fetched_via_spdy); 10620 EXPECT_FALSE(response->was_fetched_via_spdy);
10626 EXPECT_TRUE(response->was_npn_negotiated); 10621 EXPECT_TRUE(response->was_npn_negotiated);
10627 } 10622 }
10628 10623
10624 // Simulate the SSL handshake completing with an NPN negotiation followed by an
10625 // immediate server closing of the socket.
10626 // Regression test for https://crbug.com/46369.
10629 TEST_P(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { 10627 TEST_P(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) {
10630 // Simulate the SSL handshake completing with an NPN negotiation 10628 session_deps_.use_alternative_services = true;
10631 // followed by an immediate server closing of the socket.
10632 // Fix crash: http://crbug.com/46369
10633 session_deps_.use_alternate_protocols = true;
10634 session_deps_.next_protos = SpdyNextProtos(); 10629 session_deps_.next_protos = SpdyNextProtos();
10635 10630
10636 HttpRequestInfo request; 10631 HttpRequestInfo request;
10637 request.method = "GET"; 10632 request.method = "GET";
10638 request.url = GURL("https://www.example.org/"); 10633 request.url = GURL("https://www.example.org/");
10639 request.load_flags = 0; 10634 request.load_flags = 0;
10640 10635
10641 SSLSocketDataProvider ssl(ASYNC, OK); 10636 SSLSocketDataProvider ssl(ASYNC, OK);
10642 ssl.SetNextProto(GetParam()); 10637 ssl.SetNextProto(GetParam());
10643 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 10638 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
10681 std::string* auth_token) override { 10676 std::string* auth_token) override {
10682 *url_ = request->url; 10677 *url_ = request->url;
10683 return HttpAuthHandlerMock::GenerateAuthTokenImpl( 10678 return HttpAuthHandlerMock::GenerateAuthTokenImpl(
10684 credentials, request, callback, auth_token); 10679 credentials, request, callback, auth_token);
10685 } 10680 }
10686 10681
10687 private: 10682 private:
10688 GURL* url_; 10683 GURL* url_;
10689 }; 10684 };
10690 10685
10686 // This test ensures that the URL passed into the proxy is upgraded to https
10687 // when doing an Alternate Protocol upgrade.
10691 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { 10688 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) {
10692 // This test ensures that the URL passed into the proxy is upgraded 10689 session_deps_.use_alternative_services = true;
10693 // to https when doing an Alternate Protocol upgrade.
10694 session_deps_.use_alternate_protocols = true;
10695 session_deps_.next_protos = SpdyNextProtos(); 10690 session_deps_.next_protos = SpdyNextProtos();
10696 10691
10697 session_deps_.proxy_service.reset( 10692 session_deps_.proxy_service.reset(
10698 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 10693 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
10699 TestNetLog net_log; 10694 TestNetLog net_log;
10700 session_deps_.net_log = &net_log; 10695 session_deps_.net_log = &net_log;
10701 GURL request_url; 10696 GURL request_url;
10702 { 10697 {
10703 HttpAuthHandlerMock::Factory* auth_factory = 10698 HttpAuthHandlerMock::Factory* auth_factory =
10704 new HttpAuthHandlerMock::Factory(); 10699 new HttpAuthHandlerMock::Factory();
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
11541 // Now that the new handshake has failed, ensure that the client 11536 // Now that the new handshake has failed, ensure that the client
11542 // certificate was removed from the client auth cache. 11537 // certificate was removed from the client auth cache.
11543 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( 11538 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup(
11544 HostPortPair("proxy", 70), &client_cert)); 11539 HostPortPair("proxy", 70), &client_cert));
11545 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( 11540 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup(
11546 HostPortPair("www.example.com", 443), &client_cert)); 11541 HostPortPair("www.example.com", 443), &client_cert));
11547 } 11542 }
11548 } 11543 }
11549 11544
11550 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) { 11545 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) {
11551 session_deps_.use_alternate_protocols = true; 11546 session_deps_.use_alternative_services = true;
11552 session_deps_.next_protos = SpdyNextProtos(); 11547 session_deps_.next_protos = SpdyNextProtos();
11553 11548
11554 // Set up a special HttpNetworkSession with a MockCachingHostResolver. 11549 // Set up a special HttpNetworkSession with a MockCachingHostResolver.
11555 session_deps_.host_resolver.reset(new MockCachingHostResolver()); 11550 session_deps_.host_resolver.reset(new MockCachingHostResolver());
11556 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11551 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11557 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11552 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11558 pool_peer.DisableDomainAuthenticationVerification(); 11553 pool_peer.DisableDomainAuthenticationVerification();
11559 11554
11560 SSLSocketDataProvider ssl(ASYNC, OK); 11555 SSLSocketDataProvider ssl(ASYNC, OK);
11561 ssl.SetNextProto(GetParam()); 11556 ssl.SetNextProto(GetParam());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
11640 ASSERT_TRUE(response != NULL); 11635 ASSERT_TRUE(response != NULL);
11641 ASSERT_TRUE(response->headers.get() != NULL); 11636 ASSERT_TRUE(response->headers.get() != NULL);
11642 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 11637 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
11643 EXPECT_TRUE(response->was_fetched_via_spdy); 11638 EXPECT_TRUE(response->was_fetched_via_spdy);
11644 EXPECT_TRUE(response->was_npn_negotiated); 11639 EXPECT_TRUE(response->was_npn_negotiated);
11645 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); 11640 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data));
11646 EXPECT_EQ("hello!", response_data); 11641 EXPECT_EQ("hello!", response_data);
11647 } 11642 }
11648 11643
11649 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { 11644 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) {
11650 session_deps_.use_alternate_protocols = true; 11645 session_deps_.use_alternative_services = true;
11651 session_deps_.next_protos = SpdyNextProtos(); 11646 session_deps_.next_protos = SpdyNextProtos();
11652 11647
11653 // Set up a special HttpNetworkSession with a MockCachingHostResolver. 11648 // Set up a special HttpNetworkSession with a MockCachingHostResolver.
11654 session_deps_.host_resolver.reset(new MockCachingHostResolver()); 11649 session_deps_.host_resolver.reset(new MockCachingHostResolver());
11655 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11650 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11656 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11651 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11657 pool_peer.DisableDomainAuthenticationVerification(); 11652 pool_peer.DisableDomainAuthenticationVerification();
11658 11653
11659 SSLSocketDataProvider ssl(ASYNC, OK); 11654 SSLSocketDataProvider ssl(ASYNC, OK);
11660 ssl.SetNextProto(GetParam()); 11655 ssl.SetNextProto(GetParam());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
11767 return &host_resolver_; 11762 return &host_resolver_;
11768 } 11763 }
11769 11764
11770 private: 11765 private:
11771 MockCachingHostResolver host_resolver_; 11766 MockCachingHostResolver host_resolver_;
11772 const HostPortPair host_port_; 11767 const HostPortPair host_port_;
11773 }; 11768 };
11774 11769
11775 TEST_P(HttpNetworkTransactionTest, 11770 TEST_P(HttpNetworkTransactionTest,
11776 UseIPConnectionPoolingWithHostCacheExpiration) { 11771 UseIPConnectionPoolingWithHostCacheExpiration) {
11777 session_deps_.use_alternate_protocols = true; 11772 session_deps_.use_alternative_services = true;
11778 session_deps_.next_protos = SpdyNextProtos(); 11773 session_deps_.next_protos = SpdyNextProtos();
11779 11774
11780 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. 11775 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver.
11781 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); 11776 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443));
11782 HttpNetworkSession::Params params = 11777 HttpNetworkSession::Params params =
11783 SpdySessionDependencies::CreateSessionParams(&session_deps_); 11778 SpdySessionDependencies::CreateSessionParams(&session_deps_);
11784 params.host_resolver = &host_resolver; 11779 params.host_resolver = &host_resolver;
11785 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11780 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11786 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11781 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11787 pool_peer.DisableDomainAuthenticationVerification(); 11782 pool_peer.DisableDomainAuthenticationVerification();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
12026 SequencedSocketData data(vector_as_array(&reads), reads.size(), 12021 SequencedSocketData data(vector_as_array(&reads), reads.size(),
12027 vector_as_array(&writes), writes.size()); 12022 vector_as_array(&writes), writes.size());
12028 session_deps_.socket_factory->AddSocketDataProvider(&data); 12023 session_deps_.socket_factory->AddSocketDataProvider(&data);
12029 12024
12030 // Connection to the origin fails. 12025 // Connection to the origin fails.
12031 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 12026 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
12032 StaticSocketDataProvider data_refused; 12027 StaticSocketDataProvider data_refused;
12033 data_refused.set_connect_data(mock_connect); 12028 data_refused.set_connect_data(mock_connect);
12034 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12029 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12035 12030
12036 session_deps_.use_alternate_protocols = true; 12031 session_deps_.use_alternative_services = true;
12037 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12032 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12038 base::WeakPtr<HttpServerProperties> http_server_properties = 12033 base::WeakPtr<HttpServerProperties> http_server_properties =
12039 session->http_server_properties(); 12034 session->http_server_properties();
12040 AlternativeService alternative_service( 12035 AlternativeService alternative_service(
12041 AlternateProtocolFromNextProto(GetParam()), alternative); 12036 AlternateProtocolFromNextProto(GetParam()), alternative);
12042 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12037 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12043 http_server_properties->SetAlternativeService(origin, alternative_service, 12038 http_server_properties->SetAlternativeService(origin, alternative_service,
12044 1.0, expiration); 12039 1.0, expiration);
12045 12040
12046 // First request to alternative. 12041 // First request to alternative.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
12131 session_deps_.socket_factory->AddSocketDataProvider(&data); 12126 session_deps_.socket_factory->AddSocketDataProvider(&data);
12132 12127
12133 // This test documents that an alternate Job should not be used if HTTP/1.1 is 12128 // This test documents that an alternate Job should not be used if HTTP/1.1 is
12134 // negotiated. In order to test this, a failed connection to the origin is 12129 // negotiated. In order to test this, a failed connection to the origin is
12135 // mocked. This way the request relies on the alternate Job. 12130 // mocked. This way the request relies on the alternate Job.
12136 StaticSocketDataProvider data_refused; 12131 StaticSocketDataProvider data_refused;
12137 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 12132 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
12138 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12133 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12139 12134
12140 // Set up alternative service for origin. 12135 // Set up alternative service for origin.
12141 session_deps_.use_alternate_protocols = true; 12136 session_deps_.use_alternative_services = true;
12142 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12137 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12143 base::WeakPtr<HttpServerProperties> http_server_properties = 12138 base::WeakPtr<HttpServerProperties> http_server_properties =
12144 session->http_server_properties(); 12139 session->http_server_properties();
12145 AlternativeService alternative_service( 12140 AlternativeService alternative_service(
12146 AlternateProtocolFromNextProto(GetParam()), alternative); 12141 AlternateProtocolFromNextProto(GetParam()), alternative);
12147 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12142 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12148 http_server_properties->SetAlternativeService(origin, alternative_service, 12143 http_server_properties->SetAlternativeService(origin, alternative_service,
12149 1.0, expiration); 12144 1.0, expiration);
12150 12145
12151 scoped_ptr<HttpTransaction> trans( 12146 scoped_ptr<HttpTransaction> trans(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
12204 MockRead("HTTP/1.1 200 OK\r\n"), 12199 MockRead("HTTP/1.1 200 OK\r\n"),
12205 MockRead("Content-Type: text/html\r\n"), 12200 MockRead("Content-Type: text/html\r\n"),
12206 MockRead("Content-Length: 7\r\n\r\n"), 12201 MockRead("Content-Length: 7\r\n\r\n"),
12207 MockRead("another"), 12202 MockRead("another"),
12208 }; 12203 };
12209 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 12204 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
12210 http_writes, arraysize(http_writes)); 12205 http_writes, arraysize(http_writes));
12211 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 12206 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
12212 12207
12213 // Set up alternative service for origin. 12208 // Set up alternative service for origin.
12214 session_deps_.use_alternate_protocols = true; 12209 session_deps_.use_alternative_services = true;
12215 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12210 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12216 base::WeakPtr<HttpServerProperties> http_server_properties = 12211 base::WeakPtr<HttpServerProperties> http_server_properties =
12217 session->http_server_properties(); 12212 session->http_server_properties();
12218 AlternativeService alternative_service( 12213 AlternativeService alternative_service(
12219 AlternateProtocolFromNextProto(GetParam()), alternative); 12214 AlternateProtocolFromNextProto(GetParam()), alternative);
12220 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12215 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12221 http_server_properties->SetAlternativeService(origin, alternative_service, 12216 http_server_properties->SetAlternativeService(origin, alternative_service,
12222 1.0, expiration); 12217 1.0, expiration);
12223 12218
12224 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 12219 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
12313 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 12308 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
12314 12309
12315 // This test documents that an alternate Job should not pool to an already 12310 // This test documents that an alternate Job should not pool to an already
12316 // existing HTTP/1.1 connection. In order to test this, a failed connection 12311 // existing HTTP/1.1 connection. In order to test this, a failed connection
12317 // to the origin is mocked. This way |request2| relies on the alternate Job. 12312 // to the origin is mocked. This way |request2| relies on the alternate Job.
12318 StaticSocketDataProvider data_refused; 12313 StaticSocketDataProvider data_refused;
12319 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 12314 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
12320 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12315 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12321 12316
12322 // Set up alternative service for origin. 12317 // Set up alternative service for origin.
12323 session_deps_.use_alternate_protocols = true; 12318 session_deps_.use_alternative_services = true;
12324 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12319 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12325 base::WeakPtr<HttpServerProperties> http_server_properties = 12320 base::WeakPtr<HttpServerProperties> http_server_properties =
12326 session->http_server_properties(); 12321 session->http_server_properties();
12327 AlternativeService alternative_service( 12322 AlternativeService alternative_service(
12328 AlternateProtocolFromNextProto(GetParam()), alternative); 12323 AlternateProtocolFromNextProto(GetParam()), alternative);
12329 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12324 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12330 http_server_properties->SetAlternativeService(origin, alternative_service, 12325 http_server_properties->SetAlternativeService(origin, alternative_service,
12331 1.0, expiration); 12326 1.0, expiration);
12332 12327
12333 // First transaction to alternative to open an HTTP/1.1 socket. 12328 // First transaction to alternative to open an HTTP/1.1 socket.
(...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after
14391 ASSERT_TRUE(response); 14386 ASSERT_TRUE(response);
14392 ASSERT_TRUE(response->headers.get()); 14387 ASSERT_TRUE(response->headers.get());
14393 14388
14394 EXPECT_EQ(101, response->headers->response_code()); 14389 EXPECT_EQ(101, response->headers->response_code());
14395 14390
14396 trans.reset(); 14391 trans.reset();
14397 session->CloseAllConnections(); 14392 session->CloseAllConnections();
14398 } 14393 }
14399 14394
14400 } // namespace net 14395 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698