| OLD | NEW |
| 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 8791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8802 NextProto next_proto, | 8802 NextProto next_proto, |
| 8803 SpdySessionDependencies* session_deps_) { | 8803 SpdySessionDependencies* session_deps_) { |
| 8804 scoped_ptr<HttpNetworkSession> session(CreateSession(session_deps_)); | 8804 scoped_ptr<HttpNetworkSession> session(CreateSession(session_deps_)); |
| 8805 | 8805 |
| 8806 base::WeakPtr<HttpServerProperties> http_server_properties = | 8806 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 8807 session->http_server_properties(); | 8807 session->http_server_properties(); |
| 8808 AlternativeService alternative_service( | 8808 AlternativeService alternative_service( |
| 8809 AlternateProtocolFromNextProto(next_proto), "", 443); | 8809 AlternateProtocolFromNextProto(next_proto), "", 443); |
| 8810 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 8810 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 8811 http_server_properties->SetAlternativeService( | 8811 http_server_properties->SetAlternativeService( |
| 8812 HostPortPair("host.with.alternate", 80), alternative_service, 1.0, | 8812 SchemeOriginPair("http", "host.with.alternate", 80), alternative_service, |
| 8813 expiration); | 8813 1.0, expiration); |
| 8814 | 8814 |
| 8815 return session; | 8815 return session; |
| 8816 } | 8816 } |
| 8817 | 8817 |
| 8818 int GroupNameTransactionHelper(const std::string& url, | 8818 int GroupNameTransactionHelper(const std::string& url, |
| 8819 HttpNetworkSession* session) { | 8819 HttpNetworkSession* session) { |
| 8820 HttpRequestInfo request; | 8820 HttpRequestInfo request; |
| 8821 request.method = "GET"; | 8821 request.method = "GET"; |
| 8822 request.url = GURL(url); | 8822 request.url = GURL(url); |
| 8823 request.load_flags = 0; | 8823 request.load_flags = 0; |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9690 | 9690 |
| 9691 TestCompletionCallback callback; | 9691 TestCompletionCallback callback; |
| 9692 | 9692 |
| 9693 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9693 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 9694 scoped_ptr<HttpTransaction> trans( | 9694 scoped_ptr<HttpTransaction> trans( |
| 9695 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9695 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9696 | 9696 |
| 9697 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9697 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9698 EXPECT_EQ(ERR_IO_PENDING, rv); | 9698 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9699 | 9699 |
| 9700 HostPortPair http_host_port_pair("www.example.org", 80); | 9700 SchemeOriginPair http_origin("http", "www.example.org", 80); |
| 9701 HttpServerProperties& http_server_properties = | 9701 HttpServerProperties& http_server_properties = |
| 9702 *session->http_server_properties(); | 9702 *session->http_server_properties(); |
| 9703 AlternativeServiceVector alternative_service_vector = | 9703 AlternativeServiceVector alternative_service_vector = |
| 9704 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9704 http_server_properties.GetAlternativeServices(http_origin); |
| 9705 EXPECT_TRUE(alternative_service_vector.empty()); | 9705 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9706 | 9706 |
| 9707 EXPECT_EQ(OK, callback.WaitForResult()); | 9707 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9708 | 9708 |
| 9709 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9709 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9710 ASSERT_TRUE(response != NULL); | 9710 ASSERT_TRUE(response != NULL); |
| 9711 ASSERT_TRUE(response->headers.get() != NULL); | 9711 ASSERT_TRUE(response->headers.get() != NULL); |
| 9712 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9712 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9713 EXPECT_FALSE(response->was_fetched_via_spdy); | 9713 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9714 EXPECT_FALSE(response->was_npn_negotiated); | 9714 EXPECT_FALSE(response->was_npn_negotiated); |
| 9715 | 9715 |
| 9716 std::string response_data; | 9716 std::string response_data; |
| 9717 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9717 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9718 EXPECT_EQ("hello world", response_data); | 9718 EXPECT_EQ("hello world", response_data); |
| 9719 | 9719 |
| 9720 alternative_service_vector = | 9720 alternative_service_vector = |
| 9721 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9721 http_server_properties.GetAlternativeServices(http_origin); |
| 9722 ASSERT_EQ(1u, alternative_service_vector.size()); | 9722 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 9723 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9723 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9724 alternative_service_vector[0].protocol); | 9724 alternative_service_vector[0].protocol); |
| 9725 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); | 9725 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); |
| 9726 EXPECT_EQ(443, alternative_service_vector[0].port); | 9726 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 9727 } | 9727 } |
| 9728 | 9728 |
| 9729 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { | 9729 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { |
| 9730 session_deps_.parse_alternative_services = true; | 9730 session_deps_.parse_alternative_services = true; |
| 9731 session_deps_.enable_alternative_service_with_different_host = false; | 9731 session_deps_.enable_alternative_service_with_different_host = false; |
| 9732 | 9732 |
| 9733 // Set an alternative service for origin. | 9733 // Set an alternative service for origin. |
| 9734 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9734 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 9735 HttpServerProperties& http_server_properties = | 9735 HttpServerProperties& http_server_properties = |
| 9736 *session->http_server_properties(); | 9736 *session->http_server_properties(); |
| 9737 HostPortPair http_host_port_pair("www.example.org", 80); | 9737 SchemeOriginPair http_origin("http", "www.example.org", 80); |
| 9738 AlternativeService alternative_service(QUIC, "", 80); | 9738 AlternativeService alternative_service(QUIC, "", 80); |
| 9739 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 9739 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 9740 http_server_properties.SetAlternativeService( | 9740 http_server_properties.SetAlternativeService(http_origin, alternative_service, |
| 9741 http_host_port_pair, alternative_service, 1.0, expiration); | 9741 1.0, expiration); |
| 9742 AlternativeServiceVector alternative_service_vector = | 9742 AlternativeServiceVector alternative_service_vector = |
| 9743 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9743 http_server_properties.GetAlternativeServices(http_origin); |
| 9744 EXPECT_EQ(1u, alternative_service_vector.size()); | 9744 EXPECT_EQ(1u, alternative_service_vector.size()); |
| 9745 | 9745 |
| 9746 // Send a clear header. | 9746 // Send a clear header. |
| 9747 MockRead data_reads[] = { | 9747 MockRead data_reads[] = { |
| 9748 MockRead("HTTP/1.1 200 OK\r\n"), | 9748 MockRead("HTTP/1.1 200 OK\r\n"), |
| 9749 MockRead("Alt-Svc: clear\r\n"), | 9749 MockRead("Alt-Svc: clear\r\n"), |
| 9750 MockRead("\r\n"), | 9750 MockRead("\r\n"), |
| 9751 MockRead("hello world"), | 9751 MockRead("hello world"), |
| 9752 MockRead(SYNCHRONOUS, OK), | 9752 MockRead(SYNCHRONOUS, OK), |
| 9753 }; | 9753 }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 9772 ASSERT_TRUE(response->headers.get() != nullptr); | 9772 ASSERT_TRUE(response->headers.get() != nullptr); |
| 9773 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9773 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9774 EXPECT_FALSE(response->was_fetched_via_spdy); | 9774 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9775 EXPECT_FALSE(response->was_npn_negotiated); | 9775 EXPECT_FALSE(response->was_npn_negotiated); |
| 9776 | 9776 |
| 9777 std::string response_data; | 9777 std::string response_data; |
| 9778 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9778 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9779 EXPECT_EQ("hello world", response_data); | 9779 EXPECT_EQ("hello world", response_data); |
| 9780 | 9780 |
| 9781 alternative_service_vector = | 9781 alternative_service_vector = |
| 9782 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9782 http_server_properties.GetAlternativeServices(http_origin); |
| 9783 EXPECT_TRUE(alternative_service_vector.empty()); | 9783 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9784 } | 9784 } |
| 9785 | 9785 |
| 9786 // Alternative Service headers must be ignored when | 9786 // Alternative Service headers must be ignored when |
| 9787 // |parse_alternative_services| is false. | 9787 // |parse_alternative_services| is false. |
| 9788 TEST_P(HttpNetworkTransactionTest, DoNotHonorAlternativeServiceHeader) { | 9788 TEST_P(HttpNetworkTransactionTest, DoNotHonorAlternativeServiceHeader) { |
| 9789 session_deps_.parse_alternative_services = false; | 9789 session_deps_.parse_alternative_services = false; |
| 9790 | 9790 |
| 9791 std::string alternative_service_http_header = | 9791 std::string alternative_service_http_header = |
| 9792 GetAlternativeServiceHttpHeader(); | 9792 GetAlternativeServiceHttpHeader(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9810 | 9810 |
| 9811 TestCompletionCallback callback; | 9811 TestCompletionCallback callback; |
| 9812 | 9812 |
| 9813 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); | 9813 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); |
| 9814 scoped_ptr<HttpTransaction> trans( | 9814 scoped_ptr<HttpTransaction> trans( |
| 9815 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9815 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9816 | 9816 |
| 9817 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9817 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9818 EXPECT_EQ(ERR_IO_PENDING, rv); | 9818 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9819 | 9819 |
| 9820 HostPortPair http_host_port_pair("www.example.org", 80); | 9820 SchemeOriginPair http_origin("http", "www.example.org", 80); |
| 9821 HttpServerProperties& http_server_properties = | 9821 HttpServerProperties& http_server_properties = |
| 9822 *session->http_server_properties(); | 9822 *session->http_server_properties(); |
| 9823 AlternativeServiceVector alternative_service_vector = | 9823 AlternativeServiceVector alternative_service_vector = |
| 9824 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9824 http_server_properties.GetAlternativeServices(http_origin); |
| 9825 EXPECT_TRUE(alternative_service_vector.empty()); | 9825 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9826 | 9826 |
| 9827 EXPECT_EQ(OK, callback.WaitForResult()); | 9827 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9828 | 9828 |
| 9829 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9829 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9830 ASSERT_TRUE(response != nullptr); | 9830 ASSERT_TRUE(response != nullptr); |
| 9831 ASSERT_TRUE(response->headers.get() != nullptr); | 9831 ASSERT_TRUE(response->headers.get() != nullptr); |
| 9832 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9832 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9833 EXPECT_FALSE(response->was_fetched_via_spdy); | 9833 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9834 EXPECT_FALSE(response->was_npn_negotiated); | 9834 EXPECT_FALSE(response->was_npn_negotiated); |
| 9835 | 9835 |
| 9836 std::string response_data; | 9836 std::string response_data; |
| 9837 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9837 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9838 EXPECT_EQ("hello world", response_data); | 9838 EXPECT_EQ("hello world", response_data); |
| 9839 | 9839 |
| 9840 alternative_service_vector = | 9840 alternative_service_vector = |
| 9841 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9841 http_server_properties.GetAlternativeServices(http_origin); |
| 9842 EXPECT_TRUE(alternative_service_vector.empty()); | 9842 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9843 } | 9843 } |
| 9844 | 9844 |
| 9845 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { | 9845 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { |
| 9846 session_deps_.parse_alternative_services = true; | 9846 session_deps_.parse_alternative_services = true; |
| 9847 session_deps_.enable_alternative_service_with_different_host = false; | 9847 session_deps_.enable_alternative_service_with_different_host = false; |
| 9848 | 9848 |
| 9849 MockRead data_reads[] = { | 9849 MockRead data_reads[] = { |
| 9850 MockRead("HTTP/1.1 200 OK\r\n"), | 9850 MockRead("HTTP/1.1 200 OK\r\n"), |
| 9851 MockRead("Alt-Svc: "), | 9851 MockRead("Alt-Svc: "), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 9868 | 9868 |
| 9869 TestCompletionCallback callback; | 9869 TestCompletionCallback callback; |
| 9870 | 9870 |
| 9871 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9871 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 9872 scoped_ptr<HttpTransaction> trans( | 9872 scoped_ptr<HttpTransaction> trans( |
| 9873 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9873 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9874 | 9874 |
| 9875 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9875 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9876 EXPECT_EQ(ERR_IO_PENDING, rv); | 9876 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9877 | 9877 |
| 9878 HostPortPair http_host_port_pair("www.example.org", 80); | 9878 SchemeOriginPair http_origin("http", "www.example.org", 80); |
| 9879 HttpServerProperties& http_server_properties = | 9879 HttpServerProperties& http_server_properties = |
| 9880 *session->http_server_properties(); | 9880 *session->http_server_properties(); |
| 9881 AlternativeServiceVector alternative_service_vector = | 9881 AlternativeServiceVector alternative_service_vector = |
| 9882 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9882 http_server_properties.GetAlternativeServices(http_origin); |
| 9883 EXPECT_TRUE(alternative_service_vector.empty()); | 9883 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9884 | 9884 |
| 9885 EXPECT_EQ(OK, callback.WaitForResult()); | 9885 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9886 | 9886 |
| 9887 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9887 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9888 ASSERT_TRUE(response != NULL); | 9888 ASSERT_TRUE(response != NULL); |
| 9889 ASSERT_TRUE(response->headers.get() != NULL); | 9889 ASSERT_TRUE(response->headers.get() != NULL); |
| 9890 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9890 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9891 EXPECT_FALSE(response->was_fetched_via_spdy); | 9891 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9892 EXPECT_FALSE(response->was_npn_negotiated); | 9892 EXPECT_FALSE(response->was_npn_negotiated); |
| 9893 | 9893 |
| 9894 std::string response_data; | 9894 std::string response_data; |
| 9895 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9895 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9896 EXPECT_EQ("hello world", response_data); | 9896 EXPECT_EQ("hello world", response_data); |
| 9897 | 9897 |
| 9898 alternative_service_vector = | 9898 alternative_service_vector = |
| 9899 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9899 http_server_properties.GetAlternativeServices(http_origin); |
| 9900 ASSERT_EQ(2u, alternative_service_vector.size()); | 9900 ASSERT_EQ(2u, alternative_service_vector.size()); |
| 9901 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9901 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9902 alternative_service_vector[0].protocol); | 9902 alternative_service_vector[0].protocol); |
| 9903 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); | 9903 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); |
| 9904 EXPECT_EQ(443, alternative_service_vector[0].port); | 9904 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 9905 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9905 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9906 alternative_service_vector[1].protocol); | 9906 alternative_service_vector[1].protocol); |
| 9907 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); | 9907 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); |
| 9908 EXPECT_EQ(1234, alternative_service_vector[1].port); | 9908 EXPECT_EQ(1234, alternative_service_vector[1].port); |
| 9909 } | 9909 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 9935 | 9935 |
| 9936 TestCompletionCallback callback; | 9936 TestCompletionCallback callback; |
| 9937 | 9937 |
| 9938 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9938 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 9939 scoped_ptr<HttpTransaction> trans( | 9939 scoped_ptr<HttpTransaction> trans( |
| 9940 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9940 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 9941 | 9941 |
| 9942 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9942 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 9943 EXPECT_EQ(ERR_IO_PENDING, rv); | 9943 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9944 | 9944 |
| 9945 HostPortPair http_host_port_pair("www.example.org", 80); | 9945 SchemeOriginPair http_origin("http", "www.example.org", 80); |
| 9946 HttpServerProperties& http_server_properties = | 9946 HttpServerProperties& http_server_properties = |
| 9947 *session->http_server_properties(); | 9947 *session->http_server_properties(); |
| 9948 AlternativeServiceVector alternative_service_vector = | 9948 AlternativeServiceVector alternative_service_vector = |
| 9949 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9949 http_server_properties.GetAlternativeServices(http_origin); |
| 9950 EXPECT_TRUE(alternative_service_vector.empty()); | 9950 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9951 | 9951 |
| 9952 EXPECT_EQ(OK, callback.WaitForResult()); | 9952 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9953 | 9953 |
| 9954 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9954 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9955 ASSERT_TRUE(response != NULL); | 9955 ASSERT_TRUE(response != NULL); |
| 9956 ASSERT_TRUE(response->headers.get() != NULL); | 9956 ASSERT_TRUE(response->headers.get() != NULL); |
| 9957 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9957 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9958 EXPECT_FALSE(response->was_fetched_via_spdy); | 9958 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9959 EXPECT_FALSE(response->was_npn_negotiated); | 9959 EXPECT_FALSE(response->was_npn_negotiated); |
| 9960 | 9960 |
| 9961 std::string response_data; | 9961 std::string response_data; |
| 9962 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9962 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9963 EXPECT_EQ("hello world", response_data); | 9963 EXPECT_EQ("hello world", response_data); |
| 9964 | 9964 |
| 9965 alternative_service_vector = | 9965 alternative_service_vector = |
| 9966 http_server_properties.GetAlternativeServices(http_host_port_pair); | 9966 http_server_properties.GetAlternativeServices(http_origin); |
| 9967 ASSERT_EQ(1u, alternative_service_vector.size()); | 9967 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 9968 EXPECT_EQ(443, alternative_service_vector[0].port); | 9968 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 9969 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9969 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9970 alternative_service_vector[0].protocol); | 9970 alternative_service_vector[0].protocol); |
| 9971 } | 9971 } |
| 9972 | 9972 |
| 9973 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) { | 9973 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) { |
| 9974 session_deps_.parse_alternative_services = false; | 9974 session_deps_.parse_alternative_services = false; |
| 9975 session_deps_.enable_alternative_service_with_different_host = false; | 9975 session_deps_.enable_alternative_service_with_different_host = false; |
| 9976 | 9976 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9987 request.load_flags = 0; | 9987 request.load_flags = 0; |
| 9988 | 9988 |
| 9989 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 9989 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 9990 | 9990 |
| 9991 session_deps_.socket_factory->AddSocketDataProvider(&data); | 9991 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 9992 | 9992 |
| 9993 TestCompletionCallback callback; | 9993 TestCompletionCallback callback; |
| 9994 | 9994 |
| 9995 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9995 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 9996 | 9996 |
| 9997 HostPortPair http_host_port_pair("www.example.org", 80); | 9997 SchemeOriginPair http_origin("http", "www.example.org", 80); |
| 9998 HttpServerProperties& http_server_properties = | 9998 HttpServerProperties& http_server_properties = |
| 9999 *session->http_server_properties(); | 9999 *session->http_server_properties(); |
| 10000 AlternativeService alternative_service(QUIC, "", 80); | 10000 AlternativeService alternative_service(QUIC, "", 80); |
| 10001 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10001 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10002 http_server_properties.SetAlternativeService( | 10002 http_server_properties.SetAlternativeService(http_origin, alternative_service, |
| 10003 http_host_port_pair, alternative_service, 1.0, expiration); | 10003 1.0, expiration); |
| 10004 | 10004 |
| 10005 AlternativeServiceVector alternative_service_vector = | 10005 AlternativeServiceVector alternative_service_vector = |
| 10006 http_server_properties.GetAlternativeServices(http_host_port_pair); | 10006 http_server_properties.GetAlternativeServices(http_origin); |
| 10007 ASSERT_EQ(1u, alternative_service_vector.size()); | 10007 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 10008 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); | 10008 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); |
| 10009 | 10009 |
| 10010 scoped_ptr<HttpTransaction> trans( | 10010 scoped_ptr<HttpTransaction> trans( |
| 10011 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10011 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10012 | 10012 |
| 10013 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10013 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10014 EXPECT_EQ(ERR_IO_PENDING, rv); | 10014 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10015 | 10015 |
| 10016 EXPECT_EQ(OK, callback.WaitForResult()); | 10016 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10017 | 10017 |
| 10018 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10018 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10019 ASSERT_TRUE(response != NULL); | 10019 ASSERT_TRUE(response != NULL); |
| 10020 ASSERT_TRUE(response->headers.get() != NULL); | 10020 ASSERT_TRUE(response->headers.get() != NULL); |
| 10021 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10021 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10022 EXPECT_FALSE(response->was_fetched_via_spdy); | 10022 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10023 EXPECT_FALSE(response->was_npn_negotiated); | 10023 EXPECT_FALSE(response->was_npn_negotiated); |
| 10024 | 10024 |
| 10025 std::string response_data; | 10025 std::string response_data; |
| 10026 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10026 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10027 EXPECT_EQ("hello world", response_data); | 10027 EXPECT_EQ("hello world", response_data); |
| 10028 | 10028 |
| 10029 alternative_service_vector = | 10029 alternative_service_vector = |
| 10030 http_server_properties.GetAlternativeServices(http_host_port_pair); | 10030 http_server_properties.GetAlternativeServices(http_origin); |
| 10031 EXPECT_TRUE(alternative_service_vector.empty()); | 10031 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10032 } | 10032 } |
| 10033 | 10033 |
| 10034 // When |session_deps_.parse_alternative_services = true| and the response has | 10034 // When |session_deps_.parse_alternative_services = true| and the response has |
| 10035 // an Alt-Svc header, then the Alternate-Protocol header is not parsed. | 10035 // an Alt-Svc header, then the Alternate-Protocol header is not parsed. |
| 10036 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) { | 10036 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) { |
| 10037 session_deps_.parse_alternative_services = true; | 10037 session_deps_.parse_alternative_services = true; |
| 10038 session_deps_.enable_alternative_service_with_different_host = false; | 10038 session_deps_.enable_alternative_service_with_different_host = false; |
| 10039 | 10039 |
| 10040 std::string alternative_service_http_header = | 10040 std::string alternative_service_http_header = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10061 | 10061 |
| 10062 TestCompletionCallback callback; | 10062 TestCompletionCallback callback; |
| 10063 | 10063 |
| 10064 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10064 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10065 scoped_ptr<HttpTransaction> trans( | 10065 scoped_ptr<HttpTransaction> trans( |
| 10066 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10066 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10067 | 10067 |
| 10068 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10068 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10069 EXPECT_EQ(ERR_IO_PENDING, rv); | 10069 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10070 | 10070 |
| 10071 HostPortPair http_host_port_pair("www.example.org", 80); | 10071 SchemeOriginPair http_origin("http", "www.example.org", 80); |
| 10072 HttpServerProperties& http_server_properties = | 10072 HttpServerProperties& http_server_properties = |
| 10073 *session->http_server_properties(); | 10073 *session->http_server_properties(); |
| 10074 AlternativeServiceVector alternative_service_vector = | 10074 AlternativeServiceVector alternative_service_vector = |
| 10075 http_server_properties.GetAlternativeServices(http_host_port_pair); | 10075 http_server_properties.GetAlternativeServices(http_origin); |
| 10076 EXPECT_TRUE(alternative_service_vector.empty()); | 10076 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10077 | 10077 |
| 10078 EXPECT_EQ(OK, callback.WaitForResult()); | 10078 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10079 | 10079 |
| 10080 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10080 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10081 ASSERT_TRUE(response != NULL); | 10081 ASSERT_TRUE(response != NULL); |
| 10082 ASSERT_TRUE(response->headers.get() != NULL); | 10082 ASSERT_TRUE(response->headers.get() != NULL); |
| 10083 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10083 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10084 EXPECT_FALSE(response->was_fetched_via_spdy); | 10084 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10085 EXPECT_FALSE(response->was_npn_negotiated); | 10085 EXPECT_FALSE(response->was_npn_negotiated); |
| 10086 | 10086 |
| 10087 std::string response_data; | 10087 std::string response_data; |
| 10088 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10088 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10089 EXPECT_EQ("hello world", response_data); | 10089 EXPECT_EQ("hello world", response_data); |
| 10090 | 10090 |
| 10091 alternative_service_vector = | 10091 alternative_service_vector = |
| 10092 http_server_properties.GetAlternativeServices(http_host_port_pair); | 10092 http_server_properties.GetAlternativeServices(http_origin); |
| 10093 ASSERT_EQ(1u, alternative_service_vector.size()); | 10093 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 10094 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 10094 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 10095 alternative_service_vector[0].protocol); | 10095 alternative_service_vector[0].protocol); |
| 10096 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); | 10096 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); |
| 10097 EXPECT_EQ(443, alternative_service_vector[0].port); | 10097 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 10098 } | 10098 } |
| 10099 | 10099 |
| 10100 // When |enable_alternative_service_with_different_host| is false, do not | 10100 // When |enable_alternative_service_with_different_host| is false, do not |
| 10101 // observe alternative service entries that point to a different host. | 10101 // observe alternative service entries that point to a different host. |
| 10102 TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) { | 10102 TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10123 | 10123 |
| 10124 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); | 10124 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); |
| 10125 | 10125 |
| 10126 base::WeakPtr<HttpServerProperties> http_server_properties = | 10126 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10127 session->http_server_properties(); | 10127 session->http_server_properties(); |
| 10128 AlternativeService alternative_service( | 10128 AlternativeService alternative_service( |
| 10129 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org", | 10129 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org", |
| 10130 80); | 10130 80); |
| 10131 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10131 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10132 http_server_properties->SetAlternativeService( | 10132 http_server_properties->SetAlternativeService( |
| 10133 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration); | 10133 SchemeOriginPair::FromURL(request.url), alternative_service, 1.0, |
| 10134 expiration); |
| 10134 | 10135 |
| 10135 scoped_ptr<HttpTransaction> trans( | 10136 scoped_ptr<HttpTransaction> trans( |
| 10136 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10137 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10137 TestCompletionCallback callback; | 10138 TestCompletionCallback callback; |
| 10138 | 10139 |
| 10139 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10140 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10140 // The connetion to origin was refused, and the alternative service should not | 10141 // The connetion to origin was refused, and the alternative service should not |
| 10141 // be used (even though mock data are there), therefore the request should | 10142 // be used (even though mock data are there), therefore the request should |
| 10142 // fail. | 10143 // fail. |
| 10143 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); | 10144 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10176 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); | 10177 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); |
| 10177 | 10178 |
| 10178 // Set up a QUIC alternative service for origin. | 10179 // Set up a QUIC alternative service for origin. |
| 10179 session_deps_.parse_alternative_services = true; | 10180 session_deps_.parse_alternative_services = true; |
| 10180 session_deps_.enable_alternative_service_with_different_host = false; | 10181 session_deps_.enable_alternative_service_with_different_host = false; |
| 10181 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10182 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10182 base::WeakPtr<HttpServerProperties> http_server_properties = | 10183 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10183 session->http_server_properties(); | 10184 session->http_server_properties(); |
| 10184 AlternativeService alternative_service(QUIC, alternative); | 10185 AlternativeService alternative_service(QUIC, alternative); |
| 10185 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10186 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10186 http_server_properties->SetAlternativeService(origin, alternative_service, | 10187 http_server_properties->SetAlternativeService( |
| 10187 1.0, expiration); | 10188 SchemeOriginPair("https", origin), alternative_service, 1.0, expiration); |
| 10188 // Mark the QUIC alternative service as broken. | 10189 // Mark the QUIC alternative service as broken. |
| 10189 http_server_properties->MarkAlternativeServiceBroken(alternative_service); | 10190 http_server_properties->MarkAlternativeServiceBroken(alternative_service); |
| 10190 | 10191 |
| 10191 scoped_ptr<HttpTransaction> trans( | 10192 scoped_ptr<HttpTransaction> trans( |
| 10192 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10193 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10193 HttpRequestInfo request; | 10194 HttpRequestInfo request; |
| 10194 request.method = "GET"; | 10195 request.method = "GET"; |
| 10195 request.url = GURL(origin_url); | 10196 request.url = GURL(origin_url); |
| 10196 request.load_flags = 0; | 10197 request.load_flags = 0; |
| 10197 TestCompletionCallback callback; | 10198 TestCompletionCallback callback; |
| 10198 NetErrorDetails details; | 10199 NetErrorDetails details; |
| 10199 EXPECT_FALSE(details.quic_broken); | 10200 EXPECT_FALSE(details.quic_broken); |
| 10200 | 10201 |
| 10201 trans->Start(&request, callback.callback(), BoundNetLog()); | 10202 trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10202 trans->PopulateNetErrorDetails(&details); | 10203 trans->PopulateNetErrorDetails(&details); |
| 10203 EXPECT_TRUE(details.quic_broken); | 10204 EXPECT_TRUE(details.quic_broken); |
| 10204 } | 10205 } |
| 10205 | 10206 |
| 10206 TEST_P(HttpNetworkTransactionTest, IdentifyQuicNotBroken) { | 10207 TEST_P(HttpNetworkTransactionTest, IdentifyQuicNotBroken) { |
| 10207 HostPortPair origin("origin.example.org", 443); | 10208 // HostPortPair origin("origin.example.org", 443); |
| 10209 SchemeOriginPair scheme_origin("https", "origin.example.org", 443); |
| 10208 HostPortPair alternative1("alternative1.example.org", 443); | 10210 HostPortPair alternative1("alternative1.example.org", 443); |
| 10209 HostPortPair alternative2("alternative2.example.org", 443); | 10211 HostPortPair alternative2("alternative2.example.org", 443); |
| 10210 std::string origin_url = "https://origin.example.org:443"; | 10212 std::string origin_url = "https://origin.example.org:443"; |
| 10211 std::string alternative_url1 = "https://alternative1.example.org:443"; | 10213 std::string alternative_url1 = "https://alternative1.example.org:443"; |
| 10212 std::string alternative_url2 = "https://alternative2.example.org:443"; | 10214 std::string alternative_url2 = "https://alternative2.example.org:443"; |
| 10213 | 10215 |
| 10214 // Negotiate HTTP/1.1 with alternative1.example.org. | 10216 // Negotiate HTTP/1.1 with alternative1.example.org. |
| 10215 SSLSocketDataProvider ssl(ASYNC, OK); | 10217 SSLSocketDataProvider ssl(ASYNC, OK); |
| 10216 ssl.SetNextProto(kProtoHTTP11); | 10218 ssl.SetNextProto(kProtoHTTP11); |
| 10217 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 10219 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10250 AlternativeService alternative_service1(QUIC, alternative1); | 10252 AlternativeService alternative_service1(QUIC, alternative1); |
| 10251 AlternativeServiceInfo alternative_service_info1(alternative_service1, 1.0, | 10253 AlternativeServiceInfo alternative_service_info1(alternative_service1, 1.0, |
| 10252 expiration); | 10254 expiration); |
| 10253 alternative_service_info_vector.push_back(alternative_service_info1); | 10255 alternative_service_info_vector.push_back(alternative_service_info1); |
| 10254 AlternativeService alternative_service2(QUIC, alternative2); | 10256 AlternativeService alternative_service2(QUIC, alternative2); |
| 10255 AlternativeServiceInfo alternative_service_info2(alternative_service2, 1.0, | 10257 AlternativeServiceInfo alternative_service_info2(alternative_service2, 1.0, |
| 10256 expiration); | 10258 expiration); |
| 10257 alternative_service_info_vector.push_back(alternative_service_info2); | 10259 alternative_service_info_vector.push_back(alternative_service_info2); |
| 10258 | 10260 |
| 10259 http_server_properties->SetAlternativeServices( | 10261 http_server_properties->SetAlternativeServices( |
| 10260 origin, alternative_service_info_vector); | 10262 scheme_origin, alternative_service_info_vector); |
| 10261 | 10263 |
| 10262 // Mark one of the QUIC alternative service as broken. | 10264 // Mark one of the QUIC alternative service as broken. |
| 10263 http_server_properties->MarkAlternativeServiceBroken(alternative_service1); | 10265 http_server_properties->MarkAlternativeServiceBroken(alternative_service1); |
| 10264 | 10266 |
| 10265 const AlternativeServiceVector alternative_service_vector = | 10267 const AlternativeServiceVector alternative_service_vector = |
| 10266 http_server_properties->GetAlternativeServices(origin); | 10268 http_server_properties->GetAlternativeServices(scheme_origin); |
| 10267 | 10269 |
| 10268 scoped_ptr<HttpTransaction> trans( | 10270 scoped_ptr<HttpTransaction> trans( |
| 10269 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10271 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10270 HttpRequestInfo request; | 10272 HttpRequestInfo request; |
| 10271 request.method = "GET"; | 10273 request.method = "GET"; |
| 10272 request.url = GURL(origin_url); | 10274 request.url = GURL(origin_url); |
| 10273 request.load_flags = 0; | 10275 request.load_flags = 0; |
| 10274 TestCompletionCallback callback; | 10276 TestCompletionCallback callback; |
| 10275 NetErrorDetails details; | 10277 NetErrorDetails details; |
| 10276 EXPECT_FALSE(details.quic_broken); | 10278 EXPECT_FALSE(details.quic_broken); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 10301 MockRead(ASYNC, OK), | 10303 MockRead(ASYNC, OK), |
| 10302 }; | 10304 }; |
| 10303 StaticSocketDataProvider second_data( | 10305 StaticSocketDataProvider second_data( |
| 10304 data_reads, arraysize(data_reads), NULL, 0); | 10306 data_reads, arraysize(data_reads), NULL, 0); |
| 10305 session_deps_.socket_factory->AddSocketDataProvider(&second_data); | 10307 session_deps_.socket_factory->AddSocketDataProvider(&second_data); |
| 10306 | 10308 |
| 10307 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10309 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10308 | 10310 |
| 10309 base::WeakPtr<HttpServerProperties> http_server_properties = | 10311 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10310 session->http_server_properties(); | 10312 session->http_server_properties(); |
| 10311 const HostPortPair host_port_pair = HostPortPair::FromURL(request.url); | 10313 SchemeOriginPair scheme_origin = SchemeOriginPair::FromURL(request.url); |
| 10314 |
| 10312 // Port must be < 1024, or the header will be ignored (since initial port was | 10315 // Port must be < 1024, or the header will be ignored (since initial port was |
| 10313 // port 80 (another restricted port). | 10316 // port 80 (another restricted port). |
| 10314 const AlternativeService alternative_service( | 10317 const AlternativeService alternative_service( |
| 10315 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10318 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10316 666); // Port is ignored by MockConnect anyway. | 10319 666); // Port is ignored by MockConnect anyway. |
| 10317 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10320 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10318 http_server_properties->SetAlternativeService( | 10321 http_server_properties->SetAlternativeService( |
| 10319 host_port_pair, alternative_service, 1.0, expiration); | 10322 scheme_origin, alternative_service, 1.0, expiration); |
| 10320 | 10323 |
| 10321 scoped_ptr<HttpTransaction> trans( | 10324 scoped_ptr<HttpTransaction> trans( |
| 10322 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10325 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10323 TestCompletionCallback callback; | 10326 TestCompletionCallback callback; |
| 10324 | 10327 |
| 10325 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10328 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10326 EXPECT_EQ(ERR_IO_PENDING, rv); | 10329 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10327 EXPECT_EQ(OK, callback.WaitForResult()); | 10330 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10328 | 10331 |
| 10329 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10332 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 10330 ASSERT_TRUE(response != NULL); | 10333 ASSERT_TRUE(response != NULL); |
| 10331 ASSERT_TRUE(response->headers.get() != NULL); | 10334 ASSERT_TRUE(response->headers.get() != NULL); |
| 10332 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10335 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10333 | 10336 |
| 10334 std::string response_data; | 10337 std::string response_data; |
| 10335 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10338 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10336 EXPECT_EQ("hello world", response_data); | 10339 EXPECT_EQ("hello world", response_data); |
| 10337 | 10340 |
| 10338 const AlternativeServiceVector alternative_service_vector = | 10341 const AlternativeServiceVector alternative_service_vector = |
| 10339 http_server_properties->GetAlternativeServices(host_port_pair); | 10342 http_server_properties->GetAlternativeServices(scheme_origin); |
| 10340 ASSERT_EQ(1u, alternative_service_vector.size()); | 10343 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 10341 EXPECT_EQ(alternative_service, alternative_service_vector[0]); | 10344 EXPECT_EQ(alternative_service, alternative_service_vector[0]); |
| 10342 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken( | 10345 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken( |
| 10343 alternative_service_vector[0])); | 10346 alternative_service_vector[0])); |
| 10344 } | 10347 } |
| 10345 | 10348 |
| 10346 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10349 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10347 // to an unrestricted (port >= 1024) when the original traffic was on a | 10350 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10348 // restricted port (port < 1024). Ensure that we can redirect in all other | 10351 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10349 // cases. | 10352 // cases. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 10374 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10377 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10375 | 10378 |
| 10376 base::WeakPtr<HttpServerProperties> http_server_properties = | 10379 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10377 session->http_server_properties(); | 10380 session->http_server_properties(); |
| 10378 const int kUnrestrictedAlternatePort = 1024; | 10381 const int kUnrestrictedAlternatePort = 1024; |
| 10379 AlternativeService alternative_service( | 10382 AlternativeService alternative_service( |
| 10380 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10383 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10381 kUnrestrictedAlternatePort); | 10384 kUnrestrictedAlternatePort); |
| 10382 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10385 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10383 http_server_properties->SetAlternativeService( | 10386 http_server_properties->SetAlternativeService( |
| 10384 HostPortPair::FromURL(restricted_port_request.url), alternative_service, | 10387 SchemeOriginPair::FromURL(restricted_port_request.url), |
| 10385 1.0, expiration); | 10388 alternative_service, 1.0, expiration); |
| 10386 | 10389 |
| 10387 scoped_ptr<HttpTransaction> trans( | 10390 scoped_ptr<HttpTransaction> trans( |
| 10388 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10391 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10389 TestCompletionCallback callback; | 10392 TestCompletionCallback callback; |
| 10390 | 10393 |
| 10391 int rv = trans->Start( | 10394 int rv = trans->Start( |
| 10392 &restricted_port_request, | 10395 &restricted_port_request, |
| 10393 callback.callback(), BoundNetLog()); | 10396 callback.callback(), BoundNetLog()); |
| 10394 EXPECT_EQ(ERR_IO_PENDING, rv); | 10397 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10395 // Invalid change to unrestricted port should fail. | 10398 // Invalid change to unrestricted port should fail. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10427 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10430 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10428 | 10431 |
| 10429 base::WeakPtr<HttpServerProperties> http_server_properties = | 10432 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10430 session->http_server_properties(); | 10433 session->http_server_properties(); |
| 10431 const int kUnrestrictedAlternatePort = 1024; | 10434 const int kUnrestrictedAlternatePort = 1024; |
| 10432 AlternativeService alternative_service( | 10435 AlternativeService alternative_service( |
| 10433 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10436 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10434 kUnrestrictedAlternatePort); | 10437 kUnrestrictedAlternatePort); |
| 10435 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10438 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10436 http_server_properties->SetAlternativeService( | 10439 http_server_properties->SetAlternativeService( |
| 10437 HostPortPair::FromURL(restricted_port_request.url), alternative_service, | 10440 SchemeOriginPair::FromURL(restricted_port_request.url), |
| 10438 1.0, expiration); | 10441 alternative_service, 1.0, expiration); |
| 10439 | 10442 |
| 10440 scoped_ptr<HttpTransaction> trans( | 10443 scoped_ptr<HttpTransaction> trans( |
| 10441 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10444 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10442 TestCompletionCallback callback; | 10445 TestCompletionCallback callback; |
| 10443 | 10446 |
| 10444 EXPECT_EQ(ERR_IO_PENDING, trans->Start( | 10447 EXPECT_EQ(ERR_IO_PENDING, trans->Start( |
| 10445 &restricted_port_request, | 10448 &restricted_port_request, |
| 10446 callback.callback(), BoundNetLog())); | 10449 callback.callback(), BoundNetLog())); |
| 10447 // Change to unrestricted port should succeed. | 10450 // Change to unrestricted port should succeed. |
| 10448 EXPECT_EQ(OK, callback.WaitForResult()); | 10451 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 10479 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10482 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10480 | 10483 |
| 10481 base::WeakPtr<HttpServerProperties> http_server_properties = | 10484 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10482 session->http_server_properties(); | 10485 session->http_server_properties(); |
| 10483 const int kRestrictedAlternatePort = 80; | 10486 const int kRestrictedAlternatePort = 80; |
| 10484 AlternativeService alternative_service( | 10487 AlternativeService alternative_service( |
| 10485 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10488 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10486 kRestrictedAlternatePort); | 10489 kRestrictedAlternatePort); |
| 10487 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10490 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10488 http_server_properties->SetAlternativeService( | 10491 http_server_properties->SetAlternativeService( |
| 10489 HostPortPair::FromURL(restricted_port_request.url), alternative_service, | 10492 SchemeOriginPair::FromURL(restricted_port_request.url), |
| 10490 1.0, expiration); | 10493 alternative_service, 1.0, expiration); |
| 10491 | 10494 |
| 10492 scoped_ptr<HttpTransaction> trans( | 10495 scoped_ptr<HttpTransaction> trans( |
| 10493 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10496 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10494 TestCompletionCallback callback; | 10497 TestCompletionCallback callback; |
| 10495 | 10498 |
| 10496 int rv = trans->Start( | 10499 int rv = trans->Start( |
| 10497 &restricted_port_request, | 10500 &restricted_port_request, |
| 10498 callback.callback(), BoundNetLog()); | 10501 callback.callback(), BoundNetLog()); |
| 10499 EXPECT_EQ(ERR_IO_PENDING, rv); | 10502 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10500 // Valid change to restricted port should pass. | 10503 // Valid change to restricted port should pass. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10532 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10535 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10533 | 10536 |
| 10534 base::WeakPtr<HttpServerProperties> http_server_properties = | 10537 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10535 session->http_server_properties(); | 10538 session->http_server_properties(); |
| 10536 const int kRestrictedAlternatePort = 80; | 10539 const int kRestrictedAlternatePort = 80; |
| 10537 AlternativeService alternative_service( | 10540 AlternativeService alternative_service( |
| 10538 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10541 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10539 kRestrictedAlternatePort); | 10542 kRestrictedAlternatePort); |
| 10540 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10543 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10541 http_server_properties->SetAlternativeService( | 10544 http_server_properties->SetAlternativeService( |
| 10542 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, | 10545 SchemeOriginPair::FromURL(unrestricted_port_request.url), |
| 10543 1.0, expiration); | 10546 alternative_service, 1.0, expiration); |
| 10544 | 10547 |
| 10545 scoped_ptr<HttpTransaction> trans( | 10548 scoped_ptr<HttpTransaction> trans( |
| 10546 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10549 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10547 TestCompletionCallback callback; | 10550 TestCompletionCallback callback; |
| 10548 | 10551 |
| 10549 int rv = trans->Start( | 10552 int rv = trans->Start( |
| 10550 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 10553 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
| 10551 EXPECT_EQ(ERR_IO_PENDING, rv); | 10554 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10552 // Valid change to restricted port should pass. | 10555 // Valid change to restricted port should pass. |
| 10553 EXPECT_EQ(OK, callback.WaitForResult()); | 10556 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 10584 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10587 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10585 | 10588 |
| 10586 base::WeakPtr<HttpServerProperties> http_server_properties = | 10589 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10587 session->http_server_properties(); | 10590 session->http_server_properties(); |
| 10588 const int kUnrestrictedAlternatePort = 1025; | 10591 const int kUnrestrictedAlternatePort = 1025; |
| 10589 AlternativeService alternative_service( | 10592 AlternativeService alternative_service( |
| 10590 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10593 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10591 kUnrestrictedAlternatePort); | 10594 kUnrestrictedAlternatePort); |
| 10592 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10595 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10593 http_server_properties->SetAlternativeService( | 10596 http_server_properties->SetAlternativeService( |
| 10594 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, | 10597 SchemeOriginPair::FromURL(unrestricted_port_request.url), |
| 10595 1.0, expiration); | 10598 alternative_service, 1.0, expiration); |
| 10596 | 10599 |
| 10597 scoped_ptr<HttpTransaction> trans( | 10600 scoped_ptr<HttpTransaction> trans( |
| 10598 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10601 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10599 TestCompletionCallback callback; | 10602 TestCompletionCallback callback; |
| 10600 | 10603 |
| 10601 int rv = trans->Start( | 10604 int rv = trans->Start( |
| 10602 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 10605 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
| 10603 EXPECT_EQ(ERR_IO_PENDING, rv); | 10606 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10604 // Valid change to an unrestricted port should pass. | 10607 // Valid change to an unrestricted port should pass. |
| 10605 EXPECT_EQ(OK, callback.WaitForResult()); | 10608 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 10631 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10634 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10632 | 10635 |
| 10633 base::WeakPtr<HttpServerProperties> http_server_properties = | 10636 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10634 session->http_server_properties(); | 10637 session->http_server_properties(); |
| 10635 const int kUnsafePort = 7; | 10638 const int kUnsafePort = 7; |
| 10636 AlternativeService alternative_service( | 10639 AlternativeService alternative_service( |
| 10637 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", | 10640 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", |
| 10638 kUnsafePort); | 10641 kUnsafePort); |
| 10639 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 10642 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10640 http_server_properties->SetAlternativeService( | 10643 http_server_properties->SetAlternativeService( |
| 10641 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration); | 10644 SchemeOriginPair::FromURL(request.url), alternative_service, 1.0, |
| 10645 expiration); |
| 10642 | 10646 |
| 10643 scoped_ptr<HttpTransaction> trans( | 10647 scoped_ptr<HttpTransaction> trans( |
| 10644 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10648 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 10645 TestCompletionCallback callback; | 10649 TestCompletionCallback callback; |
| 10646 | 10650 |
| 10647 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10651 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10648 EXPECT_EQ(ERR_IO_PENDING, rv); | 10652 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10649 // The HTTP request should succeed. | 10653 // The HTTP request should succeed. |
| 10650 EXPECT_EQ(OK, callback.WaitForResult()); | 10654 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10651 | 10655 |
| (...skipping 2710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13362 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); | 13366 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); |
| 13363 | 13367 |
| 13364 session_deps_.parse_alternative_services = true; | 13368 session_deps_.parse_alternative_services = true; |
| 13365 session_deps_.enable_alternative_service_with_different_host = true; | 13369 session_deps_.enable_alternative_service_with_different_host = true; |
| 13366 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13370 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13367 base::WeakPtr<HttpServerProperties> http_server_properties = | 13371 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13368 session->http_server_properties(); | 13372 session->http_server_properties(); |
| 13369 AlternativeService alternative_service( | 13373 AlternativeService alternative_service( |
| 13370 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13374 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13371 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13375 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13372 http_server_properties->SetAlternativeService(origin, alternative_service, | 13376 http_server_properties->SetAlternativeService( |
| 13373 1.0, expiration); | 13377 SchemeOriginPair("https", origin), alternative_service, 1.0, |
| 13378 expiration); |
| 13374 | 13379 |
| 13375 // First request to alternative. | 13380 // First request to alternative. |
| 13376 if (pooling) { | 13381 if (pooling) { |
| 13377 scoped_ptr<HttpTransaction> trans0( | 13382 scoped_ptr<HttpTransaction> trans0( |
| 13378 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13383 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13379 HttpRequestInfo request0; | 13384 HttpRequestInfo request0; |
| 13380 request0.method = "GET"; | 13385 request0.method = "GET"; |
| 13381 request0.url = GURL(url0); | 13386 request0.url = GURL(url0); |
| 13382 request0.load_flags = 0; | 13387 request0.load_flags = 0; |
| 13383 TestCompletionCallback callback0; | 13388 TestCompletionCallback callback0; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13467 | 13472 |
| 13468 // Set up alternative service for origin. | 13473 // Set up alternative service for origin. |
| 13469 session_deps_.parse_alternative_services = true; | 13474 session_deps_.parse_alternative_services = true; |
| 13470 session_deps_.enable_alternative_service_with_different_host = true; | 13475 session_deps_.enable_alternative_service_with_different_host = true; |
| 13471 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13476 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13472 base::WeakPtr<HttpServerProperties> http_server_properties = | 13477 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13473 session->http_server_properties(); | 13478 session->http_server_properties(); |
| 13474 AlternativeService alternative_service( | 13479 AlternativeService alternative_service( |
| 13475 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13480 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13476 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13481 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13477 http_server_properties->SetAlternativeService(origin, alternative_service, | 13482 http_server_properties->SetAlternativeService( |
| 13478 1.0, expiration); | 13483 SchemeOriginPair("https", origin), alternative_service, 1.0, expiration); |
| 13479 | 13484 |
| 13480 scoped_ptr<HttpTransaction> trans( | 13485 scoped_ptr<HttpTransaction> trans( |
| 13481 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13486 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13482 HttpRequestInfo request; | 13487 HttpRequestInfo request; |
| 13483 request.method = "GET"; | 13488 request.method = "GET"; |
| 13484 request.url = GURL("https://origin.example.org:443"); | 13489 request.url = GURL("https://origin.example.org:443"); |
| 13485 request.load_flags = 0; | 13490 request.load_flags = 0; |
| 13486 TestCompletionCallback callback; | 13491 TestCompletionCallback callback; |
| 13487 | 13492 |
| 13488 // 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 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13541 | 13546 |
| 13542 // Set up alternative service for origin. | 13547 // Set up alternative service for origin. |
| 13543 session_deps_.parse_alternative_services = true; | 13548 session_deps_.parse_alternative_services = true; |
| 13544 session_deps_.enable_alternative_service_with_different_host = true; | 13549 session_deps_.enable_alternative_service_with_different_host = true; |
| 13545 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13550 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13546 base::WeakPtr<HttpServerProperties> http_server_properties = | 13551 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13547 session->http_server_properties(); | 13552 session->http_server_properties(); |
| 13548 AlternativeService alternative_service( | 13553 AlternativeService alternative_service( |
| 13549 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13554 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13550 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13555 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13551 http_server_properties->SetAlternativeService(origin, alternative_service, | 13556 http_server_properties->SetAlternativeService( |
| 13552 1.0, expiration); | 13557 SchemeOriginPair("https", origin), alternative_service, 1.0, expiration); |
| 13553 | 13558 |
| 13554 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 13559 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 13555 HttpRequestInfo request1; | 13560 HttpRequestInfo request1; |
| 13556 request1.method = "GET"; | 13561 request1.method = "GET"; |
| 13557 request1.url = GURL("https://origin.example.org:443"); | 13562 request1.url = GURL("https://origin.example.org:443"); |
| 13558 request1.load_flags = 0; | 13563 request1.load_flags = 0; |
| 13559 TestCompletionCallback callback1; | 13564 TestCompletionCallback callback1; |
| 13560 | 13565 |
| 13561 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); | 13566 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); |
| 13562 rv = callback1.GetResult(rv); | 13567 rv = callback1.GetResult(rv); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13651 | 13656 |
| 13652 // Set up alternative service for origin. | 13657 // Set up alternative service for origin. |
| 13653 session_deps_.parse_alternative_services = true; | 13658 session_deps_.parse_alternative_services = true; |
| 13654 session_deps_.enable_alternative_service_with_different_host = false; | 13659 session_deps_.enable_alternative_service_with_different_host = false; |
| 13655 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13660 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13656 base::WeakPtr<HttpServerProperties> http_server_properties = | 13661 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13657 session->http_server_properties(); | 13662 session->http_server_properties(); |
| 13658 AlternativeService alternative_service( | 13663 AlternativeService alternative_service( |
| 13659 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13664 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13660 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13665 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13661 http_server_properties->SetAlternativeService(origin, alternative_service, | 13666 http_server_properties->SetAlternativeService( |
| 13662 1.0, expiration); | 13667 SchemeOriginPair("https", origin), alternative_service, 1.0, expiration); |
| 13663 | 13668 |
| 13664 // First transaction to alternative to open an HTTP/1.1 socket. | 13669 // First transaction to alternative to open an HTTP/1.1 socket. |
| 13665 scoped_ptr<HttpTransaction> trans1( | 13670 scoped_ptr<HttpTransaction> trans1( |
| 13666 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13671 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13667 HttpRequestInfo request1; | 13672 HttpRequestInfo request1; |
| 13668 request1.method = "GET"; | 13673 request1.method = "GET"; |
| 13669 request1.url = GURL(alternative_url); | 13674 request1.url = GURL(alternative_url); |
| 13670 request1.load_flags = 0; | 13675 request1.load_flags = 0; |
| 13671 TestCompletionCallback callback1; | 13676 TestCompletionCallback callback1; |
| 13672 | 13677 |
| (...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15959 base::MessageLoop::current()->RunUntilIdle(); | 15964 base::MessageLoop::current()->RunUntilIdle(); |
| 15960 | 15965 |
| 15961 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15966 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15962 HttpRequestHeaders headers; | 15967 HttpRequestHeaders headers; |
| 15963 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15968 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15964 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15969 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15965 } | 15970 } |
| 15966 #endif // !defined(OS_IOS) | 15971 #endif // !defined(OS_IOS) |
| 15967 | 15972 |
| 15968 } // namespace net | 15973 } // namespace net |
| OLD | NEW |