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

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

Issue 1878143005: SHP 4: Change AlternativeServiceMap to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SHP_3
Patch Set: fix a comment Created 4 years, 8 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 <stdint.h> 9 #include <stdint.h>
10 #include <limits> 10 #include <limits>
(...skipping 8784 matching lines...) Expand 10 before | Expand all | Expand 10 after
8795 NextProto next_proto, 8795 NextProto next_proto,
8796 SpdySessionDependencies* session_deps_) { 8796 SpdySessionDependencies* session_deps_) {
8797 scoped_ptr<HttpNetworkSession> session(CreateSession(session_deps_)); 8797 scoped_ptr<HttpNetworkSession> session(CreateSession(session_deps_));
8798 8798
8799 base::WeakPtr<HttpServerProperties> http_server_properties = 8799 base::WeakPtr<HttpServerProperties> http_server_properties =
8800 session->http_server_properties(); 8800 session->http_server_properties();
8801 AlternativeService alternative_service( 8801 AlternativeService alternative_service(
8802 AlternateProtocolFromNextProto(next_proto), "", 443); 8802 AlternateProtocolFromNextProto(next_proto), "", 443);
8803 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 8803 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
8804 http_server_properties->SetAlternativeService( 8804 http_server_properties->SetAlternativeService(
8805 HostPortPair("host.with.alternate", 80), alternative_service, expiration); 8805 url::SchemeHostPort("http", "host.with.alternate", 80),
8806 alternative_service, expiration);
8806 8807
8807 return session; 8808 return session;
8808 } 8809 }
8809 8810
8810 int GroupNameTransactionHelper(const std::string& url, 8811 int GroupNameTransactionHelper(const std::string& url,
8811 HttpNetworkSession* session) { 8812 HttpNetworkSession* session) {
8812 HttpRequestInfo request; 8813 HttpRequestInfo request;
8813 request.method = "GET"; 8814 request.method = "GET";
8814 request.url = GURL(url); 8815 request.url = GURL(url);
8815 request.load_flags = 0; 8816 request.load_flags = 0;
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
9682 9683
9683 TestCompletionCallback callback; 9684 TestCompletionCallback callback;
9684 9685
9685 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9686 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9686 scoped_ptr<HttpTransaction> trans( 9687 scoped_ptr<HttpTransaction> trans(
9687 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9688 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9688 9689
9689 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9690 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9690 EXPECT_EQ(ERR_IO_PENDING, rv); 9691 EXPECT_EQ(ERR_IO_PENDING, rv);
9691 9692
9692 HostPortPair http_host_port_pair("www.example.org", 80); 9693 url::SchemeHostPort test_server("http", "www.example.org", 80);
9693 HttpServerProperties& http_server_properties = 9694 HttpServerProperties& http_server_properties =
9694 *session->http_server_properties(); 9695 *session->http_server_properties();
9695 AlternativeServiceVector alternative_service_vector = 9696 AlternativeServiceVector alternative_service_vector =
9696 http_server_properties.GetAlternativeServices(http_host_port_pair); 9697 http_server_properties.GetAlternativeServices(test_server);
9697 EXPECT_TRUE(alternative_service_vector.empty()); 9698 EXPECT_TRUE(alternative_service_vector.empty());
9698 9699
9699 EXPECT_EQ(OK, callback.WaitForResult()); 9700 EXPECT_EQ(OK, callback.WaitForResult());
9700 9701
9701 const HttpResponseInfo* response = trans->GetResponseInfo(); 9702 const HttpResponseInfo* response = trans->GetResponseInfo();
9702 ASSERT_TRUE(response != NULL); 9703 ASSERT_TRUE(response != NULL);
9703 ASSERT_TRUE(response->headers.get() != NULL); 9704 ASSERT_TRUE(response->headers.get() != NULL);
9704 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9705 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9705 EXPECT_FALSE(response->was_fetched_via_spdy); 9706 EXPECT_FALSE(response->was_fetched_via_spdy);
9706 EXPECT_FALSE(response->was_npn_negotiated); 9707 EXPECT_FALSE(response->was_npn_negotiated);
9707 9708
9708 std::string response_data; 9709 std::string response_data;
9709 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9710 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9710 EXPECT_EQ("hello world", response_data); 9711 EXPECT_EQ("hello world", response_data);
9711 9712
9712 alternative_service_vector = 9713 alternative_service_vector =
9713 http_server_properties.GetAlternativeServices(http_host_port_pair); 9714 http_server_properties.GetAlternativeServices(test_server);
9714 ASSERT_EQ(1u, alternative_service_vector.size()); 9715 ASSERT_EQ(1u, alternative_service_vector.size());
9715 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), 9716 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
9716 alternative_service_vector[0].protocol); 9717 alternative_service_vector[0].protocol);
9717 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 9718 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
9718 EXPECT_EQ(443, alternative_service_vector[0].port); 9719 EXPECT_EQ(443, alternative_service_vector[0].port);
9719 } 9720 }
9720 9721
9721 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { 9722 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) {
9722 session_deps_.parse_alternative_services = true; 9723 session_deps_.parse_alternative_services = true;
9723 session_deps_.enable_alternative_service_with_different_host = false; 9724 session_deps_.enable_alternative_service_with_different_host = false;
9724 9725
9725 // Set an alternative service for origin. 9726 // Set an alternative service for origin.
9726 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9727 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9727 HttpServerProperties& http_server_properties = 9728 HttpServerProperties& http_server_properties =
9728 *session->http_server_properties(); 9729 *session->http_server_properties();
9729 HostPortPair http_host_port_pair("www.example.org", 80); 9730 url::SchemeHostPort test_server("http", "www.example.org", 80);
9730 AlternativeService alternative_service(QUIC, "", 80); 9731 AlternativeService alternative_service(QUIC, "", 80);
9731 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9732 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9732 http_server_properties.SetAlternativeService(http_host_port_pair, 9733 http_server_properties.SetAlternativeService(test_server, alternative_service,
9733 alternative_service, expiration); 9734 expiration);
9734 AlternativeServiceVector alternative_service_vector = 9735 AlternativeServiceVector alternative_service_vector =
9735 http_server_properties.GetAlternativeServices(http_host_port_pair); 9736 http_server_properties.GetAlternativeServices(test_server);
9736 EXPECT_EQ(1u, alternative_service_vector.size()); 9737 EXPECT_EQ(1u, alternative_service_vector.size());
9737 9738
9738 // Send a clear header. 9739 // Send a clear header.
9739 MockRead data_reads[] = { 9740 MockRead data_reads[] = {
9740 MockRead("HTTP/1.1 200 OK\r\n"), 9741 MockRead("HTTP/1.1 200 OK\r\n"),
9741 MockRead("Alt-Svc: clear\r\n"), 9742 MockRead("Alt-Svc: clear\r\n"),
9742 MockRead("\r\n"), 9743 MockRead("\r\n"),
9743 MockRead("hello world"), 9744 MockRead("hello world"),
9744 MockRead(SYNCHRONOUS, OK), 9745 MockRead(SYNCHRONOUS, OK),
9745 }; 9746 };
(...skipping 18 matching lines...) Expand all
9764 ASSERT_TRUE(response->headers.get() != nullptr); 9765 ASSERT_TRUE(response->headers.get() != nullptr);
9765 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9766 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9766 EXPECT_FALSE(response->was_fetched_via_spdy); 9767 EXPECT_FALSE(response->was_fetched_via_spdy);
9767 EXPECT_FALSE(response->was_npn_negotiated); 9768 EXPECT_FALSE(response->was_npn_negotiated);
9768 9769
9769 std::string response_data; 9770 std::string response_data;
9770 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9771 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9771 EXPECT_EQ("hello world", response_data); 9772 EXPECT_EQ("hello world", response_data);
9772 9773
9773 alternative_service_vector = 9774 alternative_service_vector =
9774 http_server_properties.GetAlternativeServices(http_host_port_pair); 9775 http_server_properties.GetAlternativeServices(test_server);
9775 EXPECT_TRUE(alternative_service_vector.empty()); 9776 EXPECT_TRUE(alternative_service_vector.empty());
9776 } 9777 }
9777 9778
9778 // Alternative Service headers must be ignored when 9779 // Alternative Service headers must be ignored when
9779 // |parse_alternative_services| is false. 9780 // |parse_alternative_services| is false.
9780 TEST_P(HttpNetworkTransactionTest, DoNotHonorAlternativeServiceHeader) { 9781 TEST_P(HttpNetworkTransactionTest, DoNotHonorAlternativeServiceHeader) {
9781 session_deps_.parse_alternative_services = false; 9782 session_deps_.parse_alternative_services = false;
9782 9783
9783 std::string alternative_service_http_header = 9784 std::string alternative_service_http_header =
9784 GetAlternativeServiceHttpHeader(); 9785 GetAlternativeServiceHttpHeader();
(...skipping 17 matching lines...) Expand all
9802 9803
9803 TestCompletionCallback callback; 9804 TestCompletionCallback callback;
9804 9805
9805 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); 9806 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_);
9806 scoped_ptr<HttpTransaction> trans( 9807 scoped_ptr<HttpTransaction> trans(
9807 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9808 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9808 9809
9809 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9810 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9810 EXPECT_EQ(ERR_IO_PENDING, rv); 9811 EXPECT_EQ(ERR_IO_PENDING, rv);
9811 9812
9812 HostPortPair http_host_port_pair("www.example.org", 80); 9813 url::SchemeHostPort test_server("http", "www.example.org", 80);
9813 HttpServerProperties& http_server_properties = 9814 HttpServerProperties& http_server_properties =
9814 *session->http_server_properties(); 9815 *session->http_server_properties();
9815 AlternativeServiceVector alternative_service_vector = 9816 AlternativeServiceVector alternative_service_vector =
9816 http_server_properties.GetAlternativeServices(http_host_port_pair); 9817 http_server_properties.GetAlternativeServices(test_server);
9817 EXPECT_TRUE(alternative_service_vector.empty()); 9818 EXPECT_TRUE(alternative_service_vector.empty());
9818 9819
9819 EXPECT_EQ(OK, callback.WaitForResult()); 9820 EXPECT_EQ(OK, callback.WaitForResult());
9820 9821
9821 const HttpResponseInfo* response = trans->GetResponseInfo(); 9822 const HttpResponseInfo* response = trans->GetResponseInfo();
9822 ASSERT_TRUE(response != nullptr); 9823 ASSERT_TRUE(response != nullptr);
9823 ASSERT_TRUE(response->headers.get() != nullptr); 9824 ASSERT_TRUE(response->headers.get() != nullptr);
9824 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9825 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9825 EXPECT_FALSE(response->was_fetched_via_spdy); 9826 EXPECT_FALSE(response->was_fetched_via_spdy);
9826 EXPECT_FALSE(response->was_npn_negotiated); 9827 EXPECT_FALSE(response->was_npn_negotiated);
9827 9828
9828 std::string response_data; 9829 std::string response_data;
9829 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9830 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9830 EXPECT_EQ("hello world", response_data); 9831 EXPECT_EQ("hello world", response_data);
9831 9832
9832 alternative_service_vector = 9833 alternative_service_vector =
9833 http_server_properties.GetAlternativeServices(http_host_port_pair); 9834 http_server_properties.GetAlternativeServices(test_server);
9834 EXPECT_TRUE(alternative_service_vector.empty()); 9835 EXPECT_TRUE(alternative_service_vector.empty());
9835 } 9836 }
9836 9837
9837 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { 9838 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) {
9838 session_deps_.parse_alternative_services = true; 9839 session_deps_.parse_alternative_services = true;
9839 session_deps_.enable_alternative_service_with_different_host = false; 9840 session_deps_.enable_alternative_service_with_different_host = false;
9840 9841
9841 MockRead data_reads[] = { 9842 MockRead data_reads[] = {
9842 MockRead("HTTP/1.1 200 OK\r\n"), 9843 MockRead("HTTP/1.1 200 OK\r\n"),
9843 MockRead("Alt-Svc: "), 9844 MockRead("Alt-Svc: "),
(...skipping 16 matching lines...) Expand all
9860 9861
9861 TestCompletionCallback callback; 9862 TestCompletionCallback callback;
9862 9863
9863 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9864 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9864 scoped_ptr<HttpTransaction> trans( 9865 scoped_ptr<HttpTransaction> trans(
9865 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9866 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9866 9867
9867 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9868 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9868 EXPECT_EQ(ERR_IO_PENDING, rv); 9869 EXPECT_EQ(ERR_IO_PENDING, rv);
9869 9870
9870 HostPortPair http_host_port_pair("www.example.org", 80); 9871 url::SchemeHostPort test_server("http", "www.example.org", 80);
9871 HttpServerProperties& http_server_properties = 9872 HttpServerProperties& http_server_properties =
9872 *session->http_server_properties(); 9873 *session->http_server_properties();
9873 AlternativeServiceVector alternative_service_vector = 9874 AlternativeServiceVector alternative_service_vector =
9874 http_server_properties.GetAlternativeServices(http_host_port_pair); 9875 http_server_properties.GetAlternativeServices(test_server);
9875 EXPECT_TRUE(alternative_service_vector.empty()); 9876 EXPECT_TRUE(alternative_service_vector.empty());
9876 9877
9877 EXPECT_EQ(OK, callback.WaitForResult()); 9878 EXPECT_EQ(OK, callback.WaitForResult());
9878 9879
9879 const HttpResponseInfo* response = trans->GetResponseInfo(); 9880 const HttpResponseInfo* response = trans->GetResponseInfo();
9880 ASSERT_TRUE(response != NULL); 9881 ASSERT_TRUE(response != NULL);
9881 ASSERT_TRUE(response->headers.get() != NULL); 9882 ASSERT_TRUE(response->headers.get() != NULL);
9882 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9883 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9883 EXPECT_FALSE(response->was_fetched_via_spdy); 9884 EXPECT_FALSE(response->was_fetched_via_spdy);
9884 EXPECT_FALSE(response->was_npn_negotiated); 9885 EXPECT_FALSE(response->was_npn_negotiated);
9885 9886
9886 std::string response_data; 9887 std::string response_data;
9887 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9888 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9888 EXPECT_EQ("hello world", response_data); 9889 EXPECT_EQ("hello world", response_data);
9889 9890
9890 alternative_service_vector = 9891 alternative_service_vector =
9891 http_server_properties.GetAlternativeServices(http_host_port_pair); 9892 http_server_properties.GetAlternativeServices(test_server);
9892 ASSERT_EQ(2u, alternative_service_vector.size()); 9893 ASSERT_EQ(2u, alternative_service_vector.size());
9893 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), 9894 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
9894 alternative_service_vector[0].protocol); 9895 alternative_service_vector[0].protocol);
9895 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 9896 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
9896 EXPECT_EQ(443, alternative_service_vector[0].port); 9897 EXPECT_EQ(443, alternative_service_vector[0].port);
9897 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), 9898 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
9898 alternative_service_vector[1].protocol); 9899 alternative_service_vector[1].protocol);
9899 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); 9900 EXPECT_EQ("www.example.org", alternative_service_vector[1].host);
9900 EXPECT_EQ(1234, alternative_service_vector[1].port); 9901 EXPECT_EQ(1234, alternative_service_vector[1].port);
9901 } 9902 }
(...skipping 25 matching lines...) Expand all
9927 9928
9928 TestCompletionCallback callback; 9929 TestCompletionCallback callback;
9929 9930
9930 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9931 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9931 scoped_ptr<HttpTransaction> trans( 9932 scoped_ptr<HttpTransaction> trans(
9932 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 9933 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
9933 9934
9934 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 9935 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9935 EXPECT_EQ(ERR_IO_PENDING, rv); 9936 EXPECT_EQ(ERR_IO_PENDING, rv);
9936 9937
9937 HostPortPair http_host_port_pair("www.example.org", 80); 9938 url::SchemeHostPort test_server("http", "www.example.org", 80);
9938 HttpServerProperties& http_server_properties = 9939 HttpServerProperties& http_server_properties =
9939 *session->http_server_properties(); 9940 *session->http_server_properties();
9940 AlternativeServiceVector alternative_service_vector = 9941 AlternativeServiceVector alternative_service_vector =
9941 http_server_properties.GetAlternativeServices(http_host_port_pair); 9942 http_server_properties.GetAlternativeServices(test_server);
9942 EXPECT_TRUE(alternative_service_vector.empty()); 9943 EXPECT_TRUE(alternative_service_vector.empty());
9943 9944
9944 EXPECT_EQ(OK, callback.WaitForResult()); 9945 EXPECT_EQ(OK, callback.WaitForResult());
9945 9946
9946 const HttpResponseInfo* response = trans->GetResponseInfo(); 9947 const HttpResponseInfo* response = trans->GetResponseInfo();
9947 ASSERT_TRUE(response != NULL); 9948 ASSERT_TRUE(response != NULL);
9948 ASSERT_TRUE(response->headers.get() != NULL); 9949 ASSERT_TRUE(response->headers.get() != NULL);
9949 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 9950 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9950 EXPECT_FALSE(response->was_fetched_via_spdy); 9951 EXPECT_FALSE(response->was_fetched_via_spdy);
9951 EXPECT_FALSE(response->was_npn_negotiated); 9952 EXPECT_FALSE(response->was_npn_negotiated);
9952 9953
9953 std::string response_data; 9954 std::string response_data;
9954 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 9955 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9955 EXPECT_EQ("hello world", response_data); 9956 EXPECT_EQ("hello world", response_data);
9956 9957
9957 alternative_service_vector = 9958 alternative_service_vector =
9958 http_server_properties.GetAlternativeServices(http_host_port_pair); 9959 http_server_properties.GetAlternativeServices(test_server);
9959 ASSERT_EQ(1u, alternative_service_vector.size()); 9960 ASSERT_EQ(1u, alternative_service_vector.size());
9960 EXPECT_EQ(443, alternative_service_vector[0].port); 9961 EXPECT_EQ(443, alternative_service_vector[0].port);
9961 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), 9962 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
9962 alternative_service_vector[0].protocol); 9963 alternative_service_vector[0].protocol);
9963 } 9964 }
9964 9965
9965 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) { 9966 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) {
9966 session_deps_.parse_alternative_services = false; 9967 session_deps_.parse_alternative_services = false;
9967 session_deps_.enable_alternative_service_with_different_host = false; 9968 session_deps_.enable_alternative_service_with_different_host = false;
9968 9969
(...skipping 10 matching lines...) Expand all
9979 request.load_flags = 0; 9980 request.load_flags = 0;
9980 9981
9981 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 9982 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
9982 9983
9983 session_deps_.socket_factory->AddSocketDataProvider(&data); 9984 session_deps_.socket_factory->AddSocketDataProvider(&data);
9984 9985
9985 TestCompletionCallback callback; 9986 TestCompletionCallback callback;
9986 9987
9987 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9988 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9988 9989
9989 HostPortPair http_host_port_pair("www.example.org", 80); 9990 url::SchemeHostPort test_server("http", "www.example.org", 80);
9990 HttpServerProperties& http_server_properties = 9991 HttpServerProperties& http_server_properties =
9991 *session->http_server_properties(); 9992 *session->http_server_properties();
9992 AlternativeService alternative_service(QUIC, "", 80); 9993 AlternativeService alternative_service(QUIC, "", 80);
9993 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9994 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9994 http_server_properties.SetAlternativeService(http_host_port_pair, 9995 http_server_properties.SetAlternativeService(test_server, alternative_service,
9995 alternative_service, expiration); 9996 expiration);
9996 9997
9997 AlternativeServiceVector alternative_service_vector = 9998 AlternativeServiceVector alternative_service_vector =
9998 http_server_properties.GetAlternativeServices(http_host_port_pair); 9999 http_server_properties.GetAlternativeServices(test_server);
9999 ASSERT_EQ(1u, alternative_service_vector.size()); 10000 ASSERT_EQ(1u, alternative_service_vector.size());
10000 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); 10001 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
10001 10002
10002 scoped_ptr<HttpTransaction> trans( 10003 scoped_ptr<HttpTransaction> trans(
10003 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10004 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10004 10005
10005 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10006 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10006 EXPECT_EQ(ERR_IO_PENDING, rv); 10007 EXPECT_EQ(ERR_IO_PENDING, rv);
10007 10008
10008 EXPECT_EQ(OK, callback.WaitForResult()); 10009 EXPECT_EQ(OK, callback.WaitForResult());
10009 10010
10010 const HttpResponseInfo* response = trans->GetResponseInfo(); 10011 const HttpResponseInfo* response = trans->GetResponseInfo();
10011 ASSERT_TRUE(response != NULL); 10012 ASSERT_TRUE(response != NULL);
10012 ASSERT_TRUE(response->headers.get() != NULL); 10013 ASSERT_TRUE(response->headers.get() != NULL);
10013 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10014 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10014 EXPECT_FALSE(response->was_fetched_via_spdy); 10015 EXPECT_FALSE(response->was_fetched_via_spdy);
10015 EXPECT_FALSE(response->was_npn_negotiated); 10016 EXPECT_FALSE(response->was_npn_negotiated);
10016 10017
10017 std::string response_data; 10018 std::string response_data;
10018 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10019 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10019 EXPECT_EQ("hello world", response_data); 10020 EXPECT_EQ("hello world", response_data);
10020 10021
10021 alternative_service_vector = 10022 alternative_service_vector =
10022 http_server_properties.GetAlternativeServices(http_host_port_pair); 10023 http_server_properties.GetAlternativeServices(test_server);
10023 EXPECT_TRUE(alternative_service_vector.empty()); 10024 EXPECT_TRUE(alternative_service_vector.empty());
10024 } 10025 }
10025 10026
10026 // When |session_deps_.parse_alternative_services = true| and the response has 10027 // When |session_deps_.parse_alternative_services = true| and the response has
10027 // an Alt-Svc header, then the Alternate-Protocol header is not parsed. 10028 // an Alt-Svc header, then the Alternate-Protocol header is not parsed.
10028 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) { 10029 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) {
10029 session_deps_.parse_alternative_services = true; 10030 session_deps_.parse_alternative_services = true;
10030 session_deps_.enable_alternative_service_with_different_host = false; 10031 session_deps_.enable_alternative_service_with_different_host = false;
10031 10032
10032 std::string alternative_service_http_header = 10033 std::string alternative_service_http_header =
(...skipping 20 matching lines...) Expand all
10053 10054
10054 TestCompletionCallback callback; 10055 TestCompletionCallback callback;
10055 10056
10056 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10057 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10057 scoped_ptr<HttpTransaction> trans( 10058 scoped_ptr<HttpTransaction> trans(
10058 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10059 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10059 10060
10060 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10061 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10061 EXPECT_EQ(ERR_IO_PENDING, rv); 10062 EXPECT_EQ(ERR_IO_PENDING, rv);
10062 10063
10063 HostPortPair http_host_port_pair("www.example.org", 80); 10064 url::SchemeHostPort test_server("http", "www.example.org", 80);
10064 HttpServerProperties& http_server_properties = 10065 HttpServerProperties& http_server_properties =
10065 *session->http_server_properties(); 10066 *session->http_server_properties();
10066 AlternativeServiceVector alternative_service_vector = 10067 AlternativeServiceVector alternative_service_vector =
10067 http_server_properties.GetAlternativeServices(http_host_port_pair); 10068 http_server_properties.GetAlternativeServices(test_server);
10068 EXPECT_TRUE(alternative_service_vector.empty()); 10069 EXPECT_TRUE(alternative_service_vector.empty());
10069 10070
10070 EXPECT_EQ(OK, callback.WaitForResult()); 10071 EXPECT_EQ(OK, callback.WaitForResult());
10071 10072
10072 const HttpResponseInfo* response = trans->GetResponseInfo(); 10073 const HttpResponseInfo* response = trans->GetResponseInfo();
10073 ASSERT_TRUE(response != NULL); 10074 ASSERT_TRUE(response != NULL);
10074 ASSERT_TRUE(response->headers.get() != NULL); 10075 ASSERT_TRUE(response->headers.get() != NULL);
10075 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10076 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10076 EXPECT_FALSE(response->was_fetched_via_spdy); 10077 EXPECT_FALSE(response->was_fetched_via_spdy);
10077 EXPECT_FALSE(response->was_npn_negotiated); 10078 EXPECT_FALSE(response->was_npn_negotiated);
10078 10079
10079 std::string response_data; 10080 std::string response_data;
10080 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10081 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10081 EXPECT_EQ("hello world", response_data); 10082 EXPECT_EQ("hello world", response_data);
10082 10083
10083 alternative_service_vector = 10084 alternative_service_vector =
10084 http_server_properties.GetAlternativeServices(http_host_port_pair); 10085 http_server_properties.GetAlternativeServices(test_server);
10085 ASSERT_EQ(1u, alternative_service_vector.size()); 10086 ASSERT_EQ(1u, alternative_service_vector.size());
10086 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), 10087 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
10087 alternative_service_vector[0].protocol); 10088 alternative_service_vector[0].protocol);
10088 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); 10089 EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
10089 EXPECT_EQ(443, alternative_service_vector[0].port); 10090 EXPECT_EQ(443, alternative_service_vector[0].port);
10090 } 10091 }
10091 10092
10092 // When |enable_alternative_service_with_different_host| is false, do not 10093 // When |enable_alternative_service_with_different_host| is false, do not
10093 // observe alternative service entries that point to a different host. 10094 // observe alternative service entries that point to a different host.
10094 TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) { 10095 TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) {
(...skipping 20 matching lines...) Expand all
10115 10116
10116 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); 10117 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_);
10117 10118
10118 base::WeakPtr<HttpServerProperties> http_server_properties = 10119 base::WeakPtr<HttpServerProperties> http_server_properties =
10119 session->http_server_properties(); 10120 session->http_server_properties();
10120 AlternativeService alternative_service( 10121 AlternativeService alternative_service(
10121 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org", 10122 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org",
10122 80); 10123 80);
10123 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10124 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10124 http_server_properties->SetAlternativeService( 10125 http_server_properties->SetAlternativeService(
10125 HostPortPair::FromURL(request.url), alternative_service, expiration); 10126 url::SchemeHostPort(request.url), alternative_service, expiration);
10126 10127
10127 scoped_ptr<HttpTransaction> trans( 10128 scoped_ptr<HttpTransaction> trans(
10128 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10129 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10129 TestCompletionCallback callback; 10130 TestCompletionCallback callback;
10130 10131
10131 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10132 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10132 // The connetion to origin was refused, and the alternative service should not 10133 // The connetion to origin was refused, and the alternative service should not
10133 // be used (even though mock data are there), therefore the request should 10134 // be used (even though mock data are there), therefore the request should
10134 // fail. 10135 // fail.
10135 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); 10136 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv));
10136 } 10137 }
10137 10138
10138 TEST_P(HttpNetworkTransactionTest, IdentifyQuicBroken) { 10139 TEST_P(HttpNetworkTransactionTest, IdentifyQuicBroken) {
10139 HostPortPair origin("origin.example.org", 443); 10140 url::SchemeHostPort server("https", "origin.example.org", 443);
10140 HostPortPair alternative("alternative.example.org", 443); 10141 HostPortPair alternative("alternative.example.org", 443);
10141 std::string origin_url = "https://origin.example.org:443"; 10142 std::string origin_url = "https://origin.example.org:443";
10142 std::string alternative_url = "https://alternative.example.org:443"; 10143 std::string alternative_url = "https://alternative.example.org:443";
10143 10144
10144 // Negotiate HTTP/1.1 with alternative.example.org. 10145 // Negotiate HTTP/1.1 with alternative.example.org.
10145 SSLSocketDataProvider ssl(ASYNC, OK); 10146 SSLSocketDataProvider ssl(ASYNC, OK);
10146 ssl.SetNextProto(kProtoHTTP11); 10147 ssl.SetNextProto(kProtoHTTP11);
10147 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 10148 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
10148 10149
10149 // HTTP/1.1 data for request. 10150 // HTTP/1.1 data for request.
(...skipping 10 matching lines...) Expand all
10160 "first HTTP/1.1 response from alternative"), 10161 "first HTTP/1.1 response from alternative"),
10161 }; 10162 };
10162 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 10163 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
10163 http_writes, arraysize(http_writes)); 10164 http_writes, arraysize(http_writes));
10164 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 10165 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
10165 10166
10166 StaticSocketDataProvider data_refused; 10167 StaticSocketDataProvider data_refused;
10167 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 10168 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
10168 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 10169 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
10169 10170
10170 // Set up a QUIC alternative service for origin. 10171 // Set up a QUIC alternative service for server.
10171 session_deps_.parse_alternative_services = true; 10172 session_deps_.parse_alternative_services = true;
10172 session_deps_.enable_alternative_service_with_different_host = false; 10173 session_deps_.enable_alternative_service_with_different_host = false;
10173 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10174 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10174 base::WeakPtr<HttpServerProperties> http_server_properties = 10175 base::WeakPtr<HttpServerProperties> http_server_properties =
10175 session->http_server_properties(); 10176 session->http_server_properties();
10176 AlternativeService alternative_service(QUIC, alternative); 10177 AlternativeService alternative_service(QUIC, alternative);
10177 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10178 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10178 http_server_properties->SetAlternativeService(origin, alternative_service, 10179 http_server_properties->SetAlternativeService(server, alternative_service,
10179 expiration); 10180 expiration);
10180 // Mark the QUIC alternative service as broken. 10181 // Mark the QUIC alternative service as broken.
10181 http_server_properties->MarkAlternativeServiceBroken(alternative_service); 10182 http_server_properties->MarkAlternativeServiceBroken(alternative_service);
10182 10183
10183 scoped_ptr<HttpTransaction> trans( 10184 scoped_ptr<HttpTransaction> trans(
10184 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10185 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10185 HttpRequestInfo request; 10186 HttpRequestInfo request;
10186 request.method = "GET"; 10187 request.method = "GET";
10187 request.url = GURL(origin_url); 10188 request.url = GURL(origin_url);
10188 request.load_flags = 0; 10189 request.load_flags = 0;
10189 TestCompletionCallback callback; 10190 TestCompletionCallback callback;
10190 NetErrorDetails details; 10191 NetErrorDetails details;
10191 EXPECT_FALSE(details.quic_broken); 10192 EXPECT_FALSE(details.quic_broken);
10192 10193
10193 trans->Start(&request, callback.callback(), BoundNetLog()); 10194 trans->Start(&request, callback.callback(), BoundNetLog());
10194 trans->PopulateNetErrorDetails(&details); 10195 trans->PopulateNetErrorDetails(&details);
10195 EXPECT_TRUE(details.quic_broken); 10196 EXPECT_TRUE(details.quic_broken);
10196 } 10197 }
10197 10198
10198 TEST_P(HttpNetworkTransactionTest, IdentifyQuicNotBroken) { 10199 TEST_P(HttpNetworkTransactionTest, IdentifyQuicNotBroken) {
10199 HostPortPair origin("origin.example.org", 443); 10200 url::SchemeHostPort server("https", "origin.example.org", 443);
10200 HostPortPair alternative1("alternative1.example.org", 443); 10201 HostPortPair alternative1("alternative1.example.org", 443);
10201 HostPortPair alternative2("alternative2.example.org", 443); 10202 HostPortPair alternative2("alternative2.example.org", 443);
10202 std::string origin_url = "https://origin.example.org:443"; 10203 std::string origin_url = "https://origin.example.org:443";
10203 std::string alternative_url1 = "https://alternative1.example.org:443"; 10204 std::string alternative_url1 = "https://alternative1.example.org:443";
10204 std::string alternative_url2 = "https://alternative2.example.org:443"; 10205 std::string alternative_url2 = "https://alternative2.example.org:443";
10205 10206
10206 // Negotiate HTTP/1.1 with alternative1.example.org. 10207 // Negotiate HTTP/1.1 with alternative1.example.org.
10207 SSLSocketDataProvider ssl(ASYNC, OK); 10208 SSLSocketDataProvider ssl(ASYNC, OK);
10208 ssl.SetNextProto(kProtoHTTP11); 10209 ssl.SetNextProto(kProtoHTTP11);
10209 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 10210 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
(...skipping 18 matching lines...) Expand all
10228 StaticSocketDataProvider data_refused; 10229 StaticSocketDataProvider data_refused;
10229 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 10230 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
10230 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 10231 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
10231 10232
10232 session_deps_.parse_alternative_services = true; 10233 session_deps_.parse_alternative_services = true;
10233 session_deps_.enable_alternative_service_with_different_host = true; 10234 session_deps_.enable_alternative_service_with_different_host = true;
10234 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10235 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10235 base::WeakPtr<HttpServerProperties> http_server_properties = 10236 base::WeakPtr<HttpServerProperties> http_server_properties =
10236 session->http_server_properties(); 10237 session->http_server_properties();
10237 10238
10238 // Set up two QUIC alternative services for origin. 10239 // Set up two QUIC alternative services for server.
10239 AlternativeServiceInfoVector alternative_service_info_vector; 10240 AlternativeServiceInfoVector alternative_service_info_vector;
10240 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10241 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10241 10242
10242 AlternativeService alternative_service1(QUIC, alternative1); 10243 AlternativeService alternative_service1(QUIC, alternative1);
10243 AlternativeServiceInfo alternative_service_info1(alternative_service1, 10244 AlternativeServiceInfo alternative_service_info1(alternative_service1,
10244 expiration); 10245 expiration);
10245 alternative_service_info_vector.push_back(alternative_service_info1); 10246 alternative_service_info_vector.push_back(alternative_service_info1);
10246 AlternativeService alternative_service2(QUIC, alternative2); 10247 AlternativeService alternative_service2(QUIC, alternative2);
10247 AlternativeServiceInfo alternative_service_info2(alternative_service2, 10248 AlternativeServiceInfo alternative_service_info2(alternative_service2,
10248 expiration); 10249 expiration);
10249 alternative_service_info_vector.push_back(alternative_service_info2); 10250 alternative_service_info_vector.push_back(alternative_service_info2);
10250 10251
10251 http_server_properties->SetAlternativeServices( 10252 http_server_properties->SetAlternativeServices(
10252 origin, alternative_service_info_vector); 10253 server, alternative_service_info_vector);
10253 10254
10254 // Mark one of the QUIC alternative service as broken. 10255 // Mark one of the QUIC alternative service as broken.
10255 http_server_properties->MarkAlternativeServiceBroken(alternative_service1); 10256 http_server_properties->MarkAlternativeServiceBroken(alternative_service1);
10256 10257
10257 const AlternativeServiceVector alternative_service_vector = 10258 const AlternativeServiceVector alternative_service_vector =
10258 http_server_properties->GetAlternativeServices(origin); 10259 http_server_properties->GetAlternativeServices(server);
10259 10260
10260 scoped_ptr<HttpTransaction> trans( 10261 scoped_ptr<HttpTransaction> trans(
10261 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10262 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10262 HttpRequestInfo request; 10263 HttpRequestInfo request;
10263 request.method = "GET"; 10264 request.method = "GET";
10264 request.url = GURL(origin_url); 10265 request.url = GURL(origin_url);
10265 request.load_flags = 0; 10266 request.load_flags = 0;
10266 TestCompletionCallback callback; 10267 TestCompletionCallback callback;
10267 NetErrorDetails details; 10268 NetErrorDetails details;
10268 EXPECT_FALSE(details.quic_broken); 10269 EXPECT_FALSE(details.quic_broken);
(...skipping 24 matching lines...) Expand all
10293 MockRead(ASYNC, OK), 10294 MockRead(ASYNC, OK),
10294 }; 10295 };
10295 StaticSocketDataProvider second_data( 10296 StaticSocketDataProvider second_data(
10296 data_reads, arraysize(data_reads), NULL, 0); 10297 data_reads, arraysize(data_reads), NULL, 0);
10297 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 10298 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
10298 10299
10299 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10300 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10300 10301
10301 base::WeakPtr<HttpServerProperties> http_server_properties = 10302 base::WeakPtr<HttpServerProperties> http_server_properties =
10302 session->http_server_properties(); 10303 session->http_server_properties();
10303 const HostPortPair host_port_pair = HostPortPair::FromURL(request.url); 10304 const url::SchemeHostPort server(request.url);
10304 // Port must be < 1024, or the header will be ignored (since initial port was 10305 // Port must be < 1024, or the header will be ignored (since initial port was
10305 // port 80 (another restricted port). 10306 // port 80 (another restricted port).
10306 const AlternativeService alternative_service( 10307 const AlternativeService alternative_service(
10307 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10308 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10308 666); // Port is ignored by MockConnect anyway. 10309 666); // Port is ignored by MockConnect anyway.
10309 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10310 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10310 http_server_properties->SetAlternativeService( 10311 http_server_properties->SetAlternativeService(server, alternative_service,
10311 host_port_pair, alternative_service, expiration); 10312 expiration);
10312 10313
10313 scoped_ptr<HttpTransaction> trans( 10314 scoped_ptr<HttpTransaction> trans(
10314 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10315 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10315 TestCompletionCallback callback; 10316 TestCompletionCallback callback;
10316 10317
10317 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10318 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10318 EXPECT_EQ(ERR_IO_PENDING, rv); 10319 EXPECT_EQ(ERR_IO_PENDING, rv);
10319 EXPECT_EQ(OK, callback.WaitForResult()); 10320 EXPECT_EQ(OK, callback.WaitForResult());
10320 10321
10321 const HttpResponseInfo* response = trans->GetResponseInfo(); 10322 const HttpResponseInfo* response = trans->GetResponseInfo();
10322 ASSERT_TRUE(response != NULL); 10323 ASSERT_TRUE(response != NULL);
10323 ASSERT_TRUE(response->headers.get() != NULL); 10324 ASSERT_TRUE(response->headers.get() != NULL);
10324 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10325 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10325 10326
10326 std::string response_data; 10327 std::string response_data;
10327 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 10328 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
10328 EXPECT_EQ("hello world", response_data); 10329 EXPECT_EQ("hello world", response_data);
10329 10330
10330 const AlternativeServiceVector alternative_service_vector = 10331 const AlternativeServiceVector alternative_service_vector =
10331 http_server_properties->GetAlternativeServices(host_port_pair); 10332 http_server_properties->GetAlternativeServices(server);
10332 ASSERT_EQ(1u, alternative_service_vector.size()); 10333 ASSERT_EQ(1u, alternative_service_vector.size());
10333 EXPECT_EQ(alternative_service, alternative_service_vector[0]); 10334 EXPECT_EQ(alternative_service, alternative_service_vector[0]);
10334 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken( 10335 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken(
10335 alternative_service_vector[0])); 10336 alternative_service_vector[0]));
10336 } 10337 }
10337 10338
10338 // Ensure that we are not allowed to redirect traffic via an alternate protocol 10339 // Ensure that we are not allowed to redirect traffic via an alternate protocol
10339 // to an unrestricted (port >= 1024) when the original traffic was on a 10340 // to an unrestricted (port >= 1024) when the original traffic was on a
10340 // restricted port (port < 1024). Ensure that we can redirect in all other 10341 // restricted port (port < 1024). Ensure that we can redirect in all other
10341 // cases. 10342 // cases.
(...skipping 24 matching lines...) Expand all
10366 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10367 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10367 10368
10368 base::WeakPtr<HttpServerProperties> http_server_properties = 10369 base::WeakPtr<HttpServerProperties> http_server_properties =
10369 session->http_server_properties(); 10370 session->http_server_properties();
10370 const int kUnrestrictedAlternatePort = 1024; 10371 const int kUnrestrictedAlternatePort = 1024;
10371 AlternativeService alternative_service( 10372 AlternativeService alternative_service(
10372 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10373 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10373 kUnrestrictedAlternatePort); 10374 kUnrestrictedAlternatePort);
10374 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10375 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10375 http_server_properties->SetAlternativeService( 10376 http_server_properties->SetAlternativeService(
10376 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 10377 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10377 expiration); 10378 expiration);
10378 10379
10379 scoped_ptr<HttpTransaction> trans( 10380 scoped_ptr<HttpTransaction> trans(
10380 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10381 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10381 TestCompletionCallback callback; 10382 TestCompletionCallback callback;
10382 10383
10383 int rv = trans->Start( 10384 int rv = trans->Start(
10384 &restricted_port_request, 10385 &restricted_port_request,
10385 callback.callback(), BoundNetLog()); 10386 callback.callback(), BoundNetLog());
10386 EXPECT_EQ(ERR_IO_PENDING, rv); 10387 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
10419 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10420 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10420 10421
10421 base::WeakPtr<HttpServerProperties> http_server_properties = 10422 base::WeakPtr<HttpServerProperties> http_server_properties =
10422 session->http_server_properties(); 10423 session->http_server_properties();
10423 const int kUnrestrictedAlternatePort = 1024; 10424 const int kUnrestrictedAlternatePort = 1024;
10424 AlternativeService alternative_service( 10425 AlternativeService alternative_service(
10425 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10426 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10426 kUnrestrictedAlternatePort); 10427 kUnrestrictedAlternatePort);
10427 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10428 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10428 http_server_properties->SetAlternativeService( 10429 http_server_properties->SetAlternativeService(
10429 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 10430 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10430 expiration); 10431 expiration);
10431 10432
10432 scoped_ptr<HttpTransaction> trans( 10433 scoped_ptr<HttpTransaction> trans(
10433 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10434 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10434 TestCompletionCallback callback; 10435 TestCompletionCallback callback;
10435 10436
10436 EXPECT_EQ(ERR_IO_PENDING, trans->Start( 10437 EXPECT_EQ(ERR_IO_PENDING, trans->Start(
10437 &restricted_port_request, 10438 &restricted_port_request,
10438 callback.callback(), BoundNetLog())); 10439 callback.callback(), BoundNetLog()));
10439 // Change to unrestricted port should succeed. 10440 // Change to unrestricted port should succeed.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10471 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10472 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10472 10473
10473 base::WeakPtr<HttpServerProperties> http_server_properties = 10474 base::WeakPtr<HttpServerProperties> http_server_properties =
10474 session->http_server_properties(); 10475 session->http_server_properties();
10475 const int kRestrictedAlternatePort = 80; 10476 const int kRestrictedAlternatePort = 80;
10476 AlternativeService alternative_service( 10477 AlternativeService alternative_service(
10477 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10478 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10478 kRestrictedAlternatePort); 10479 kRestrictedAlternatePort);
10479 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10480 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10480 http_server_properties->SetAlternativeService( 10481 http_server_properties->SetAlternativeService(
10481 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 10482 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10482 expiration); 10483 expiration);
10483 10484
10484 scoped_ptr<HttpTransaction> trans( 10485 scoped_ptr<HttpTransaction> trans(
10485 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10486 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10486 TestCompletionCallback callback; 10487 TestCompletionCallback callback;
10487 10488
10488 int rv = trans->Start( 10489 int rv = trans->Start(
10489 &restricted_port_request, 10490 &restricted_port_request,
10490 callback.callback(), BoundNetLog()); 10491 callback.callback(), BoundNetLog());
10491 EXPECT_EQ(ERR_IO_PENDING, rv); 10492 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
10524 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10525 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10525 10526
10526 base::WeakPtr<HttpServerProperties> http_server_properties = 10527 base::WeakPtr<HttpServerProperties> http_server_properties =
10527 session->http_server_properties(); 10528 session->http_server_properties();
10528 const int kRestrictedAlternatePort = 80; 10529 const int kRestrictedAlternatePort = 80;
10529 AlternativeService alternative_service( 10530 AlternativeService alternative_service(
10530 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10531 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10531 kRestrictedAlternatePort); 10532 kRestrictedAlternatePort);
10532 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10533 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10533 http_server_properties->SetAlternativeService( 10534 http_server_properties->SetAlternativeService(
10534 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, 10535 url::SchemeHostPort(unrestricted_port_request.url), alternative_service,
10535 expiration); 10536 expiration);
10536 10537
10537 scoped_ptr<HttpTransaction> trans( 10538 scoped_ptr<HttpTransaction> trans(
10538 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10539 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10539 TestCompletionCallback callback; 10540 TestCompletionCallback callback;
10540 10541
10541 int rv = trans->Start( 10542 int rv = trans->Start(
10542 &unrestricted_port_request, callback.callback(), BoundNetLog()); 10543 &unrestricted_port_request, callback.callback(), BoundNetLog());
10543 EXPECT_EQ(ERR_IO_PENDING, rv); 10544 EXPECT_EQ(ERR_IO_PENDING, rv);
10544 // Valid change to restricted port should pass. 10545 // Valid change to restricted port should pass.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10576 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10577 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10577 10578
10578 base::WeakPtr<HttpServerProperties> http_server_properties = 10579 base::WeakPtr<HttpServerProperties> http_server_properties =
10579 session->http_server_properties(); 10580 session->http_server_properties();
10580 const int kUnrestrictedAlternatePort = 1025; 10581 const int kUnrestrictedAlternatePort = 1025;
10581 AlternativeService alternative_service( 10582 AlternativeService alternative_service(
10582 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10583 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10583 kUnrestrictedAlternatePort); 10584 kUnrestrictedAlternatePort);
10584 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10585 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10585 http_server_properties->SetAlternativeService( 10586 http_server_properties->SetAlternativeService(
10586 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, 10587 url::SchemeHostPort(unrestricted_port_request.url), alternative_service,
10587 expiration); 10588 expiration);
10588 10589
10589 scoped_ptr<HttpTransaction> trans( 10590 scoped_ptr<HttpTransaction> trans(
10590 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10591 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10591 TestCompletionCallback callback; 10592 TestCompletionCallback callback;
10592 10593
10593 int rv = trans->Start( 10594 int rv = trans->Start(
10594 &unrestricted_port_request, callback.callback(), BoundNetLog()); 10595 &unrestricted_port_request, callback.callback(), BoundNetLog());
10595 EXPECT_EQ(ERR_IO_PENDING, rv); 10596 EXPECT_EQ(ERR_IO_PENDING, rv);
10596 // Valid change to an unrestricted port should pass. 10597 // Valid change to an unrestricted port should pass.
(...skipping 26 matching lines...) Expand all
10623 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10624 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10624 10625
10625 base::WeakPtr<HttpServerProperties> http_server_properties = 10626 base::WeakPtr<HttpServerProperties> http_server_properties =
10626 session->http_server_properties(); 10627 session->http_server_properties();
10627 const int kUnsafePort = 7; 10628 const int kUnsafePort = 7;
10628 AlternativeService alternative_service( 10629 AlternativeService alternative_service(
10629 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10630 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10630 kUnsafePort); 10631 kUnsafePort);
10631 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10632 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10632 http_server_properties->SetAlternativeService( 10633 http_server_properties->SetAlternativeService(
10633 HostPortPair::FromURL(request.url), alternative_service, expiration); 10634 url::SchemeHostPort(request.url), alternative_service, expiration);
10634 10635
10635 scoped_ptr<HttpTransaction> trans( 10636 scoped_ptr<HttpTransaction> trans(
10636 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10637 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10637 TestCompletionCallback callback; 10638 TestCompletionCallback callback;
10638 10639
10639 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10640 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10640 EXPECT_EQ(ERR_IO_PENDING, rv); 10641 EXPECT_EQ(ERR_IO_PENDING, rv);
10641 // The HTTP request should succeed. 10642 // The HTTP request should succeed.
10642 EXPECT_EQ(OK, callback.WaitForResult()); 10643 EXPECT_EQ(OK, callback.WaitForResult());
10643 10644
(...skipping 2636 matching lines...) Expand 10 before | Expand all | Expand 10 after
13280 trans2.Start(&request2, callback2.callback(), BoundNetLog())); 13281 trans2.Start(&request2, callback2.callback(), BoundNetLog()));
13281 base::MessageLoop::current()->RunUntilIdle(); 13282 base::MessageLoop::current()->RunUntilIdle();
13282 13283
13283 EXPECT_EQ(OK, callback2.WaitForResult()); 13284 EXPECT_EQ(OK, callback2.WaitForResult());
13284 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); 13285 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy);
13285 } 13286 }
13286 13287
13287 class AltSvcCertificateVerificationTest : public HttpNetworkTransactionTest { 13288 class AltSvcCertificateVerificationTest : public HttpNetworkTransactionTest {
13288 public: 13289 public:
13289 void Run(bool pooling, bool valid) { 13290 void Run(bool pooling, bool valid) {
13290 HostPortPair origin(valid ? "mail.example.org" : "invalid.example.org", 13291 url::SchemeHostPort server(GURL(valid ? "https://mail.example.org:443"
13291 443); 13292 : "https://invalid.example.org:443"));
13292 HostPortPair alternative("www.example.org", 443); 13293 HostPortPair alternative("www.example.org", 443);
13293 13294
13294 base::FilePath certs_dir = GetTestCertsDirectory(); 13295 base::FilePath certs_dir = GetTestCertsDirectory();
13295 scoped_refptr<X509Certificate> cert( 13296 scoped_refptr<X509Certificate> cert(
13296 ImportCertFromFile(certs_dir, "spdy_pooling.pem")); 13297 ImportCertFromFile(certs_dir, "spdy_pooling.pem"));
13297 ASSERT_TRUE(cert.get()); 13298 ASSERT_TRUE(cert.get());
13298 bool common_name_fallback_used; 13299 bool common_name_fallback_used;
13299 EXPECT_EQ(valid, 13300 EXPECT_EQ(valid,
13300 cert->VerifyNameMatch(origin.host(), &common_name_fallback_used)); 13301 cert->VerifyNameMatch(server.host(), &common_name_fallback_used));
13301 EXPECT_TRUE( 13302 EXPECT_TRUE(
13302 cert->VerifyNameMatch(alternative.host(), &common_name_fallback_used)); 13303 cert->VerifyNameMatch(alternative.host(), &common_name_fallback_used));
13303 SSLSocketDataProvider ssl(ASYNC, OK); 13304 SSLSocketDataProvider ssl(ASYNC, OK);
13304 ssl.SetNextProto(GetProtocol()); 13305 ssl.SetNextProto(GetProtocol());
13305 ssl.cert = cert; 13306 ssl.cert = cert;
13306 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 13307 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
13307 13308
13308 // If pooling, then start a request to alternative first to create a 13309 // If pooling, then start a request to alternative first to create a
13309 // SpdySession. 13310 // SpdySession.
13310 std::string url0 = "https://www.example.org:443"; 13311 std::string url0 = "https://www.example.org:443";
13311 // Second request to origin, which has an alternative service, and could 13312 // Second request to server, which has an alternative service, and could
13312 // open a connection to the alternative host or pool to the existing one. 13313 // open a connection to the alternative host or pool to the existing one.
13313 std::string url1("https://"); 13314 std::string url1("https://");
13314 url1.append(origin.host()); 13315 url1.append(server.host());
13315 url1.append(":443"); 13316 url1.append(":443");
13316 13317
13317 scoped_ptr<SpdySerializedFrame> req0; 13318 scoped_ptr<SpdySerializedFrame> req0;
13318 scoped_ptr<SpdySerializedFrame> req1; 13319 scoped_ptr<SpdySerializedFrame> req1;
13319 scoped_ptr<SpdySerializedFrame> resp0; 13320 scoped_ptr<SpdySerializedFrame> resp0;
13320 scoped_ptr<SpdySerializedFrame> body0; 13321 scoped_ptr<SpdySerializedFrame> body0;
13321 scoped_ptr<SpdySerializedFrame> resp1; 13322 scoped_ptr<SpdySerializedFrame> resp1;
13322 scoped_ptr<SpdySerializedFrame> body1; 13323 scoped_ptr<SpdySerializedFrame> body1;
13323 std::vector<MockWrite> writes; 13324 std::vector<MockWrite> writes;
13324 std::vector<MockRead> reads; 13325 std::vector<MockRead> reads;
(...skipping 27 matching lines...) Expand all
13352 13353
13353 reads.push_back(CreateMockRead(*resp1, 1)); 13354 reads.push_back(CreateMockRead(*resp1, 1));
13354 reads.push_back(CreateMockRead(*body1, 2)); 13355 reads.push_back(CreateMockRead(*body1, 2));
13355 reads.push_back(MockRead(ASYNC, OK, 3)); 13356 reads.push_back(MockRead(ASYNC, OK, 3));
13356 } 13357 }
13357 13358
13358 SequencedSocketData data(reads.data(), reads.size(), writes.data(), 13359 SequencedSocketData data(reads.data(), reads.size(), writes.data(),
13359 writes.size()); 13360 writes.size());
13360 session_deps_.socket_factory->AddSocketDataProvider(&data); 13361 session_deps_.socket_factory->AddSocketDataProvider(&data);
13361 13362
13362 // Connection to the origin fails. 13363 // Connection to the server fails.
13363 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); 13364 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
13364 StaticSocketDataProvider data_refused; 13365 StaticSocketDataProvider data_refused;
13365 data_refused.set_connect_data(mock_connect); 13366 data_refused.set_connect_data(mock_connect);
13366 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 13367 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
13367 13368
13368 session_deps_.parse_alternative_services = true; 13369 session_deps_.parse_alternative_services = true;
13369 session_deps_.enable_alternative_service_with_different_host = true; 13370 session_deps_.enable_alternative_service_with_different_host = true;
13370 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13371 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13371 base::WeakPtr<HttpServerProperties> http_server_properties = 13372 base::WeakPtr<HttpServerProperties> http_server_properties =
13372 session->http_server_properties(); 13373 session->http_server_properties();
13373 AlternativeService alternative_service( 13374 AlternativeService alternative_service(
13374 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13375 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13375 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13376 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13376 http_server_properties->SetAlternativeService(origin, alternative_service, 13377 http_server_properties->SetAlternativeService(server, alternative_service,
13377 expiration); 13378 expiration);
13378 13379
13379 // First request to alternative. 13380 // First request to alternative.
13380 if (pooling) { 13381 if (pooling) {
13381 scoped_ptr<HttpTransaction> trans0( 13382 scoped_ptr<HttpTransaction> trans0(
13382 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13383 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13383 HttpRequestInfo request0; 13384 HttpRequestInfo request0;
13384 request0.method = "GET"; 13385 request0.method = "GET";
13385 request0.url = GURL(url0); 13386 request0.url = GURL(url0);
13386 request0.load_flags = 0; 13387 request0.load_flags = 0;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
13442 Run(false, true); 13443 Run(false, true);
13443 } 13444 }
13444 13445
13445 TEST_P(AltSvcCertificateVerificationTest, NewConnectionInvalid) { 13446 TEST_P(AltSvcCertificateVerificationTest, NewConnectionInvalid) {
13446 Run(false, false); 13447 Run(false, false);
13447 } 13448 }
13448 13449
13449 // Alternative service requires HTTP/2 (or SPDY), but HTTP/1.1 is negotiated 13450 // Alternative service requires HTTP/2 (or SPDY), but HTTP/1.1 is negotiated
13450 // with the alternative server. That connection should not be used. 13451 // with the alternative server. That connection should not be used.
13451 TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) { 13452 TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) {
13452 HostPortPair origin("origin.example.org", 443); 13453 url::SchemeHostPort server("https", "origin.example.org", 443);
13453 HostPortPair alternative("alternative.example.org", 443); 13454 HostPortPair alternative("alternative.example.org", 443);
13454 13455
13455 // Negotiate HTTP/1.1 with alternative.example.org. 13456 // Negotiate HTTP/1.1 with alternative.example.org.
13456 SSLSocketDataProvider ssl(ASYNC, OK); 13457 SSLSocketDataProvider ssl(ASYNC, OK);
13457 ssl.SetNextProto(kProtoHTTP11); 13458 ssl.SetNextProto(kProtoHTTP11);
13458 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 13459 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
13459 13460
13460 // No data should be read from the alternative, because HTTP/1.1 is 13461 // No data should be read from the alternative, because HTTP/1.1 is
13461 // negotiated. 13462 // negotiated.
13462 StaticSocketDataProvider data; 13463 StaticSocketDataProvider data;
13463 session_deps_.socket_factory->AddSocketDataProvider(&data); 13464 session_deps_.socket_factory->AddSocketDataProvider(&data);
13464 13465
13465 // This test documents that an alternate Job should not be used if HTTP/1.1 is 13466 // This test documents that an alternate Job should not be used if HTTP/1.1 is
13466 // negotiated. In order to test this, a failed connection to the origin is 13467 // negotiated. In order to test this, a failed connection to the server is
13467 // mocked. This way the request relies on the alternate Job. 13468 // mocked. This way the request relies on the alternate Job.
13468 StaticSocketDataProvider data_refused; 13469 StaticSocketDataProvider data_refused;
13469 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 13470 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
13470 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 13471 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
13471 13472
13472 // Set up alternative service for origin. 13473 // Set up alternative service for server.
13473 session_deps_.parse_alternative_services = true; 13474 session_deps_.parse_alternative_services = true;
13474 session_deps_.enable_alternative_service_with_different_host = true; 13475 session_deps_.enable_alternative_service_with_different_host = true;
13475 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13476 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13476 base::WeakPtr<HttpServerProperties> http_server_properties = 13477 base::WeakPtr<HttpServerProperties> http_server_properties =
13477 session->http_server_properties(); 13478 session->http_server_properties();
13478 AlternativeService alternative_service( 13479 AlternativeService alternative_service(
13479 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13480 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13480 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13481 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13481 http_server_properties->SetAlternativeService(origin, alternative_service, 13482 http_server_properties->SetAlternativeService(server, alternative_service,
13482 expiration); 13483 expiration);
13483 13484
13484 scoped_ptr<HttpTransaction> trans( 13485 scoped_ptr<HttpTransaction> trans(
13485 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13486 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13486 HttpRequestInfo request; 13487 HttpRequestInfo request;
13487 request.method = "GET"; 13488 request.method = "GET";
13488 request.url = GURL("https://origin.example.org:443"); 13489 request.url = GURL("https://origin.example.org:443");
13489 request.load_flags = 0; 13490 request.load_flags = 0;
13490 TestCompletionCallback callback; 13491 TestCompletionCallback callback;
13491 13492
13492 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is 13493 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is
13493 // negotiated, the alternate Job should fail with ERR_NPN_NEGOTIATION_FAILED. 13494 // negotiated, the alternate Job should fail with ERR_NPN_NEGOTIATION_FAILED.
13494 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 13495 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
13495 EXPECT_EQ(ERR_NPN_NEGOTIATION_FAILED, callback.GetResult(rv)); 13496 EXPECT_EQ(ERR_NPN_NEGOTIATION_FAILED, callback.GetResult(rv));
13496 } 13497 }
13497 13498
13498 // A request to a server with an alternative service fires two Jobs: one to the 13499 // A request to a server with an alternative service fires two Jobs: one to the
13499 // origin, and an alternate one to the alternative server. If the former 13500 // server, and an alternate one to the alternative server. If the former
13500 // succeeds, the request should succeed, even if the latter fails because 13501 // succeeds, the request should succeed, even if the latter fails because
13501 // HTTP/1.1 is negotiated which is insufficient for alternative service. 13502 // HTTP/1.1 is negotiated which is insufficient for alternative service.
13502 TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) { 13503 TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) {
13503 HostPortPair origin("origin.example.org", 443); 13504 url::SchemeHostPort server("https", "origin.example.org", 443);
13504 HostPortPair alternative("alternative.example.org", 443); 13505 HostPortPair alternative("alternative.example.org", 443);
13505 13506
13506 // Negotiate HTTP/1.1 with alternative. 13507 // Negotiate HTTP/1.1 with alternative.
13507 SSLSocketDataProvider alternative_ssl(ASYNC, OK); 13508 SSLSocketDataProvider alternative_ssl(ASYNC, OK);
13508 alternative_ssl.SetNextProto(kProtoHTTP11); 13509 alternative_ssl.SetNextProto(kProtoHTTP11);
13509 session_deps_.socket_factory->AddSSLSocketDataProvider(&alternative_ssl); 13510 session_deps_.socket_factory->AddSSLSocketDataProvider(&alternative_ssl);
13510 13511
13511 // No data should be read from the alternative, because HTTP/1.1 is 13512 // No data should be read from the alternative, because HTTP/1.1 is
13512 // negotiated. 13513 // negotiated.
13513 StaticSocketDataProvider data; 13514 StaticSocketDataProvider data;
13514 session_deps_.socket_factory->AddSocketDataProvider(&data); 13515 session_deps_.socket_factory->AddSocketDataProvider(&data);
13515 13516
13516 // Negotiate HTTP/1.1 with origin. 13517 // Negotiate HTTP/1.1 with server.
13517 SSLSocketDataProvider origin_ssl(ASYNC, OK); 13518 SSLSocketDataProvider origin_ssl(ASYNC, OK);
13518 origin_ssl.SetNextProto(kProtoHTTP11); 13519 origin_ssl.SetNextProto(kProtoHTTP11);
13519 session_deps_.socket_factory->AddSSLSocketDataProvider(&origin_ssl); 13520 session_deps_.socket_factory->AddSSLSocketDataProvider(&origin_ssl);
13520 13521
13521 MockWrite http_writes[] = { 13522 MockWrite http_writes[] = {
13522 MockWrite( 13523 MockWrite(
13523 "GET / HTTP/1.1\r\n" 13524 "GET / HTTP/1.1\r\n"
13524 "Host: origin.example.org\r\n" 13525 "Host: origin.example.org\r\n"
13525 "Connection: keep-alive\r\n\r\n"), 13526 "Connection: keep-alive\r\n\r\n"),
13526 MockWrite( 13527 MockWrite(
13527 "GET /second HTTP/1.1\r\n" 13528 "GET /second HTTP/1.1\r\n"
13528 "Host: origin.example.org\r\n" 13529 "Host: origin.example.org\r\n"
13529 "Connection: keep-alive\r\n\r\n"), 13530 "Connection: keep-alive\r\n\r\n"),
13530 }; 13531 };
13531 13532
13532 MockRead http_reads[] = { 13533 MockRead http_reads[] = {
13533 MockRead("HTTP/1.1 200 OK\r\n"), 13534 MockRead("HTTP/1.1 200 OK\r\n"),
13534 MockRead("Content-Type: text/html\r\n"), 13535 MockRead("Content-Type: text/html\r\n"),
13535 MockRead("Content-Length: 6\r\n\r\n"), 13536 MockRead("Content-Length: 6\r\n\r\n"),
13536 MockRead("foobar"), 13537 MockRead("foobar"),
13537 MockRead("HTTP/1.1 200 OK\r\n"), 13538 MockRead("HTTP/1.1 200 OK\r\n"),
13538 MockRead("Content-Type: text/html\r\n"), 13539 MockRead("Content-Type: text/html\r\n"),
13539 MockRead("Content-Length: 7\r\n\r\n"), 13540 MockRead("Content-Length: 7\r\n\r\n"),
13540 MockRead("another"), 13541 MockRead("another"),
13541 }; 13542 };
13542 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 13543 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
13543 http_writes, arraysize(http_writes)); 13544 http_writes, arraysize(http_writes));
13544 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 13545 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
13545 13546
13546 // Set up alternative service for origin. 13547 // Set up alternative service for server.
13547 session_deps_.parse_alternative_services = true; 13548 session_deps_.parse_alternative_services = true;
13548 session_deps_.enable_alternative_service_with_different_host = true; 13549 session_deps_.enable_alternative_service_with_different_host = true;
13549 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13550 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13550 base::WeakPtr<HttpServerProperties> http_server_properties = 13551 base::WeakPtr<HttpServerProperties> http_server_properties =
13551 session->http_server_properties(); 13552 session->http_server_properties();
13552 AlternativeService alternative_service( 13553 AlternativeService alternative_service(
13553 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13554 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13554 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13555 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13555 http_server_properties->SetAlternativeService(origin, alternative_service, 13556 http_server_properties->SetAlternativeService(server, alternative_service,
13556 expiration); 13557 expiration);
13557 13558
13558 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 13559 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
13559 HttpRequestInfo request1; 13560 HttpRequestInfo request1;
13560 request1.method = "GET"; 13561 request1.method = "GET";
13561 request1.url = GURL("https://origin.example.org:443"); 13562 request1.url = GURL("https://origin.example.org:443");
13562 request1.load_flags = 0; 13563 request1.load_flags = 0;
13563 TestCompletionCallback callback1; 13564 TestCompletionCallback callback1;
13564 13565
13565 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); 13566 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog());
13566 rv = callback1.GetResult(rv); 13567 rv = callback1.GetResult(rv);
13567 EXPECT_EQ(OK, rv); 13568 EXPECT_EQ(OK, rv);
13568 13569
13569 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); 13570 const HttpResponseInfo* response1 = trans1.GetResponseInfo();
13570 ASSERT_TRUE(response1 != nullptr); 13571 ASSERT_TRUE(response1 != nullptr);
13571 ASSERT_TRUE(response1->headers.get() != nullptr); 13572 ASSERT_TRUE(response1->headers.get() != nullptr);
13572 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); 13573 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine());
13573 13574
13574 std::string response_data1; 13575 std::string response_data1;
13575 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data1)); 13576 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data1));
13576 EXPECT_EQ("foobar", response_data1); 13577 EXPECT_EQ("foobar", response_data1);
13577 13578
13578 // Alternative should be marked as broken, because HTTP/1.1 is not sufficient 13579 // Alternative should be marked as broken, because HTTP/1.1 is not sufficient
13579 // for alternative service. 13580 // for alternative service.
13580 EXPECT_TRUE( 13581 EXPECT_TRUE(
13581 http_server_properties->IsAlternativeServiceBroken(alternative_service)); 13582 http_server_properties->IsAlternativeServiceBroken(alternative_service));
13582 13583
13583 // Since |alternative_service| is broken, a second transaction to origin 13584 // Since |alternative_service| is broken, a second transaction to server
13584 // should not start an alternate Job. It should pool to existing connection 13585 // should not start an alternate Job. It should pool to existing connection
13585 // to origin. 13586 // to server.
13586 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get()); 13587 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get());
13587 HttpRequestInfo request2; 13588 HttpRequestInfo request2;
13588 request2.method = "GET"; 13589 request2.method = "GET";
13589 request2.url = GURL("https://origin.example.org:443/second"); 13590 request2.url = GURL("https://origin.example.org:443/second");
13590 request2.load_flags = 0; 13591 request2.load_flags = 0;
13591 TestCompletionCallback callback2; 13592 TestCompletionCallback callback2;
13592 13593
13593 rv = trans2.Start(&request2, callback2.callback(), BoundNetLog()); 13594 rv = trans2.Start(&request2, callback2.callback(), BoundNetLog());
13594 rv = callback2.GetResult(rv); 13595 rv = callback2.GetResult(rv);
13595 EXPECT_EQ(OK, rv); 13596 EXPECT_EQ(OK, rv);
13596 13597
13597 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); 13598 const HttpResponseInfo* response2 = trans2.GetResponseInfo();
13598 ASSERT_TRUE(response2 != nullptr); 13599 ASSERT_TRUE(response2 != nullptr);
13599 ASSERT_TRUE(response2->headers.get() != nullptr); 13600 ASSERT_TRUE(response2->headers.get() != nullptr);
13600 EXPECT_EQ("HTTP/1.1 200 OK", response2->headers->GetStatusLine()); 13601 EXPECT_EQ("HTTP/1.1 200 OK", response2->headers->GetStatusLine());
13601 13602
13602 std::string response_data2; 13603 std::string response_data2;
13603 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data2)); 13604 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data2));
13604 EXPECT_EQ("another", response_data2); 13605 EXPECT_EQ("another", response_data2);
13605 } 13606 }
13606 13607
13607 // Alternative service requires HTTP/2 (or SPDY), but there is already a 13608 // Alternative service requires HTTP/2 (or SPDY), but there is already a
13608 // HTTP/1.1 socket open to the alternative server. That socket should not be 13609 // HTTP/1.1 socket open to the alternative server. That socket should not be
13609 // used. 13610 // used.
13610 TEST_P(HttpNetworkTransactionTest, AlternativeServiceShouldNotPoolToHttp11) { 13611 TEST_P(HttpNetworkTransactionTest, AlternativeServiceShouldNotPoolToHttp11) {
13611 HostPortPair origin("origin.example.org", 443); 13612 url::SchemeHostPort server("https", "origin.example.org", 443);
13612 HostPortPair alternative("alternative.example.org", 443); 13613 HostPortPair alternative("alternative.example.org", 443);
13613 std::string origin_url = "https://origin.example.org:443"; 13614 std::string origin_url = "https://origin.example.org:443";
13614 std::string alternative_url = "https://alternative.example.org:443"; 13615 std::string alternative_url = "https://alternative.example.org:443";
13615 13616
13616 // Negotiate HTTP/1.1 with alternative.example.org. 13617 // Negotiate HTTP/1.1 with alternative.example.org.
13617 SSLSocketDataProvider ssl(ASYNC, OK); 13618 SSLSocketDataProvider ssl(ASYNC, OK);
13618 ssl.SetNextProto(kProtoHTTP11); 13619 ssl.SetNextProto(kProtoHTTP11);
13619 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 13620 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
13620 13621
13621 // HTTP/1.1 data for |request1| and |request2|. 13622 // HTTP/1.1 data for |request1| and |request2|.
(...skipping 19 matching lines...) Expand all
13641 "Content-Type: text/html; charset=iso-8859-1\r\n" 13642 "Content-Type: text/html; charset=iso-8859-1\r\n"
13642 "Content-Length: 41\r\n\r\n" 13643 "Content-Length: 41\r\n\r\n"
13643 "second HTTP/1.1 response from alternative"), 13644 "second HTTP/1.1 response from alternative"),
13644 }; 13645 };
13645 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 13646 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
13646 http_writes, arraysize(http_writes)); 13647 http_writes, arraysize(http_writes));
13647 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 13648 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
13648 13649
13649 // This test documents that an alternate Job should not pool to an already 13650 // This test documents that an alternate Job should not pool to an already
13650 // existing HTTP/1.1 connection. In order to test this, a failed connection 13651 // existing HTTP/1.1 connection. In order to test this, a failed connection
13651 // to the origin is mocked. This way |request2| relies on the alternate Job. 13652 // to the server is mocked. This way |request2| relies on the alternate Job.
13652 StaticSocketDataProvider data_refused; 13653 StaticSocketDataProvider data_refused;
13653 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 13654 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
13654 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 13655 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
13655 13656
13656 // Set up alternative service for origin. 13657 // Set up alternative service for server.
13657 session_deps_.parse_alternative_services = true; 13658 session_deps_.parse_alternative_services = true;
13658 session_deps_.enable_alternative_service_with_different_host = false; 13659 session_deps_.enable_alternative_service_with_different_host = false;
13659 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13660 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13660 base::WeakPtr<HttpServerProperties> http_server_properties = 13661 base::WeakPtr<HttpServerProperties> http_server_properties =
13661 session->http_server_properties(); 13662 session->http_server_properties();
13662 AlternativeService alternative_service( 13663 AlternativeService alternative_service(
13663 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13664 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13664 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13665 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13665 http_server_properties->SetAlternativeService(origin, alternative_service, 13666 http_server_properties->SetAlternativeService(server, alternative_service,
13666 expiration); 13667 expiration);
13667 13668
13668 // First transaction to alternative to open an HTTP/1.1 socket. 13669 // First transaction to alternative to open an HTTP/1.1 socket.
13669 scoped_ptr<HttpTransaction> trans1( 13670 scoped_ptr<HttpTransaction> trans1(
13670 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13671 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13671 HttpRequestInfo request1; 13672 HttpRequestInfo request1;
13672 request1.method = "GET"; 13673 request1.method = "GET";
13673 request1.url = GURL(alternative_url); 13674 request1.url = GURL(alternative_url);
13674 request1.load_flags = 0; 13675 request1.load_flags = 0;
13675 TestCompletionCallback callback1; 13676 TestCompletionCallback callback1;
13676 13677
13677 int rv = trans1->Start(&request1, callback1.callback(), BoundNetLog()); 13678 int rv = trans1->Start(&request1, callback1.callback(), BoundNetLog());
13678 EXPECT_EQ(OK, callback1.GetResult(rv)); 13679 EXPECT_EQ(OK, callback1.GetResult(rv));
13679 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); 13680 const HttpResponseInfo* response1 = trans1->GetResponseInfo();
13680 ASSERT_TRUE(response1); 13681 ASSERT_TRUE(response1);
13681 ASSERT_TRUE(response1->headers.get()); 13682 ASSERT_TRUE(response1->headers.get());
13682 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); 13683 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine());
13683 EXPECT_TRUE(response1->was_npn_negotiated); 13684 EXPECT_TRUE(response1->was_npn_negotiated);
13684 EXPECT_FALSE(response1->was_fetched_via_spdy); 13685 EXPECT_FALSE(response1->was_fetched_via_spdy);
13685 std::string response_data1; 13686 std::string response_data1;
13686 ASSERT_EQ(OK, ReadTransaction(trans1.get(), &response_data1)); 13687 ASSERT_EQ(OK, ReadTransaction(trans1.get(), &response_data1));
13687 EXPECT_EQ("first HTTP/1.1 response from alternative", response_data1); 13688 EXPECT_EQ("first HTTP/1.1 response from alternative", response_data1);
13688 13689
13689 // Request for origin.example.org, which has an alternative service. This 13690 // Request for origin.example.org, which has an alternative service. This
13690 // will start two Jobs: the alternative looks for connections to pool to, 13691 // will start two Jobs: the alternative looks for connections to pool to,
13691 // finds one which is HTTP/1.1, and should ignore it, and should not try to 13692 // finds one which is HTTP/1.1, and should ignore it, and should not try to
13692 // open other connections to alternative server. The Job to origin fails, so 13693 // open other connections to alternative server. The Job to server fails, so
13693 // this request fails. 13694 // this request fails.
13694 scoped_ptr<HttpTransaction> trans2( 13695 scoped_ptr<HttpTransaction> trans2(
13695 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13696 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13696 HttpRequestInfo request2; 13697 HttpRequestInfo request2;
13697 request2.method = "GET"; 13698 request2.method = "GET";
13698 request2.url = GURL(origin_url); 13699 request2.url = GURL(origin_url);
13699 request2.load_flags = 0; 13700 request2.load_flags = 0;
13700 TestCompletionCallback callback2; 13701 TestCompletionCallback callback2;
13701 13702
13702 rv = trans2->Start(&request2, callback2.callback(), BoundNetLog()); 13703 rv = trans2->Start(&request2, callback2.callback(), BoundNetLog());
(...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after
15971 base::MessageLoop::current()->RunUntilIdle(); 15972 base::MessageLoop::current()->RunUntilIdle();
15972 15973
15973 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); 15974 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
15974 HttpRequestHeaders headers; 15975 HttpRequestHeaders headers;
15975 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); 15976 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
15976 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); 15977 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
15977 } 15978 }
15978 #endif // !defined(OS_IOS) 15979 #endif // !defined(OS_IOS)
15979 15980
15980 } // namespace net 15981 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698