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

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: 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
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 7921 matching lines...) Expand 10 before | Expand all | Expand 10 after
7932 true, 7932 true,
7933 }, 7933 },
7934 { 7934 {
7935 "", // unused 7935 "", // unused
7936 "http://host.with.alternate/direct", 7936 "http://host.with.alternate/direct",
7937 "ssl/host.with.alternate:443", 7937 "ssl/host.with.alternate:443",
7938 true, 7938 true,
7939 }, 7939 },
7940 }; 7940 };
7941 7941
7942 session_deps_.use_alternate_protocols = true; 7942 session_deps_.use_alternative_services = true;
7943 7943
7944 for (size_t i = 0; i < arraysize(tests); ++i) { 7944 for (size_t i = 0; i < arraysize(tests); ++i) {
7945 session_deps_.proxy_service.reset( 7945 session_deps_.proxy_service.reset(
7946 ProxyService::CreateFixed(tests[i].proxy_server)); 7946 ProxyService::CreateFixed(tests[i].proxy_server));
7947 scoped_refptr<HttpNetworkSession> session( 7947 scoped_refptr<HttpNetworkSession> session(
7948 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 7948 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
7949 7949
7950 HttpNetworkSessionPeer peer(session); 7950 HttpNetworkSessionPeer peer(session);
7951 CaptureGroupNameTransportSocketPool* transport_conn_pool = 7951 CaptureGroupNameTransportSocketPool* transport_conn_pool =
7952 new CaptureGroupNameTransportSocketPool(NULL, NULL); 7952 new CaptureGroupNameTransportSocketPool(NULL, NULL);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
7995 }, 7995 },
7996 7996
7997 { 7997 {
7998 "http_proxy", 7998 "http_proxy",
7999 "ftp://ftp.google.com/http_proxy_normal", 7999 "ftp://ftp.google.com/http_proxy_normal",
8000 "ftp/ftp.google.com:21", 8000 "ftp/ftp.google.com:21",
8001 false, 8001 false,
8002 }, 8002 },
8003 }; 8003 };
8004 8004
8005 session_deps_.use_alternate_protocols = true; 8005 session_deps_.use_alternative_services = true;
8006 8006
8007 for (size_t i = 0; i < arraysize(tests); ++i) { 8007 for (size_t i = 0; i < arraysize(tests); ++i) {
8008 session_deps_.proxy_service.reset( 8008 session_deps_.proxy_service.reset(
8009 ProxyService::CreateFixed(tests[i].proxy_server)); 8009 ProxyService::CreateFixed(tests[i].proxy_server));
8010 scoped_refptr<HttpNetworkSession> session( 8010 scoped_refptr<HttpNetworkSession> session(
8011 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8011 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8012 8012
8013 HttpNetworkSessionPeer peer(session); 8013 HttpNetworkSessionPeer peer(session);
8014 8014
8015 HostPortPair proxy_host("http_proxy", 80); 8015 HostPortPair proxy_host("http_proxy", 80);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
8065 }, 8065 },
8066 8066
8067 { 8067 {
8068 "socks4://socks_proxy:1080", 8068 "socks4://socks_proxy:1080",
8069 "http://host.with.alternate/direct", 8069 "http://host.with.alternate/direct",
8070 "socks4/ssl/host.with.alternate:443", 8070 "socks4/ssl/host.with.alternate:443",
8071 true, 8071 true,
8072 }, 8072 },
8073 }; 8073 };
8074 8074
8075 session_deps_.use_alternate_protocols = true; 8075 session_deps_.use_alternative_services = true;
8076 8076
8077 for (size_t i = 0; i < arraysize(tests); ++i) { 8077 for (size_t i = 0; i < arraysize(tests); ++i) {
8078 session_deps_.proxy_service.reset( 8078 session_deps_.proxy_service.reset(
8079 ProxyService::CreateFixed(tests[i].proxy_server)); 8079 ProxyService::CreateFixed(tests[i].proxy_server));
8080 scoped_refptr<HttpNetworkSession> session( 8080 scoped_refptr<HttpNetworkSession> session(
8081 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8081 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8082 8082
8083 HttpNetworkSessionPeer peer(session); 8083 HttpNetworkSessionPeer peer(session);
8084 8084
8085 HostPortPair proxy_host("socks_proxy", 1080); 8085 HostPortPair proxy_host("socks_proxy", 1080);
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
8720 EXPECT_EQ(ERR_IO_PENDING, rv); 8720 EXPECT_EQ(ERR_IO_PENDING, rv);
8721 rv = callback4.WaitForResult(); 8721 rv = callback4.WaitForResult();
8722 EXPECT_EQ(OK, rv); 8722 EXPECT_EQ(OK, rv);
8723 response = trans->GetResponseInfo(); 8723 response = trans->GetResponseInfo();
8724 ASSERT_TRUE(response != NULL); 8724 ASSERT_TRUE(response != NULL);
8725 EXPECT_TRUE(response->auth_challenge.get() == NULL); 8725 EXPECT_TRUE(response->auth_challenge.get() == NULL);
8726 } 8726 }
8727 8727
8728 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { 8728 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) {
8729 session_deps_.next_protos = SpdyNextProtos(); 8729 session_deps_.next_protos = SpdyNextProtos();
8730 session_deps_.use_alternate_protocols = true; 8730 session_deps_.use_alternative_services = true;
8731 8731
8732 std::string alternative_service_http_header = 8732 std::string alternative_service_http_header =
8733 GetAlternativeServiceHttpHeader(); 8733 GetAlternativeServiceHttpHeader();
8734 8734
8735 MockRead data_reads[] = { 8735 MockRead data_reads[] = {
8736 MockRead("HTTP/1.1 200 OK\r\n"), 8736 MockRead("HTTP/1.1 200 OK\r\n"),
8737 MockRead(alternative_service_http_header.c_str()), 8737 MockRead(alternative_service_http_header.c_str()),
8738 MockRead("\r\n"), 8738 MockRead("\r\n"),
8739 MockRead("hello world"), 8739 MockRead("hello world"),
8740 MockRead(SYNCHRONOUS, OK), 8740 MockRead(SYNCHRONOUS, OK),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
8782 http_server_properties.GetAlternativeServices(http_host_port_pair); 8782 http_server_properties.GetAlternativeServices(http_host_port_pair);
8783 ASSERT_EQ(1u, alternative_service_vector.size()); 8783 ASSERT_EQ(1u, alternative_service_vector.size());
8784 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), 8784 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()),
8785 alternative_service_vector[0].protocol); 8785 alternative_service_vector[0].protocol);
8786 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 8786 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
8787 EXPECT_EQ(443, alternative_service_vector[0].port); 8787 EXPECT_EQ(443, alternative_service_vector[0].port);
8788 } 8788 }
8789 8789
8790 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { 8790 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) {
8791 session_deps_.next_protos = SpdyNextProtos(); 8791 session_deps_.next_protos = SpdyNextProtos();
8792 session_deps_.use_alternate_protocols = true; 8792 session_deps_.use_alternative_services = true;
8793 8793
8794 MockRead data_reads[] = { 8794 MockRead data_reads[] = {
8795 MockRead("HTTP/1.1 200 OK\r\n"), 8795 MockRead("HTTP/1.1 200 OK\r\n"),
8796 MockRead("Alt-Svc: "), 8796 MockRead("Alt-Svc: "),
8797 MockRead(GetAlternateProtocolFromParam()), 8797 MockRead(GetAlternateProtocolFromParam()),
8798 MockRead("=\"www.example.com:443\";p=1.0,"), 8798 MockRead("=\"www.example.com:443\";p=1.0,"),
8799 MockRead("quic=\":1234\"\r\n\r\n"), 8799 MockRead("quic=\":1234\"\r\n\r\n"),
8800 MockRead("hello world"), 8800 MockRead("hello world"),
8801 MockRead(SYNCHRONOUS, OK), 8801 MockRead(SYNCHRONOUS, OK),
8802 }; 8802 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
8846 alternative_service_vector[0].protocol); 8846 alternative_service_vector[0].protocol);
8847 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 8847 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
8848 EXPECT_EQ(443, alternative_service_vector[0].port); 8848 EXPECT_EQ(443, alternative_service_vector[0].port);
8849 EXPECT_EQ(QUIC, alternative_service_vector[1].protocol); 8849 EXPECT_EQ(QUIC, alternative_service_vector[1].protocol);
8850 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); 8850 EXPECT_EQ("www.example.org", alternative_service_vector[1].host);
8851 EXPECT_EQ(1234, alternative_service_vector[1].port); 8851 EXPECT_EQ(1234, alternative_service_vector[1].port);
8852 } 8852 }
8853 8853
8854 TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { 8854 TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
8855 session_deps_.next_protos = SpdyNextProtos(); 8855 session_deps_.next_protos = SpdyNextProtos();
8856 session_deps_.use_alternate_protocols = true; 8856 session_deps_.use_alternative_services = true;
8857 8857
8858 std::string alternate_protocol_http_header = 8858 std::string alternate_protocol_http_header =
8859 GetAlternateProtocolHttpHeader(); 8859 GetAlternateProtocolHttpHeader();
8860 8860
8861 MockRead data_reads[] = { 8861 MockRead data_reads[] = {
8862 MockRead("HTTP/1.1 200 OK\r\n"), 8862 MockRead("HTTP/1.1 200 OK\r\n"),
8863 MockRead(alternate_protocol_http_header.c_str()), 8863 MockRead(alternate_protocol_http_header.c_str()),
8864 MockRead("\r\n"), 8864 MockRead("\r\n"),
8865 MockRead("hello world"), 8865 MockRead("hello world"),
8866 MockRead(SYNCHRONOUS, OK), 8866 MockRead(SYNCHRONOUS, OK),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8907 alternative_service_vector = 8907 alternative_service_vector =
8908 http_server_properties.GetAlternativeServices(http_host_port_pair); 8908 http_server_properties.GetAlternativeServices(http_host_port_pair);
8909 ASSERT_EQ(1u, alternative_service_vector.size()); 8909 ASSERT_EQ(1u, alternative_service_vector.size());
8910 EXPECT_EQ(443, alternative_service_vector[0].port); 8910 EXPECT_EQ(443, alternative_service_vector[0].port);
8911 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), 8911 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()),
8912 alternative_service_vector[0].protocol); 8912 alternative_service_vector[0].protocol);
8913 } 8913 }
8914 8914
8915 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) { 8915 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) {
8916 session_deps_.next_protos = SpdyNextProtos(); 8916 session_deps_.next_protos = SpdyNextProtos();
8917 session_deps_.use_alternate_protocols = true; 8917 session_deps_.use_alternative_services = true;
8918 8918
8919 MockRead data_reads[] = { 8919 MockRead data_reads[] = {
8920 MockRead("HTTP/1.1 200 OK\r\n"), 8920 MockRead("HTTP/1.1 200 OK\r\n"),
8921 MockRead("Alternate-Protocol: \r\n\r\n"), 8921 MockRead("Alternate-Protocol: \r\n\r\n"),
8922 MockRead("hello world"), 8922 MockRead("hello world"),
8923 MockRead(SYNCHRONOUS, OK), 8923 MockRead(SYNCHRONOUS, OK),
8924 }; 8924 };
8925 8925
8926 HttpRequestInfo request; 8926 HttpRequestInfo request;
8927 request.method = "GET"; 8927 request.method = "GET";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8968 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 8968 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
8969 EXPECT_EQ("hello world", response_data); 8969 EXPECT_EQ("hello world", response_data);
8970 8970
8971 alternative_service_vector = 8971 alternative_service_vector =
8972 http_server_properties.GetAlternativeServices(http_host_port_pair); 8972 http_server_properties.GetAlternativeServices(http_host_port_pair);
8973 EXPECT_TRUE(alternative_service_vector.empty()); 8973 EXPECT_TRUE(alternative_service_vector.empty());
8974 } 8974 }
8975 8975
8976 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) { 8976 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) {
8977 session_deps_.next_protos = SpdyNextProtos(); 8977 session_deps_.next_protos = SpdyNextProtos();
8978 session_deps_.use_alternate_protocols = true; 8978 session_deps_.use_alternative_services = true;
8979 8979
8980 std::string alternative_service_http_header = 8980 std::string alternative_service_http_header =
8981 GetAlternativeServiceHttpHeader(); 8981 GetAlternativeServiceHttpHeader();
8982 std::string alternate_protocol_http_header = GetAlternateProtocolHttpHeader(); 8982 std::string alternate_protocol_http_header = GetAlternateProtocolHttpHeader();
8983 8983
8984 MockRead data_reads[] = { 8984 MockRead data_reads[] = {
8985 MockRead("HTTP/1.1 200 OK\r\n"), 8985 MockRead("HTTP/1.1 200 OK\r\n"),
8986 MockRead(alternative_service_http_header.c_str()), 8986 MockRead(alternative_service_http_header.c_str()),
8987 MockRead(alternate_protocol_http_header.c_str()), 8987 MockRead(alternate_protocol_http_header.c_str()),
8988 MockRead("\r\n"), 8988 MockRead("\r\n"),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
9032 http_server_properties.GetAlternativeServices(http_host_port_pair); 9032 http_server_properties.GetAlternativeServices(http_host_port_pair);
9033 ASSERT_EQ(1u, alternative_service_vector.size()); 9033 ASSERT_EQ(1u, alternative_service_vector.size());
9034 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), 9034 EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()),
9035 alternative_service_vector[0].protocol); 9035 alternative_service_vector[0].protocol);
9036 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 9036 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
9037 EXPECT_EQ(443, alternative_service_vector[0].port); 9037 EXPECT_EQ(443, alternative_service_vector[0].port);
9038 } 9038 }
9039 9039
9040 TEST_P(HttpNetworkTransactionTest, 9040 TEST_P(HttpNetworkTransactionTest,
9041 MarkBrokenAlternateProtocolAndFallback) { 9041 MarkBrokenAlternateProtocolAndFallback) {
9042 session_deps_.use_alternate_protocols = true; 9042 session_deps_.use_alternative_services = true;
9043 9043
9044 HttpRequestInfo request; 9044 HttpRequestInfo request;
9045 request.method = "GET"; 9045 request.method = "GET";
9046 request.url = GURL("http://www.example.org/"); 9046 request.url = GURL("http://www.example.org/");
9047 request.load_flags = 0; 9047 request.load_flags = 0;
9048 9048
9049 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9049 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9050 StaticSocketDataProvider first_data; 9050 StaticSocketDataProvider first_data;
9051 first_data.set_connect_data(mock_connect); 9051 first_data.set_connect_data(mock_connect);
9052 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9052 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9092 EXPECT_EQ("hello world", response_data); 9092 EXPECT_EQ("hello world", response_data);
9093 9093
9094 const AlternativeServiceVector alternative_service_vector = 9094 const AlternativeServiceVector alternative_service_vector =
9095 http_server_properties->GetAlternativeServices(host_port_pair); 9095 http_server_properties->GetAlternativeServices(host_port_pair);
9096 ASSERT_EQ(1u, alternative_service_vector.size()); 9096 ASSERT_EQ(1u, alternative_service_vector.size());
9097 EXPECT_EQ(alternative_service, alternative_service_vector[0]); 9097 EXPECT_EQ(alternative_service, alternative_service_vector[0]);
9098 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken( 9098 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken(
9099 alternative_service_vector[0])); 9099 alternative_service_vector[0]));
9100 } 9100 }
9101 9101
9102 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9103 // to an unrestricted (port >= 1024) when the original traffic was on a
9104 // restricted port (port < 1024). Ensure that we can redirect in all other
9105 // cases.
9102 TEST_P(HttpNetworkTransactionTest, 9106 TEST_P(HttpNetworkTransactionTest,
9103 AlternateProtocolPortRestrictedBlocked) { 9107 AlternateProtocolPortRestrictedBlocked) {
9104 // Ensure that we're not allowed to redirect traffic via an alternate 9108 session_deps_.use_alternative_services = true;
9105 // protocol to an unrestricted (port >= 1024) when the original traffic was
9106 // on a restricted port (port < 1024). Ensure that we can redirect in all
9107 // other cases.
9108 session_deps_.use_alternate_protocols = true;
9109 9109
9110 HttpRequestInfo restricted_port_request; 9110 HttpRequestInfo restricted_port_request;
9111 restricted_port_request.method = "GET"; 9111 restricted_port_request.method = "GET";
9112 restricted_port_request.url = GURL("http://www.example.org:1023/"); 9112 restricted_port_request.url = GURL("http://www.example.org:1023/");
9113 restricted_port_request.load_flags = 0; 9113 restricted_port_request.load_flags = 0;
9114 9114
9115 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9115 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9116 StaticSocketDataProvider first_data; 9116 StaticSocketDataProvider first_data;
9117 first_data.set_connect_data(mock_connect); 9117 first_data.set_connect_data(mock_connect);
9118 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9118 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 25 matching lines...) Expand all
9144 TestCompletionCallback callback; 9144 TestCompletionCallback callback;
9145 9145
9146 int rv = trans->Start( 9146 int rv = trans->Start(
9147 &restricted_port_request, 9147 &restricted_port_request,
9148 callback.callback(), BoundNetLog()); 9148 callback.callback(), BoundNetLog());
9149 EXPECT_EQ(ERR_IO_PENDING, rv); 9149 EXPECT_EQ(ERR_IO_PENDING, rv);
9150 // Invalid change to unrestricted port should fail. 9150 // Invalid change to unrestricted port should fail.
9151 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); 9151 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult());
9152 } 9152 }
9153 9153
9154 // Ensure that we are allowed to redirect traffic via an alternate protocol to
9155 // an unrestricted (port >= 1024) when the original traffic was on a restricted
9156 // port (port < 1024) if we set |enable_user_alternate_protocol_ports|.
9154 TEST_P(HttpNetworkTransactionTest, 9157 TEST_P(HttpNetworkTransactionTest,
9155 AlternateProtocolPortRestrictedPermitted) { 9158 AlternateProtocolPortRestrictedPermitted) {
9156 // Ensure that we're allowed to redirect traffic via an alternate 9159 session_deps_.use_alternative_services = true;
9157 // protocol to an unrestricted (port >= 1024) when the original traffic was
9158 // on a restricted port (port < 1024) if we set
9159 // enable_user_alternate_protocol_ports.
9160
9161 session_deps_.use_alternate_protocols = true;
9162 session_deps_.enable_user_alternate_protocol_ports = true; 9160 session_deps_.enable_user_alternate_protocol_ports = true;
9163 9161
9164 HttpRequestInfo restricted_port_request; 9162 HttpRequestInfo restricted_port_request;
9165 restricted_port_request.method = "GET"; 9163 restricted_port_request.method = "GET";
9166 restricted_port_request.url = GURL("http://www.example.org:1023/"); 9164 restricted_port_request.url = GURL("http://www.example.org:1023/");
9167 restricted_port_request.load_flags = 0; 9165 restricted_port_request.load_flags = 0;
9168 9166
9169 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9167 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9170 StaticSocketDataProvider first_data; 9168 StaticSocketDataProvider first_data;
9171 first_data.set_connect_data(mock_connect); 9169 first_data.set_connect_data(mock_connect);
(...skipping 25 matching lines...) Expand all
9197 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9195 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9198 TestCompletionCallback callback; 9196 TestCompletionCallback callback;
9199 9197
9200 EXPECT_EQ(ERR_IO_PENDING, trans->Start( 9198 EXPECT_EQ(ERR_IO_PENDING, trans->Start(
9201 &restricted_port_request, 9199 &restricted_port_request,
9202 callback.callback(), BoundNetLog())); 9200 callback.callback(), BoundNetLog()));
9203 // Change to unrestricted port should succeed. 9201 // Change to unrestricted port should succeed.
9204 EXPECT_EQ(OK, callback.WaitForResult()); 9202 EXPECT_EQ(OK, callback.WaitForResult());
9205 } 9203 }
9206 9204
9205 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9206 // to an unrestricted (port >= 1024) when the original traffic was on a
9207 // restricted port (port < 1024). Ensure that we can redirect in all other
9208 // cases.
9207 TEST_P(HttpNetworkTransactionTest, 9209 TEST_P(HttpNetworkTransactionTest,
9208 AlternateProtocolPortRestrictedAllowed) { 9210 AlternateProtocolPortRestrictedAllowed) {
9209 // Ensure that we're not allowed to redirect traffic via an alternate 9211 session_deps_.use_alternative_services = true;
9210 // protocol to an unrestricted (port >= 1024) when the original traffic was
9211 // on a restricted port (port < 1024). Ensure that we can redirect in all
9212 // other cases.
9213 session_deps_.use_alternate_protocols = true;
9214 9212
9215 HttpRequestInfo restricted_port_request; 9213 HttpRequestInfo restricted_port_request;
9216 restricted_port_request.method = "GET"; 9214 restricted_port_request.method = "GET";
9217 restricted_port_request.url = GURL("http://www.example.org:1023/"); 9215 restricted_port_request.url = GURL("http://www.example.org:1023/");
9218 restricted_port_request.load_flags = 0; 9216 restricted_port_request.load_flags = 0;
9219 9217
9220 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9218 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9221 StaticSocketDataProvider first_data; 9219 StaticSocketDataProvider first_data;
9222 first_data.set_connect_data(mock_connect); 9220 first_data.set_connect_data(mock_connect);
9223 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9221 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 25 matching lines...) Expand all
9249 TestCompletionCallback callback; 9247 TestCompletionCallback callback;
9250 9248
9251 int rv = trans->Start( 9249 int rv = trans->Start(
9252 &restricted_port_request, 9250 &restricted_port_request,
9253 callback.callback(), BoundNetLog()); 9251 callback.callback(), BoundNetLog());
9254 EXPECT_EQ(ERR_IO_PENDING, rv); 9252 EXPECT_EQ(ERR_IO_PENDING, rv);
9255 // Valid change to restricted port should pass. 9253 // Valid change to restricted port should pass.
9256 EXPECT_EQ(OK, callback.WaitForResult()); 9254 EXPECT_EQ(OK, callback.WaitForResult());
9257 } 9255 }
9258 9256
9257 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9258 // to an unrestricted (port >= 1024) when the original traffic was on a
9259 // restricted port (port < 1024). Ensure that we can redirect in all other
9260 // cases.
9259 TEST_P(HttpNetworkTransactionTest, 9261 TEST_P(HttpNetworkTransactionTest,
9260 AlternateProtocolPortUnrestrictedAllowed1) { 9262 AlternateProtocolPortUnrestrictedAllowed1) {
9261 // Ensure that we're not allowed to redirect traffic via an alternate 9263 session_deps_.use_alternative_services = true;
9262 // protocol to an unrestricted (port >= 1024) when the original traffic was
9263 // on a restricted port (port < 1024). Ensure that we can redirect in all
9264 // other cases.
9265 session_deps_.use_alternate_protocols = true;
9266 9264
9267 HttpRequestInfo unrestricted_port_request; 9265 HttpRequestInfo unrestricted_port_request;
9268 unrestricted_port_request.method = "GET"; 9266 unrestricted_port_request.method = "GET";
9269 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); 9267 unrestricted_port_request.url = GURL("http://www.example.org:1024/");
9270 unrestricted_port_request.load_flags = 0; 9268 unrestricted_port_request.load_flags = 0;
9271 9269
9272 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9270 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9273 StaticSocketDataProvider first_data; 9271 StaticSocketDataProvider first_data;
9274 first_data.set_connect_data(mock_connect); 9272 first_data.set_connect_data(mock_connect);
9275 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9273 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 24 matching lines...) Expand all
9300 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9298 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9301 TestCompletionCallback callback; 9299 TestCompletionCallback callback;
9302 9300
9303 int rv = trans->Start( 9301 int rv = trans->Start(
9304 &unrestricted_port_request, callback.callback(), BoundNetLog()); 9302 &unrestricted_port_request, callback.callback(), BoundNetLog());
9305 EXPECT_EQ(ERR_IO_PENDING, rv); 9303 EXPECT_EQ(ERR_IO_PENDING, rv);
9306 // Valid change to restricted port should pass. 9304 // Valid change to restricted port should pass.
9307 EXPECT_EQ(OK, callback.WaitForResult()); 9305 EXPECT_EQ(OK, callback.WaitForResult());
9308 } 9306 }
9309 9307
9308 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9309 // to an unrestricted (port >= 1024) when the original traffic was on a
9310 // restricted port (port < 1024). Ensure that we can redirect in all other
9311 // cases.
9310 TEST_P(HttpNetworkTransactionTest, 9312 TEST_P(HttpNetworkTransactionTest,
9311 AlternateProtocolPortUnrestrictedAllowed2) { 9313 AlternateProtocolPortUnrestrictedAllowed2) {
9312 // Ensure that we're not allowed to redirect traffic via an alternate 9314 session_deps_.use_alternative_services = true;
9313 // protocol to an unrestricted (port >= 1024) when the original traffic was
9314 // on a restricted port (port < 1024). Ensure that we can redirect in all
9315 // other cases.
9316 session_deps_.use_alternate_protocols = true;
9317 9315
9318 HttpRequestInfo unrestricted_port_request; 9316 HttpRequestInfo unrestricted_port_request;
9319 unrestricted_port_request.method = "GET"; 9317 unrestricted_port_request.method = "GET";
9320 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); 9318 unrestricted_port_request.url = GURL("http://www.example.org:1024/");
9321 unrestricted_port_request.load_flags = 0; 9319 unrestricted_port_request.load_flags = 0;
9322 9320
9323 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 9321 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
9324 StaticSocketDataProvider first_data; 9322 StaticSocketDataProvider first_data;
9325 first_data.set_connect_data(mock_connect); 9323 first_data.set_connect_data(mock_connect);
9326 session_deps_.socket_factory->AddSocketDataProvider(&first_data); 9324 session_deps_.socket_factory->AddSocketDataProvider(&first_data);
(...skipping 24 matching lines...) Expand all
9351 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9349 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9352 TestCompletionCallback callback; 9350 TestCompletionCallback callback;
9353 9351
9354 int rv = trans->Start( 9352 int rv = trans->Start(
9355 &unrestricted_port_request, callback.callback(), BoundNetLog()); 9353 &unrestricted_port_request, callback.callback(), BoundNetLog());
9356 EXPECT_EQ(ERR_IO_PENDING, rv); 9354 EXPECT_EQ(ERR_IO_PENDING, rv);
9357 // Valid change to an unrestricted port should pass. 9355 // Valid change to an unrestricted port should pass.
9358 EXPECT_EQ(OK, callback.WaitForResult()); 9356 EXPECT_EQ(OK, callback.WaitForResult());
9359 } 9357 }
9360 9358
9359 // Ensure that we are not allowed to redirect traffic via an alternate protocol
9360 // to an unsafe port, and that we resume the second HttpStreamFactoryImpl::Job
9361 // once the alternate protocol request fails.
9361 TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) { 9362 TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) {
9362 // Ensure that we're not allowed to redirect traffic via an alternate 9363 session_deps_.use_alternative_services = true;
9363 // protocol to an unsafe port, and that we resume the second
9364 // HttpStreamFactoryImpl::Job once the alternate protocol request fails.
9365 session_deps_.use_alternate_protocols = true;
9366 9364
9367 HttpRequestInfo request; 9365 HttpRequestInfo request;
9368 request.method = "GET"; 9366 request.method = "GET";
9369 request.url = GURL("http://www.example.org/"); 9367 request.url = GURL("http://www.example.org/");
9370 request.load_flags = 0; 9368 request.load_flags = 0;
9371 9369
9372 // The alternate protocol request will error out before we attempt to connect, 9370 // The alternate protocol request will error out before we attempt to connect,
9373 // so only the standard HTTP request will try to connect. 9371 // so only the standard HTTP request will try to connect.
9374 MockRead data_reads[] = { 9372 MockRead data_reads[] = {
9375 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 9373 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
(...skipping 18 matching lines...) Expand all
9394 9392
9395 scoped_ptr<HttpTransaction> trans( 9393 scoped_ptr<HttpTransaction> trans(
9396 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9394 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9397 TestCompletionCallback callback; 9395 TestCompletionCallback callback;
9398 9396
9399 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9397 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9400 EXPECT_EQ(ERR_IO_PENDING, rv); 9398 EXPECT_EQ(ERR_IO_PENDING, rv);
9401 // The HTTP request should succeed. 9399 // The HTTP request should succeed.
9402 EXPECT_EQ(OK, callback.WaitForResult()); 9400 EXPECT_EQ(OK, callback.WaitForResult());
9403 9401
9404 // Disable alternate protocol before the asserts.
9405 // HttpStreamFactory::set_use_alternate_protocols(false);
Ryan Hamilton 2015/08/12 03:31:15 What's the story behind this change?
Bence 2015/08/12 12:02:10 I have no idea. This line got commented out at ht
9406
9407 const HttpResponseInfo* response = trans->GetResponseInfo(); 9402 const HttpResponseInfo* response = trans->GetResponseInfo();
9408 ASSERT_TRUE(response != NULL); 9403 ASSERT_TRUE(response != NULL);
9409 ASSERT_TRUE(response->headers.get() != NULL); 9404 ASSERT_TRUE(response->headers.get() != NULL);
9410 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9405 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9411 9406
9412 std::string response_data; 9407 std::string response_data;
9413 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9408 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9414 EXPECT_EQ("hello world", response_data); 9409 EXPECT_EQ("hello world", response_data);
9415 } 9410 }
9416 9411
9417 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { 9412 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) {
9418 session_deps_.use_alternate_protocols = true; 9413 session_deps_.use_alternative_services = true;
9419 session_deps_.next_protos = SpdyNextProtos(); 9414 session_deps_.next_protos = SpdyNextProtos();
9420 9415
9421 HttpRequestInfo request; 9416 HttpRequestInfo request;
9422 request.method = "GET"; 9417 request.method = "GET";
9423 request.url = GURL("http://www.example.org/"); 9418 request.url = GURL("http://www.example.org/");
9424 request.load_flags = 0; 9419 request.load_flags = 0;
9425 9420
9426 std::string alternate_protocol_http_header = 9421 std::string alternate_protocol_http_header =
9427 GetAlternateProtocolHttpHeader(); 9422 GetAlternateProtocolHttpHeader();
9428 9423
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
9496 ASSERT_TRUE(response->headers.get() != NULL); 9491 ASSERT_TRUE(response->headers.get() != NULL);
9497 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9492 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9498 EXPECT_TRUE(response->was_fetched_via_spdy); 9493 EXPECT_TRUE(response->was_fetched_via_spdy);
9499 EXPECT_TRUE(response->was_npn_negotiated); 9494 EXPECT_TRUE(response->was_npn_negotiated);
9500 9495
9501 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9496 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9502 EXPECT_EQ("hello!", response_data); 9497 EXPECT_EQ("hello!", response_data);
9503 } 9498 }
9504 9499
9505 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { 9500 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) {
9506 session_deps_.use_alternate_protocols = true; 9501 session_deps_.use_alternative_services = true;
9507 session_deps_.next_protos = SpdyNextProtos(); 9502 session_deps_.next_protos = SpdyNextProtos();
9508 9503
9509 HttpRequestInfo request; 9504 HttpRequestInfo request;
9510 request.method = "GET"; 9505 request.method = "GET";
9511 request.url = GURL("http://www.example.org/"); 9506 request.url = GURL("http://www.example.org/");
9512 request.load_flags = 0; 9507 request.load_flags = 0;
9513 9508
9514 std::string alternate_protocol_http_header = 9509 std::string alternate_protocol_http_header =
9515 GetAlternateProtocolHttpHeader(); 9510 GetAlternateProtocolHttpHeader();
9516 9511
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
9613 ASSERT_TRUE(response != NULL); 9608 ASSERT_TRUE(response != NULL);
9614 ASSERT_TRUE(response->headers.get() != NULL); 9609 ASSERT_TRUE(response->headers.get() != NULL);
9615 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9610 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9616 EXPECT_TRUE(response->was_fetched_via_spdy); 9611 EXPECT_TRUE(response->was_fetched_via_spdy);
9617 EXPECT_TRUE(response->was_npn_negotiated); 9612 EXPECT_TRUE(response->was_npn_negotiated);
9618 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); 9613 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data));
9619 EXPECT_EQ("hello!", response_data); 9614 EXPECT_EQ("hello!", response_data);
9620 } 9615 }
9621 9616
9622 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { 9617 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) {
9623 session_deps_.use_alternate_protocols = true; 9618 session_deps_.use_alternative_services = true;
9624 session_deps_.next_protos = SpdyNextProtos(); 9619 session_deps_.next_protos = SpdyNextProtos();
9625 9620
9626 HttpRequestInfo request; 9621 HttpRequestInfo request;
9627 request.method = "GET"; 9622 request.method = "GET";
9628 request.url = GURL("http://www.example.org/"); 9623 request.url = GURL("http://www.example.org/");
9629 request.load_flags = 0; 9624 request.load_flags = 0;
9630 9625
9631 std::string alternate_protocol_http_header = 9626 std::string alternate_protocol_http_header =
9632 GetAlternateProtocolHttpHeader(); 9627 GetAlternateProtocolHttpHeader();
9633 9628
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
9740 resolver->reset(new ForwardingProxyResolver(resolver_)); 9735 resolver->reset(new ForwardingProxyResolver(resolver_));
9741 return OK; 9736 return OK;
9742 } 9737 }
9743 9738
9744 private: 9739 private:
9745 ProxyResolver* resolver_; 9740 ProxyResolver* resolver_;
9746 }; 9741 };
9747 9742
9748 TEST_P(HttpNetworkTransactionTest, 9743 TEST_P(HttpNetworkTransactionTest,
9749 UseAlternateProtocolForTunneledNpnSpdy) { 9744 UseAlternateProtocolForTunneledNpnSpdy) {
9750 session_deps_.use_alternate_protocols = true; 9745 session_deps_.use_alternative_services = true;
9751 session_deps_.next_protos = SpdyNextProtos(); 9746 session_deps_.next_protos = SpdyNextProtos();
9752 9747
9753 ProxyConfig proxy_config; 9748 ProxyConfig proxy_config;
9754 proxy_config.set_auto_detect(true); 9749 proxy_config.set_auto_detect(true);
9755 proxy_config.set_pac_url(GURL("http://fooproxyurl")); 9750 proxy_config.set_pac_url(GURL("http://fooproxyurl"));
9756 9751
9757 CapturingProxyResolver capturing_proxy_resolver; 9752 CapturingProxyResolver capturing_proxy_resolver;
9758 session_deps_.proxy_service.reset(new ProxyService( 9753 session_deps_.proxy_service.reset(new ProxyService(
9759 new ProxyConfigServiceFixed(proxy_config), 9754 new ProxyConfigServiceFixed(proxy_config),
9760 make_scoped_ptr( 9755 make_scoped_ptr(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
9866 capturing_proxy_resolver.resolved()[1].spec()); 9861 capturing_proxy_resolver.resolved()[1].spec());
9867 9862
9868 LoadTimingInfo load_timing_info; 9863 LoadTimingInfo load_timing_info;
9869 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); 9864 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info));
9870 TestLoadTimingNotReusedWithPac(load_timing_info, 9865 TestLoadTimingNotReusedWithPac(load_timing_info,
9871 CONNECT_TIMING_HAS_SSL_TIMES); 9866 CONNECT_TIMING_HAS_SSL_TIMES);
9872 } 9867 }
9873 9868
9874 TEST_P(HttpNetworkTransactionTest, 9869 TEST_P(HttpNetworkTransactionTest,
9875 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { 9870 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) {
9876 session_deps_.use_alternate_protocols = true; 9871 session_deps_.use_alternative_services = true;
9877 session_deps_.next_protos = SpdyNextProtos(); 9872 session_deps_.next_protos = SpdyNextProtos();
9878 9873
9879 HttpRequestInfo request; 9874 HttpRequestInfo request;
9880 request.method = "GET"; 9875 request.method = "GET";
9881 request.url = GURL("http://www.example.org/"); 9876 request.url = GURL("http://www.example.org/");
9882 request.load_flags = 0; 9877 request.load_flags = 0;
9883 9878
9884 std::string alternate_protocol_http_header = 9879 std::string alternate_protocol_http_header =
9885 GetAlternateProtocolHttpHeader(); 9880 GetAlternateProtocolHttpHeader();
9886 9881
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
10564 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); 10559 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback());
10565 EXPECT_EQ(0, rv); 10560 EXPECT_EQ(0, rv);
10566 10561
10567 // Finally, the socket is released to the group. 10562 // Finally, the socket is released to the group.
10568 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); 10563 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup));
10569 } 10564 }
10570 10565
10571 // This tests the case that a request is issued via http instead of spdy after 10566 // This tests the case that a request is issued via http instead of spdy after
10572 // npn is negotiated. 10567 // npn is negotiated.
10573 TEST_P(HttpNetworkTransactionTest, NpnWithHttpOverSSL) { 10568 TEST_P(HttpNetworkTransactionTest, NpnWithHttpOverSSL) {
10574 session_deps_.use_alternate_protocols = true; 10569 session_deps_.use_alternative_services = true;
10575 NextProtoVector next_protos; 10570 NextProtoVector next_protos;
10576 next_protos.push_back(kProtoHTTP11); 10571 next_protos.push_back(kProtoHTTP11);
10577 session_deps_.next_protos = next_protos; 10572 session_deps_.next_protos = next_protos;
10578 10573
10579 HttpRequestInfo request; 10574 HttpRequestInfo request;
10580 request.method = "GET"; 10575 request.method = "GET";
10581 request.url = GURL("https://www.example.org/"); 10576 request.url = GURL("https://www.example.org/");
10582 request.load_flags = 0; 10577 request.load_flags = 0;
10583 10578
10584 MockWrite data_writes[] = { 10579 MockWrite data_writes[] = {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
10625 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10620 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10626 10621
10627 std::string response_data; 10622 std::string response_data;
10628 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10623 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10629 EXPECT_EQ("hello world", response_data); 10624 EXPECT_EQ("hello world", response_data);
10630 10625
10631 EXPECT_FALSE(response->was_fetched_via_spdy); 10626 EXPECT_FALSE(response->was_fetched_via_spdy);
10632 EXPECT_TRUE(response->was_npn_negotiated); 10627 EXPECT_TRUE(response->was_npn_negotiated);
10633 } 10628 }
10634 10629
10630 // Simulate the SSL handshake completing with an NPN negotiation followed by an
10631 // immediate server closing of the socket.
10632 // Regression test for https://crbug.com/46369.
10635 TEST_P(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { 10633 TEST_P(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) {
10636 // Simulate the SSL handshake completing with an NPN negotiation 10634 session_deps_.use_alternative_services = true;
10637 // followed by an immediate server closing of the socket.
10638 // Fix crash: http://crbug.com/46369
10639 session_deps_.use_alternate_protocols = true;
10640 session_deps_.next_protos = SpdyNextProtos(); 10635 session_deps_.next_protos = SpdyNextProtos();
10641 10636
10642 HttpRequestInfo request; 10637 HttpRequestInfo request;
10643 request.method = "GET"; 10638 request.method = "GET";
10644 request.url = GURL("https://www.example.org/"); 10639 request.url = GURL("https://www.example.org/");
10645 request.load_flags = 0; 10640 request.load_flags = 0;
10646 10641
10647 SSLSocketDataProvider ssl(ASYNC, OK); 10642 SSLSocketDataProvider ssl(ASYNC, OK);
10648 ssl.SetNextProto(GetParam()); 10643 ssl.SetNextProto(GetParam());
10649 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 10644 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
10687 std::string* auth_token) override { 10682 std::string* auth_token) override {
10688 *url_ = request->url; 10683 *url_ = request->url;
10689 return HttpAuthHandlerMock::GenerateAuthTokenImpl( 10684 return HttpAuthHandlerMock::GenerateAuthTokenImpl(
10690 credentials, request, callback, auth_token); 10685 credentials, request, callback, auth_token);
10691 } 10686 }
10692 10687
10693 private: 10688 private:
10694 GURL* url_; 10689 GURL* url_;
10695 }; 10690 };
10696 10691
10692 // This test ensures that the URL passed into the proxy is upgraded to https
10693 // when doing an Alternate Protocol upgrade.
10697 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { 10694 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) {
10698 // This test ensures that the URL passed into the proxy is upgraded 10695 session_deps_.use_alternative_services = true;
10699 // to https when doing an Alternate Protocol upgrade.
10700 session_deps_.use_alternate_protocols = true;
10701 session_deps_.next_protos = SpdyNextProtos(); 10696 session_deps_.next_protos = SpdyNextProtos();
10702 10697
10703 session_deps_.proxy_service.reset( 10698 session_deps_.proxy_service.reset(
10704 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 10699 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
10705 TestNetLog net_log; 10700 TestNetLog net_log;
10706 session_deps_.net_log = &net_log; 10701 session_deps_.net_log = &net_log;
10707 GURL request_url; 10702 GURL request_url;
10708 { 10703 {
10709 HttpAuthHandlerMock::Factory* auth_factory = 10704 HttpAuthHandlerMock::Factory* auth_factory =
10710 new HttpAuthHandlerMock::Factory(); 10705 new HttpAuthHandlerMock::Factory();
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
11547 // Now that the new handshake has failed, ensure that the client 11542 // Now that the new handshake has failed, ensure that the client
11548 // certificate was removed from the client auth cache. 11543 // certificate was removed from the client auth cache.
11549 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( 11544 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup(
11550 HostPortPair("proxy", 70), &client_cert)); 11545 HostPortPair("proxy", 70), &client_cert));
11551 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( 11546 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup(
11552 HostPortPair("www.example.com", 443), &client_cert)); 11547 HostPortPair("www.example.com", 443), &client_cert));
11553 } 11548 }
11554 } 11549 }
11555 11550
11556 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) { 11551 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) {
11557 session_deps_.use_alternate_protocols = true; 11552 session_deps_.use_alternative_services = true;
11558 session_deps_.next_protos = SpdyNextProtos(); 11553 session_deps_.next_protos = SpdyNextProtos();
11559 11554
11560 // Set up a special HttpNetworkSession with a MockCachingHostResolver. 11555 // Set up a special HttpNetworkSession with a MockCachingHostResolver.
11561 session_deps_.host_resolver.reset(new MockCachingHostResolver()); 11556 session_deps_.host_resolver.reset(new MockCachingHostResolver());
11562 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11557 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11563 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11558 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11564 pool_peer.DisableDomainAuthenticationVerification(); 11559 pool_peer.DisableDomainAuthenticationVerification();
11565 11560
11566 SSLSocketDataProvider ssl(ASYNC, OK); 11561 SSLSocketDataProvider ssl(ASYNC, OK);
11567 ssl.SetNextProto(GetParam()); 11562 ssl.SetNextProto(GetParam());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
11646 ASSERT_TRUE(response != NULL); 11641 ASSERT_TRUE(response != NULL);
11647 ASSERT_TRUE(response->headers.get() != NULL); 11642 ASSERT_TRUE(response->headers.get() != NULL);
11648 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 11643 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
11649 EXPECT_TRUE(response->was_fetched_via_spdy); 11644 EXPECT_TRUE(response->was_fetched_via_spdy);
11650 EXPECT_TRUE(response->was_npn_negotiated); 11645 EXPECT_TRUE(response->was_npn_negotiated);
11651 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); 11646 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data));
11652 EXPECT_EQ("hello!", response_data); 11647 EXPECT_EQ("hello!", response_data);
11653 } 11648 }
11654 11649
11655 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { 11650 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) {
11656 session_deps_.use_alternate_protocols = true; 11651 session_deps_.use_alternative_services = true;
11657 session_deps_.next_protos = SpdyNextProtos(); 11652 session_deps_.next_protos = SpdyNextProtos();
11658 11653
11659 // Set up a special HttpNetworkSession with a MockCachingHostResolver. 11654 // Set up a special HttpNetworkSession with a MockCachingHostResolver.
11660 session_deps_.host_resolver.reset(new MockCachingHostResolver()); 11655 session_deps_.host_resolver.reset(new MockCachingHostResolver());
11661 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11656 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11662 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11657 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11663 pool_peer.DisableDomainAuthenticationVerification(); 11658 pool_peer.DisableDomainAuthenticationVerification();
11664 11659
11665 SSLSocketDataProvider ssl(ASYNC, OK); 11660 SSLSocketDataProvider ssl(ASYNC, OK);
11666 ssl.SetNextProto(GetParam()); 11661 ssl.SetNextProto(GetParam());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
11773 return &host_resolver_; 11768 return &host_resolver_;
11774 } 11769 }
11775 11770
11776 private: 11771 private:
11777 MockCachingHostResolver host_resolver_; 11772 MockCachingHostResolver host_resolver_;
11778 const HostPortPair host_port_; 11773 const HostPortPair host_port_;
11779 }; 11774 };
11780 11775
11781 TEST_P(HttpNetworkTransactionTest, 11776 TEST_P(HttpNetworkTransactionTest,
11782 UseIPConnectionPoolingWithHostCacheExpiration) { 11777 UseIPConnectionPoolingWithHostCacheExpiration) {
11783 session_deps_.use_alternate_protocols = true; 11778 session_deps_.use_alternative_services = true;
11784 session_deps_.next_protos = SpdyNextProtos(); 11779 session_deps_.next_protos = SpdyNextProtos();
11785 11780
11786 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. 11781 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver.
11787 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); 11782 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443));
11788 HttpNetworkSession::Params params = 11783 HttpNetworkSession::Params params =
11789 SpdySessionDependencies::CreateSessionParams(&session_deps_); 11784 SpdySessionDependencies::CreateSessionParams(&session_deps_);
11790 params.host_resolver = &host_resolver; 11785 params.host_resolver = &host_resolver;
11791 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11786 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11792 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); 11787 SpdySessionPoolPeer pool_peer(session->spdy_session_pool());
11793 pool_peer.DisableDomainAuthenticationVerification(); 11788 pool_peer.DisableDomainAuthenticationVerification();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
12032 SequencedSocketData data(vector_as_array(&reads), reads.size(), 12027 SequencedSocketData data(vector_as_array(&reads), reads.size(),
12033 vector_as_array(&writes), writes.size()); 12028 vector_as_array(&writes), writes.size());
12034 session_deps_.socket_factory->AddSocketDataProvider(&data); 12029 session_deps_.socket_factory->AddSocketDataProvider(&data);
12035 12030
12036 // Connection to the origin fails. 12031 // Connection to the origin fails.
12037 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 12032 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
12038 StaticSocketDataProvider data_refused; 12033 StaticSocketDataProvider data_refused;
12039 data_refused.set_connect_data(mock_connect); 12034 data_refused.set_connect_data(mock_connect);
12040 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12035 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12041 12036
12042 session_deps_.use_alternate_protocols = true; 12037 session_deps_.use_alternative_services = true;
12043 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12038 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12044 base::WeakPtr<HttpServerProperties> http_server_properties = 12039 base::WeakPtr<HttpServerProperties> http_server_properties =
12045 session->http_server_properties(); 12040 session->http_server_properties();
12046 AlternativeService alternative_service( 12041 AlternativeService alternative_service(
12047 AlternateProtocolFromNextProto(GetParam()), alternative); 12042 AlternateProtocolFromNextProto(GetParam()), alternative);
12048 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12043 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12049 http_server_properties->SetAlternativeService(origin, alternative_service, 12044 http_server_properties->SetAlternativeService(origin, alternative_service,
12050 1.0, expiration); 12045 1.0, expiration);
12051 12046
12052 // First request to alternative. 12047 // First request to alternative.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
12137 session_deps_.socket_factory->AddSocketDataProvider(&data); 12132 session_deps_.socket_factory->AddSocketDataProvider(&data);
12138 12133
12139 // This test documents that an alternate Job should not be used if HTTP/1.1 is 12134 // This test documents that an alternate Job should not be used if HTTP/1.1 is
12140 // negotiated. In order to test this, a failed connection to the origin is 12135 // negotiated. In order to test this, a failed connection to the origin is
12141 // mocked. This way the request relies on the alternate Job. 12136 // mocked. This way the request relies on the alternate Job.
12142 StaticSocketDataProvider data_refused; 12137 StaticSocketDataProvider data_refused;
12143 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 12138 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
12144 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12139 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12145 12140
12146 // Set up alternative service for origin. 12141 // Set up alternative service for origin.
12147 session_deps_.use_alternate_protocols = true; 12142 session_deps_.use_alternative_services = true;
12148 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12143 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12149 base::WeakPtr<HttpServerProperties> http_server_properties = 12144 base::WeakPtr<HttpServerProperties> http_server_properties =
12150 session->http_server_properties(); 12145 session->http_server_properties();
12151 AlternativeService alternative_service( 12146 AlternativeService alternative_service(
12152 AlternateProtocolFromNextProto(GetParam()), alternative); 12147 AlternateProtocolFromNextProto(GetParam()), alternative);
12153 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12148 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12154 http_server_properties->SetAlternativeService(origin, alternative_service, 12149 http_server_properties->SetAlternativeService(origin, alternative_service,
12155 1.0, expiration); 12150 1.0, expiration);
12156 12151
12157 scoped_ptr<HttpTransaction> trans( 12152 scoped_ptr<HttpTransaction> trans(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
12210 MockRead("HTTP/1.1 200 OK\r\n"), 12205 MockRead("HTTP/1.1 200 OK\r\n"),
12211 MockRead("Content-Type: text/html\r\n"), 12206 MockRead("Content-Type: text/html\r\n"),
12212 MockRead("Content-Length: 7\r\n\r\n"), 12207 MockRead("Content-Length: 7\r\n\r\n"),
12213 MockRead("another"), 12208 MockRead("another"),
12214 }; 12209 };
12215 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 12210 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
12216 http_writes, arraysize(http_writes)); 12211 http_writes, arraysize(http_writes));
12217 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 12212 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
12218 12213
12219 // Set up alternative service for origin. 12214 // Set up alternative service for origin.
12220 session_deps_.use_alternate_protocols = true; 12215 session_deps_.use_alternative_services = true;
12221 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12216 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12222 base::WeakPtr<HttpServerProperties> http_server_properties = 12217 base::WeakPtr<HttpServerProperties> http_server_properties =
12223 session->http_server_properties(); 12218 session->http_server_properties();
12224 AlternativeService alternative_service( 12219 AlternativeService alternative_service(
12225 AlternateProtocolFromNextProto(GetParam()), alternative); 12220 AlternateProtocolFromNextProto(GetParam()), alternative);
12226 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12221 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12227 http_server_properties->SetAlternativeService(origin, alternative_service, 12222 http_server_properties->SetAlternativeService(origin, alternative_service,
12228 1.0, expiration); 12223 1.0, expiration);
12229 12224
12230 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 12225 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
12319 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 12314 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
12320 12315
12321 // This test documents that an alternate Job should not pool to an already 12316 // This test documents that an alternate Job should not pool to an already
12322 // existing HTTP/1.1 connection. In order to test this, a failed connection 12317 // existing HTTP/1.1 connection. In order to test this, a failed connection
12323 // to the origin is mocked. This way |request2| relies on the alternate Job. 12318 // to the origin is mocked. This way |request2| relies on the alternate Job.
12324 StaticSocketDataProvider data_refused; 12319 StaticSocketDataProvider data_refused;
12325 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 12320 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
12326 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 12321 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
12327 12322
12328 // Set up alternative service for origin. 12323 // Set up alternative service for origin.
12329 session_deps_.use_alternate_protocols = true; 12324 session_deps_.use_alternative_services = true;
12330 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 12325 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
12331 base::WeakPtr<HttpServerProperties> http_server_properties = 12326 base::WeakPtr<HttpServerProperties> http_server_properties =
12332 session->http_server_properties(); 12327 session->http_server_properties();
12333 AlternativeService alternative_service( 12328 AlternativeService alternative_service(
12334 AlternateProtocolFromNextProto(GetParam()), alternative); 12329 AlternateProtocolFromNextProto(GetParam()), alternative);
12335 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 12330 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
12336 http_server_properties->SetAlternativeService(origin, alternative_service, 12331 http_server_properties->SetAlternativeService(origin, alternative_service,
12337 1.0, expiration); 12332 1.0, expiration);
12338 12333
12339 // First transaction to alternative to open an HTTP/1.1 socket. 12334 // First transaction to alternative to open an HTTP/1.1 socket.
(...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after
14397 ASSERT_TRUE(response); 14392 ASSERT_TRUE(response);
14398 ASSERT_TRUE(response->headers.get()); 14393 ASSERT_TRUE(response->headers.get());
14399 14394
14400 EXPECT_EQ(101, response->headers->response_code()); 14395 EXPECT_EQ(101, response->headers->response_code());
14401 14396
14402 trans.reset(); 14397 trans.reset();
14403 session->CloseAllConnections(); 14398 session->CloseAllConnections();
14404 } 14399 }
14405 14400
14406 } // namespace net 14401 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698