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

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

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

Powered by Google App Engine
This is Rietveld 408576698