| 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 | 10 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 const char* GetAlternateProtocolFromParam() { | 323 const char* GetAlternateProtocolFromParam() { |
| 324 return AlternateProtocolToString( | 324 return AlternateProtocolToString( |
| 325 AlternateProtocolFromNextProto(GetProtocol())); | 325 AlternateProtocolFromNextProto(GetProtocol())); |
| 326 } | 326 } |
| 327 | 327 |
| 328 std::string GetAlternativeServiceHttpHeader() { | 328 std::string GetAlternativeServiceHttpHeader() { |
| 329 return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() + | 329 return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() + |
| 330 "=\"www.example.com:443\"\r\n"; | 330 "=\"www.example.com:443\"\r\n"; |
| 331 } | 331 } |
| 332 | 332 |
| 333 std::string GetAlternateProtocolHttpHeader() { | |
| 334 return std::string("Alternate-Protocol: 443:") + | |
| 335 GetAlternateProtocolFromParam() + "\r\n"; | |
| 336 } | |
| 337 | |
| 338 // Either |write_failure| specifies a write failure or |read_failure| | 333 // Either |write_failure| specifies a write failure or |read_failure| |
| 339 // specifies a read failure when using a reused socket. In either case, the | 334 // specifies a read failure when using a reused socket. In either case, the |
| 340 // failure should cause the network transaction to resend the request, and the | 335 // failure should cause the network transaction to resend the request, and the |
| 341 // other argument should be NULL. | 336 // other argument should be NULL. |
| 342 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure, | 337 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure, |
| 343 const MockRead* read_failure); | 338 const MockRead* read_failure); |
| 344 | 339 |
| 345 // Either |write_failure| specifies a write failure or |read_failure| | 340 // Either |write_failure| specifies a write failure or |read_failure| |
| 346 // specifies a read failure when using a reused socket. In either case, the | 341 // specifies a read failure when using a reused socket. In either case, the |
| 347 // failure should cause the network transaction to resend the request, and the | 342 // failure should cause the network transaction to resend the request, and the |
| (...skipping 8506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8854 true, | 8849 true, |
| 8855 }, | 8850 }, |
| 8856 { | 8851 { |
| 8857 "", // unused | 8852 "", // unused |
| 8858 "http://host.with.alternate/direct", | 8853 "http://host.with.alternate/direct", |
| 8859 "ssl/host.with.alternate:443", | 8854 "ssl/host.with.alternate:443", |
| 8860 true, | 8855 true, |
| 8861 }, | 8856 }, |
| 8862 }; | 8857 }; |
| 8863 | 8858 |
| 8864 session_deps_.parse_alternative_services = true; | |
| 8865 session_deps_.enable_alternative_service_with_different_host = false; | 8859 session_deps_.enable_alternative_service_with_different_host = false; |
| 8866 | 8860 |
| 8867 for (size_t i = 0; i < arraysize(tests); ++i) { | 8861 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 8868 session_deps_.proxy_service = | 8862 session_deps_.proxy_service = |
| 8869 ProxyService::CreateFixed(tests[i].proxy_server); | 8863 ProxyService::CreateFixed(tests[i].proxy_server); |
| 8870 std::unique_ptr<HttpNetworkSession> session( | 8864 std::unique_ptr<HttpNetworkSession> session( |
| 8871 SetupSessionForGroupNameTests(GetProtocol(), &session_deps_)); | 8865 SetupSessionForGroupNameTests(GetProtocol(), &session_deps_)); |
| 8872 | 8866 |
| 8873 HttpNetworkSessionPeer peer(session.get()); | 8867 HttpNetworkSessionPeer peer(session.get()); |
| 8874 CaptureGroupNameTransportSocketPool* transport_conn_pool = | 8868 CaptureGroupNameTransportSocketPool* transport_conn_pool = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8917 }, | 8911 }, |
| 8918 | 8912 |
| 8919 { | 8913 { |
| 8920 "http_proxy", | 8914 "http_proxy", |
| 8921 "ftp://ftp.google.com/http_proxy_normal", | 8915 "ftp://ftp.google.com/http_proxy_normal", |
| 8922 "ftp/ftp.google.com:21", | 8916 "ftp/ftp.google.com:21", |
| 8923 false, | 8917 false, |
| 8924 }, | 8918 }, |
| 8925 }; | 8919 }; |
| 8926 | 8920 |
| 8927 session_deps_.parse_alternative_services = true; | |
| 8928 session_deps_.enable_alternative_service_with_different_host = false; | 8921 session_deps_.enable_alternative_service_with_different_host = false; |
| 8929 | 8922 |
| 8930 for (size_t i = 0; i < arraysize(tests); ++i) { | 8923 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 8931 session_deps_.proxy_service = | 8924 session_deps_.proxy_service = |
| 8932 ProxyService::CreateFixed(tests[i].proxy_server); | 8925 ProxyService::CreateFixed(tests[i].proxy_server); |
| 8933 std::unique_ptr<HttpNetworkSession> session( | 8926 std::unique_ptr<HttpNetworkSession> session( |
| 8934 SetupSessionForGroupNameTests(GetProtocol(), &session_deps_)); | 8927 SetupSessionForGroupNameTests(GetProtocol(), &session_deps_)); |
| 8935 | 8928 |
| 8936 HttpNetworkSessionPeer peer(session.get()); | 8929 HttpNetworkSessionPeer peer(session.get()); |
| 8937 | 8930 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8988 }, | 8981 }, |
| 8989 | 8982 |
| 8990 { | 8983 { |
| 8991 "socks4://socks_proxy:1080", | 8984 "socks4://socks_proxy:1080", |
| 8992 "http://host.with.alternate/direct", | 8985 "http://host.with.alternate/direct", |
| 8993 "socks4/ssl/host.with.alternate:443", | 8986 "socks4/ssl/host.with.alternate:443", |
| 8994 true, | 8987 true, |
| 8995 }, | 8988 }, |
| 8996 }; | 8989 }; |
| 8997 | 8990 |
| 8998 session_deps_.parse_alternative_services = true; | |
| 8999 session_deps_.enable_alternative_service_with_different_host = false; | 8991 session_deps_.enable_alternative_service_with_different_host = false; |
| 9000 | 8992 |
| 9001 for (size_t i = 0; i < arraysize(tests); ++i) { | 8993 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 9002 session_deps_.proxy_service = | 8994 session_deps_.proxy_service = |
| 9003 ProxyService::CreateFixed(tests[i].proxy_server); | 8995 ProxyService::CreateFixed(tests[i].proxy_server); |
| 9004 std::unique_ptr<HttpNetworkSession> session( | 8996 std::unique_ptr<HttpNetworkSession> session( |
| 9005 SetupSessionForGroupNameTests(GetProtocol(), &session_deps_)); | 8997 SetupSessionForGroupNameTests(GetProtocol(), &session_deps_)); |
| 9006 | 8998 |
| 9007 HttpNetworkSessionPeer peer(session.get()); | 8999 HttpNetworkSessionPeer peer(session.get()); |
| 9008 | 9000 |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9650 AuthCredentials(kFirst, kBar), callback4.callback()); | 9642 AuthCredentials(kFirst, kBar), callback4.callback()); |
| 9651 EXPECT_EQ(ERR_IO_PENDING, rv); | 9643 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9652 rv = callback4.WaitForResult(); | 9644 rv = callback4.WaitForResult(); |
| 9653 EXPECT_EQ(OK, rv); | 9645 EXPECT_EQ(OK, rv); |
| 9654 response = trans->GetResponseInfo(); | 9646 response = trans->GetResponseInfo(); |
| 9655 ASSERT_TRUE(response); | 9647 ASSERT_TRUE(response); |
| 9656 EXPECT_FALSE(response->auth_challenge); | 9648 EXPECT_FALSE(response->auth_challenge); |
| 9657 } | 9649 } |
| 9658 | 9650 |
| 9659 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { | 9651 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { |
| 9660 session_deps_.parse_alternative_services = true; | |
| 9661 session_deps_.enable_alternative_service_with_different_host = false; | 9652 session_deps_.enable_alternative_service_with_different_host = false; |
| 9662 | 9653 |
| 9663 std::string alternative_service_http_header = | 9654 std::string alternative_service_http_header = |
| 9664 GetAlternativeServiceHttpHeader(); | 9655 GetAlternativeServiceHttpHeader(); |
| 9665 | 9656 |
| 9666 MockRead data_reads[] = { | 9657 MockRead data_reads[] = { |
| 9667 MockRead("HTTP/1.1 200 OK\r\n"), | 9658 MockRead("HTTP/1.1 200 OK\r\n"), |
| 9668 MockRead(alternative_service_http_header.c_str()), | 9659 MockRead(alternative_service_http_header.c_str()), |
| 9669 MockRead("\r\n"), | 9660 MockRead("\r\n"), |
| 9670 MockRead("hello world"), | 9661 MockRead("hello world"), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9712 alternative_service_vector = | 9703 alternative_service_vector = |
| 9713 http_server_properties.GetAlternativeServices(test_server); | 9704 http_server_properties.GetAlternativeServices(test_server); |
| 9714 ASSERT_EQ(1u, alternative_service_vector.size()); | 9705 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 9715 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9706 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9716 alternative_service_vector[0].protocol); | 9707 alternative_service_vector[0].protocol); |
| 9717 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); | 9708 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); |
| 9718 EXPECT_EQ(443, alternative_service_vector[0].port); | 9709 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 9719 } | 9710 } |
| 9720 | 9711 |
| 9721 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { | 9712 TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) { |
| 9722 session_deps_.parse_alternative_services = true; | |
| 9723 session_deps_.enable_alternative_service_with_different_host = false; | 9713 session_deps_.enable_alternative_service_with_different_host = false; |
| 9724 | 9714 |
| 9725 // Set an alternative service for origin. | 9715 // Set an alternative service for origin. |
| 9726 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9716 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 9727 HttpServerProperties& http_server_properties = | 9717 HttpServerProperties& http_server_properties = |
| 9728 *session->http_server_properties(); | 9718 *session->http_server_properties(); |
| 9729 url::SchemeHostPort test_server("http", "www.example.org", 80); | 9719 url::SchemeHostPort test_server("http", "www.example.org", 80); |
| 9730 AlternativeService alternative_service(QUIC, "", 80); | 9720 AlternativeService alternative_service(QUIC, "", 80); |
| 9731 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 9721 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 9732 http_server_properties.SetAlternativeService(test_server, alternative_service, | 9722 http_server_properties.SetAlternativeService(test_server, alternative_service, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9768 | 9758 |
| 9769 std::string response_data; | 9759 std::string response_data; |
| 9770 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9760 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9771 EXPECT_EQ("hello world", response_data); | 9761 EXPECT_EQ("hello world", response_data); |
| 9772 | 9762 |
| 9773 alternative_service_vector = | 9763 alternative_service_vector = |
| 9774 http_server_properties.GetAlternativeServices(test_server); | 9764 http_server_properties.GetAlternativeServices(test_server); |
| 9775 EXPECT_TRUE(alternative_service_vector.empty()); | 9765 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9776 } | 9766 } |
| 9777 | 9767 |
| 9778 // Alternative Service headers must be ignored when | |
| 9779 // |parse_alternative_services| is false. | |
| 9780 TEST_P(HttpNetworkTransactionTest, DoNotHonorAlternativeServiceHeader) { | |
| 9781 session_deps_.parse_alternative_services = false; | |
| 9782 | |
| 9783 std::string alternative_service_http_header = | |
| 9784 GetAlternativeServiceHttpHeader(); | |
| 9785 | |
| 9786 MockRead data_reads[] = { | |
| 9787 MockRead("HTTP/1.1 200 OK\r\n"), | |
| 9788 MockRead(alternative_service_http_header.c_str()), | |
| 9789 MockRead("\r\n"), | |
| 9790 MockRead("hello world"), | |
| 9791 MockRead(SYNCHRONOUS, OK), | |
| 9792 }; | |
| 9793 | |
| 9794 HttpRequestInfo request; | |
| 9795 request.method = "GET"; | |
| 9796 request.url = GURL("http://www.example.org/"); | |
| 9797 request.load_flags = 0; | |
| 9798 | |
| 9799 StaticSocketDataProvider data(data_reads, arraysize(data_reads), nullptr, 0); | |
| 9800 | |
| 9801 session_deps_.socket_factory->AddSocketDataProvider(&data); | |
| 9802 | |
| 9803 TestCompletionCallback callback; | |
| 9804 | |
| 9805 std::unique_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); | |
| 9806 std::unique_ptr<HttpTransaction> trans( | |
| 9807 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | |
| 9808 | |
| 9809 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | |
| 9810 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 9811 | |
| 9812 url::SchemeHostPort test_server("http", "www.example.org", 80); | |
| 9813 HttpServerProperties& http_server_properties = | |
| 9814 *session->http_server_properties(); | |
| 9815 AlternativeServiceVector alternative_service_vector = | |
| 9816 http_server_properties.GetAlternativeServices(test_server); | |
| 9817 EXPECT_TRUE(alternative_service_vector.empty()); | |
| 9818 | |
| 9819 EXPECT_EQ(OK, callback.WaitForResult()); | |
| 9820 | |
| 9821 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 9822 ASSERT_TRUE(response); | |
| 9823 ASSERT_TRUE(response->headers); | |
| 9824 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | |
| 9825 EXPECT_FALSE(response->was_fetched_via_spdy); | |
| 9826 EXPECT_FALSE(response->was_npn_negotiated); | |
| 9827 | |
| 9828 std::string response_data; | |
| 9829 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | |
| 9830 EXPECT_EQ("hello world", response_data); | |
| 9831 | |
| 9832 alternative_service_vector = | |
| 9833 http_server_properties.GetAlternativeServices(test_server); | |
| 9834 EXPECT_TRUE(alternative_service_vector.empty()); | |
| 9835 } | |
| 9836 | |
| 9837 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { | 9768 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) { |
| 9838 session_deps_.parse_alternative_services = true; | |
| 9839 session_deps_.enable_alternative_service_with_different_host = false; | 9769 session_deps_.enable_alternative_service_with_different_host = false; |
| 9840 | 9770 |
| 9841 MockRead data_reads[] = { | 9771 MockRead data_reads[] = { |
| 9842 MockRead("HTTP/1.1 200 OK\r\n"), | 9772 MockRead("HTTP/1.1 200 OK\r\n"), |
| 9843 MockRead("Alt-Svc: "), | 9773 MockRead("Alt-Svc: "), |
| 9844 MockRead(GetAlternateProtocolFromParam()), | 9774 MockRead(GetAlternateProtocolFromParam()), |
| 9845 MockRead("=\"www.example.com:443\";p=\"1.0\","), | 9775 MockRead("=\"www.example.com:443\";p=\"1.0\","), |
| 9846 MockRead(GetAlternateProtocolFromParam()), | 9776 MockRead(GetAlternateProtocolFromParam()), |
| 9847 MockRead("=\":1234\"\r\n\r\n"), | 9777 MockRead("=\":1234\"\r\n\r\n"), |
| 9848 MockRead("hello world"), | 9778 MockRead("hello world"), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9893 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9823 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9894 alternative_service_vector[0].protocol); | 9824 alternative_service_vector[0].protocol); |
| 9895 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); | 9825 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); |
| 9896 EXPECT_EQ(443, alternative_service_vector[0].port); | 9826 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 9897 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9827 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 9898 alternative_service_vector[1].protocol); | 9828 alternative_service_vector[1].protocol); |
| 9899 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); | 9829 EXPECT_EQ("www.example.org", alternative_service_vector[1].host); |
| 9900 EXPECT_EQ(1234, alternative_service_vector[1].port); | 9830 EXPECT_EQ(1234, alternative_service_vector[1].port); |
| 9901 } | 9831 } |
| 9902 | 9832 |
| 9903 // Alternate Protocol headers must be honored even if | |
| 9904 // |parse_alternative_services| is false. | |
| 9905 TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { | |
| 9906 session_deps_.parse_alternative_services = false; | |
| 9907 | |
| 9908 std::string alternate_protocol_http_header = | |
| 9909 GetAlternateProtocolHttpHeader(); | |
| 9910 | |
| 9911 MockRead data_reads[] = { | |
| 9912 MockRead("HTTP/1.1 200 OK\r\n"), | |
| 9913 MockRead(alternate_protocol_http_header.c_str()), | |
| 9914 MockRead("\r\n"), | |
| 9915 MockRead("hello world"), | |
| 9916 MockRead(SYNCHRONOUS, OK), | |
| 9917 }; | |
| 9918 | |
| 9919 HttpRequestInfo request; | |
| 9920 request.method = "GET"; | |
| 9921 request.url = GURL("http://www.example.org/"); | |
| 9922 request.load_flags = 0; | |
| 9923 | |
| 9924 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | |
| 9925 | |
| 9926 session_deps_.socket_factory->AddSocketDataProvider(&data); | |
| 9927 | |
| 9928 TestCompletionCallback callback; | |
| 9929 | |
| 9930 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | |
| 9931 std::unique_ptr<HttpTransaction> trans( | |
| 9932 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | |
| 9933 | |
| 9934 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | |
| 9935 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 9936 | |
| 9937 url::SchemeHostPort test_server("http", "www.example.org", 80); | |
| 9938 HttpServerProperties& http_server_properties = | |
| 9939 *session->http_server_properties(); | |
| 9940 AlternativeServiceVector alternative_service_vector = | |
| 9941 http_server_properties.GetAlternativeServices(test_server); | |
| 9942 EXPECT_TRUE(alternative_service_vector.empty()); | |
| 9943 | |
| 9944 EXPECT_EQ(OK, callback.WaitForResult()); | |
| 9945 | |
| 9946 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 9947 ASSERT_TRUE(response); | |
| 9948 ASSERT_TRUE(response->headers); | |
| 9949 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | |
| 9950 EXPECT_FALSE(response->was_fetched_via_spdy); | |
| 9951 EXPECT_FALSE(response->was_npn_negotiated); | |
| 9952 | |
| 9953 std::string response_data; | |
| 9954 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | |
| 9955 EXPECT_EQ("hello world", response_data); | |
| 9956 | |
| 9957 alternative_service_vector = | |
| 9958 http_server_properties.GetAlternativeServices(test_server); | |
| 9959 ASSERT_EQ(1u, alternative_service_vector.size()); | |
| 9960 EXPECT_EQ(443, alternative_service_vector[0].port); | |
| 9961 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | |
| 9962 alternative_service_vector[0].protocol); | |
| 9963 } | |
| 9964 | |
| 9965 TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) { | |
| 9966 session_deps_.parse_alternative_services = false; | |
| 9967 session_deps_.enable_alternative_service_with_different_host = false; | |
| 9968 | |
| 9969 MockRead data_reads[] = { | |
| 9970 MockRead("HTTP/1.1 200 OK\r\n"), | |
| 9971 MockRead("Alternate-Protocol: \r\n\r\n"), | |
| 9972 MockRead("hello world"), | |
| 9973 MockRead(SYNCHRONOUS, OK), | |
| 9974 }; | |
| 9975 | |
| 9976 HttpRequestInfo request; | |
| 9977 request.method = "GET"; | |
| 9978 request.url = GURL("http://www.example.org/"); | |
| 9979 request.load_flags = 0; | |
| 9980 | |
| 9981 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | |
| 9982 | |
| 9983 session_deps_.socket_factory->AddSocketDataProvider(&data); | |
| 9984 | |
| 9985 TestCompletionCallback callback; | |
| 9986 | |
| 9987 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | |
| 9988 | |
| 9989 url::SchemeHostPort test_server("http", "www.example.org", 80); | |
| 9990 HttpServerProperties& http_server_properties = | |
| 9991 *session->http_server_properties(); | |
| 9992 AlternativeService alternative_service(QUIC, "", 80); | |
| 9993 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | |
| 9994 http_server_properties.SetAlternativeService(test_server, alternative_service, | |
| 9995 expiration); | |
| 9996 | |
| 9997 AlternativeServiceVector alternative_service_vector = | |
| 9998 http_server_properties.GetAlternativeServices(test_server); | |
| 9999 ASSERT_EQ(1u, alternative_service_vector.size()); | |
| 10000 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); | |
| 10001 | |
| 10002 std::unique_ptr<HttpTransaction> trans( | |
| 10003 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | |
| 10004 | |
| 10005 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | |
| 10006 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 10007 | |
| 10008 EXPECT_EQ(OK, callback.WaitForResult()); | |
| 10009 | |
| 10010 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 10011 ASSERT_TRUE(response); | |
| 10012 ASSERT_TRUE(response->headers); | |
| 10013 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | |
| 10014 EXPECT_FALSE(response->was_fetched_via_spdy); | |
| 10015 EXPECT_FALSE(response->was_npn_negotiated); | |
| 10016 | |
| 10017 std::string response_data; | |
| 10018 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | |
| 10019 EXPECT_EQ("hello world", response_data); | |
| 10020 | |
| 10021 alternative_service_vector = | |
| 10022 http_server_properties.GetAlternativeServices(test_server); | |
| 10023 EXPECT_TRUE(alternative_service_vector.empty()); | |
| 10024 } | |
| 10025 | |
| 10026 // When |session_deps_.parse_alternative_services = true| and the response has | |
| 10027 // an Alt-Svc header, then the Alternate-Protocol header is not parsed. | |
| 10028 TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) { | |
| 10029 session_deps_.parse_alternative_services = true; | |
| 10030 session_deps_.enable_alternative_service_with_different_host = false; | |
| 10031 | |
| 10032 std::string alternative_service_http_header = | |
| 10033 GetAlternativeServiceHttpHeader(); | |
| 10034 std::string alternate_protocol_http_header = GetAlternateProtocolHttpHeader(); | |
| 10035 | |
| 10036 MockRead data_reads[] = { | |
| 10037 MockRead("HTTP/1.1 200 OK\r\n"), | |
| 10038 MockRead(alternative_service_http_header.c_str()), | |
| 10039 MockRead(alternate_protocol_http_header.c_str()), | |
| 10040 MockRead("\r\n"), | |
| 10041 MockRead("hello world"), | |
| 10042 MockRead(SYNCHRONOUS, OK), | |
| 10043 }; | |
| 10044 | |
| 10045 HttpRequestInfo request; | |
| 10046 request.method = "GET"; | |
| 10047 request.url = GURL("http://www.example.org/"); | |
| 10048 request.load_flags = 0; | |
| 10049 | |
| 10050 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | |
| 10051 | |
| 10052 session_deps_.socket_factory->AddSocketDataProvider(&data); | |
| 10053 | |
| 10054 TestCompletionCallback callback; | |
| 10055 | |
| 10056 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | |
| 10057 std::unique_ptr<HttpTransaction> trans( | |
| 10058 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | |
| 10059 | |
| 10060 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | |
| 10061 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 10062 | |
| 10063 url::SchemeHostPort test_server("http", "www.example.org", 80); | |
| 10064 HttpServerProperties& http_server_properties = | |
| 10065 *session->http_server_properties(); | |
| 10066 AlternativeServiceVector alternative_service_vector = | |
| 10067 http_server_properties.GetAlternativeServices(test_server); | |
| 10068 EXPECT_TRUE(alternative_service_vector.empty()); | |
| 10069 | |
| 10070 EXPECT_EQ(OK, callback.WaitForResult()); | |
| 10071 | |
| 10072 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 10073 ASSERT_TRUE(response); | |
| 10074 ASSERT_TRUE(response->headers); | |
| 10075 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | |
| 10076 EXPECT_FALSE(response->was_fetched_via_spdy); | |
| 10077 EXPECT_FALSE(response->was_npn_negotiated); | |
| 10078 | |
| 10079 std::string response_data; | |
| 10080 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | |
| 10081 EXPECT_EQ("hello world", response_data); | |
| 10082 | |
| 10083 alternative_service_vector = | |
| 10084 http_server_properties.GetAlternativeServices(test_server); | |
| 10085 ASSERT_EQ(1u, alternative_service_vector.size()); | |
| 10086 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | |
| 10087 alternative_service_vector[0].protocol); | |
| 10088 EXPECT_EQ("www.example.com", alternative_service_vector[0].host); | |
| 10089 EXPECT_EQ(443, alternative_service_vector[0].port); | |
| 10090 } | |
| 10091 | |
| 10092 // When |enable_alternative_service_with_different_host| is false, do not | 9833 // When |enable_alternative_service_with_different_host| is false, do not |
| 10093 // observe alternative service entries that point to a different host. | 9834 // observe alternative service entries that point to a different host. |
| 10094 TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) { | 9835 TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) { |
| 10095 session_deps_.parse_alternative_services = true; | |
| 10096 session_deps_.enable_alternative_service_with_different_host = false; | 9836 session_deps_.enable_alternative_service_with_different_host = false; |
| 10097 | 9837 |
| 10098 HttpRequestInfo request; | 9838 HttpRequestInfo request; |
| 10099 request.method = "GET"; | 9839 request.method = "GET"; |
| 10100 request.url = GURL("http://www.example.org/"); | 9840 request.url = GURL("http://www.example.org/"); |
| 10101 request.load_flags = 0; | 9841 request.load_flags = 0; |
| 10102 | 9842 |
| 10103 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 9843 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10104 StaticSocketDataProvider first_data; | 9844 StaticSocketDataProvider first_data; |
| 10105 first_data.set_connect_data(mock_connect); | 9845 first_data.set_connect_data(mock_connect); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10161 }; | 9901 }; |
| 10162 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), | 9902 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
| 10163 http_writes, arraysize(http_writes)); | 9903 http_writes, arraysize(http_writes)); |
| 10164 session_deps_.socket_factory->AddSocketDataProvider(&http_data); | 9904 session_deps_.socket_factory->AddSocketDataProvider(&http_data); |
| 10165 | 9905 |
| 10166 StaticSocketDataProvider data_refused; | 9906 StaticSocketDataProvider data_refused; |
| 10167 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); | 9907 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); |
| 10168 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); | 9908 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); |
| 10169 | 9909 |
| 10170 // Set up a QUIC alternative service for server. | 9910 // Set up a QUIC alternative service for server. |
| 10171 session_deps_.parse_alternative_services = true; | |
| 10172 session_deps_.enable_alternative_service_with_different_host = false; | 9911 session_deps_.enable_alternative_service_with_different_host = false; |
| 10173 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9912 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10174 base::WeakPtr<HttpServerProperties> http_server_properties = | 9913 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10175 session->http_server_properties(); | 9914 session->http_server_properties(); |
| 10176 AlternativeService alternative_service(QUIC, alternative); | 9915 AlternativeService alternative_service(QUIC, alternative); |
| 10177 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 9916 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10178 http_server_properties->SetAlternativeService(server, alternative_service, | 9917 http_server_properties->SetAlternativeService(server, alternative_service, |
| 10179 expiration); | 9918 expiration); |
| 10180 // Mark the QUIC alternative service as broken. | 9919 // Mark the QUIC alternative service as broken. |
| 10181 http_server_properties->MarkAlternativeServiceBroken(alternative_service); | 9920 http_server_properties->MarkAlternativeServiceBroken(alternative_service); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10222 "first HTTP/1.1 response from alternative1"), | 9961 "first HTTP/1.1 response from alternative1"), |
| 10223 }; | 9962 }; |
| 10224 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), | 9963 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
| 10225 http_writes, arraysize(http_writes)); | 9964 http_writes, arraysize(http_writes)); |
| 10226 session_deps_.socket_factory->AddSocketDataProvider(&http_data); | 9965 session_deps_.socket_factory->AddSocketDataProvider(&http_data); |
| 10227 | 9966 |
| 10228 StaticSocketDataProvider data_refused; | 9967 StaticSocketDataProvider data_refused; |
| 10229 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); | 9968 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); |
| 10230 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); | 9969 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); |
| 10231 | 9970 |
| 10232 session_deps_.parse_alternative_services = true; | |
| 10233 session_deps_.enable_alternative_service_with_different_host = true; | 9971 session_deps_.enable_alternative_service_with_different_host = true; |
| 10234 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9972 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10235 base::WeakPtr<HttpServerProperties> http_server_properties = | 9973 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 10236 session->http_server_properties(); | 9974 session->http_server_properties(); |
| 10237 | 9975 |
| 10238 // Set up two QUIC alternative services for server. | 9976 // Set up two QUIC alternative services for server. |
| 10239 AlternativeServiceInfoVector alternative_service_info_vector; | 9977 AlternativeServiceInfoVector alternative_service_info_vector; |
| 10240 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 9978 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 10241 | 9979 |
| 10242 AlternativeService alternative_service1(QUIC, alternative1); | 9980 AlternativeService alternative_service1(QUIC, alternative1); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 10267 NetErrorDetails details; | 10005 NetErrorDetails details; |
| 10268 EXPECT_FALSE(details.quic_broken); | 10006 EXPECT_FALSE(details.quic_broken); |
| 10269 | 10007 |
| 10270 trans->Start(&request, callback.callback(), BoundNetLog()); | 10008 trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10271 trans->PopulateNetErrorDetails(&details); | 10009 trans->PopulateNetErrorDetails(&details); |
| 10272 EXPECT_FALSE(details.quic_broken); | 10010 EXPECT_FALSE(details.quic_broken); |
| 10273 } | 10011 } |
| 10274 | 10012 |
| 10275 TEST_P(HttpNetworkTransactionTest, | 10013 TEST_P(HttpNetworkTransactionTest, |
| 10276 MarkBrokenAlternateProtocolAndFallback) { | 10014 MarkBrokenAlternateProtocolAndFallback) { |
| 10277 session_deps_.parse_alternative_services = true; | |
| 10278 session_deps_.enable_alternative_service_with_different_host = false; | 10015 session_deps_.enable_alternative_service_with_different_host = false; |
| 10279 | 10016 |
| 10280 HttpRequestInfo request; | 10017 HttpRequestInfo request; |
| 10281 request.method = "GET"; | 10018 request.method = "GET"; |
| 10282 request.url = GURL("http://www.example.org/"); | 10019 request.url = GURL("http://www.example.org/"); |
| 10283 request.load_flags = 0; | 10020 request.load_flags = 0; |
| 10284 | 10021 |
| 10285 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10022 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10286 StaticSocketDataProvider first_data; | 10023 StaticSocketDataProvider first_data; |
| 10287 first_data.set_connect_data(mock_connect); | 10024 first_data.set_connect_data(mock_connect); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10334 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken( | 10071 EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken( |
| 10335 alternative_service_vector[0])); | 10072 alternative_service_vector[0])); |
| 10336 } | 10073 } |
| 10337 | 10074 |
| 10338 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10075 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10339 // to an unrestricted (port >= 1024) when the original traffic was on a | 10076 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10340 // restricted port (port < 1024). Ensure that we can redirect in all other | 10077 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10341 // cases. | 10078 // cases. |
| 10342 TEST_P(HttpNetworkTransactionTest, | 10079 TEST_P(HttpNetworkTransactionTest, |
| 10343 AlternateProtocolPortRestrictedBlocked) { | 10080 AlternateProtocolPortRestrictedBlocked) { |
| 10344 session_deps_.parse_alternative_services = true; | |
| 10345 session_deps_.enable_alternative_service_with_different_host = false; | 10081 session_deps_.enable_alternative_service_with_different_host = false; |
| 10346 | 10082 |
| 10347 HttpRequestInfo restricted_port_request; | 10083 HttpRequestInfo restricted_port_request; |
| 10348 restricted_port_request.method = "GET"; | 10084 restricted_port_request.method = "GET"; |
| 10349 restricted_port_request.url = GURL("http://www.example.org:1023/"); | 10085 restricted_port_request.url = GURL("http://www.example.org:1023/"); |
| 10350 restricted_port_request.load_flags = 0; | 10086 restricted_port_request.load_flags = 0; |
| 10351 | 10087 |
| 10352 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10088 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10353 StaticSocketDataProvider first_data; | 10089 StaticSocketDataProvider first_data; |
| 10354 first_data.set_connect_data(mock_connect); | 10090 first_data.set_connect_data(mock_connect); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10386 EXPECT_EQ(ERR_IO_PENDING, rv); | 10122 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10387 // Invalid change to unrestricted port should fail. | 10123 // Invalid change to unrestricted port should fail. |
| 10388 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); | 10124 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); |
| 10389 } | 10125 } |
| 10390 | 10126 |
| 10391 // Ensure that we are allowed to redirect traffic via an alternate protocol to | 10127 // Ensure that we are allowed to redirect traffic via an alternate protocol to |
| 10392 // an unrestricted (port >= 1024) when the original traffic was on a restricted | 10128 // an unrestricted (port >= 1024) when the original traffic was on a restricted |
| 10393 // port (port < 1024) if we set |enable_user_alternate_protocol_ports|. | 10129 // port (port < 1024) if we set |enable_user_alternate_protocol_ports|. |
| 10394 TEST_P(HttpNetworkTransactionTest, | 10130 TEST_P(HttpNetworkTransactionTest, |
| 10395 AlternateProtocolPortRestrictedPermitted) { | 10131 AlternateProtocolPortRestrictedPermitted) { |
| 10396 session_deps_.parse_alternative_services = true; | |
| 10397 session_deps_.enable_alternative_service_with_different_host = false; | 10132 session_deps_.enable_alternative_service_with_different_host = false; |
| 10398 session_deps_.enable_user_alternate_protocol_ports = true; | 10133 session_deps_.enable_user_alternate_protocol_ports = true; |
| 10399 | 10134 |
| 10400 HttpRequestInfo restricted_port_request; | 10135 HttpRequestInfo restricted_port_request; |
| 10401 restricted_port_request.method = "GET"; | 10136 restricted_port_request.method = "GET"; |
| 10402 restricted_port_request.url = GURL("http://www.example.org:1023/"); | 10137 restricted_port_request.url = GURL("http://www.example.org:1023/"); |
| 10403 restricted_port_request.load_flags = 0; | 10138 restricted_port_request.load_flags = 0; |
| 10404 | 10139 |
| 10405 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10140 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10406 StaticSocketDataProvider first_data; | 10141 StaticSocketDataProvider first_data; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10439 // Change to unrestricted port should succeed. | 10174 // Change to unrestricted port should succeed. |
| 10440 EXPECT_EQ(OK, callback.WaitForResult()); | 10175 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10441 } | 10176 } |
| 10442 | 10177 |
| 10443 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10178 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10444 // to an unrestricted (port >= 1024) when the original traffic was on a | 10179 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10445 // restricted port (port < 1024). Ensure that we can redirect in all other | 10180 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10446 // cases. | 10181 // cases. |
| 10447 TEST_P(HttpNetworkTransactionTest, | 10182 TEST_P(HttpNetworkTransactionTest, |
| 10448 AlternateProtocolPortRestrictedAllowed) { | 10183 AlternateProtocolPortRestrictedAllowed) { |
| 10449 session_deps_.parse_alternative_services = true; | |
| 10450 session_deps_.enable_alternative_service_with_different_host = false; | 10184 session_deps_.enable_alternative_service_with_different_host = false; |
| 10451 | 10185 |
| 10452 HttpRequestInfo restricted_port_request; | 10186 HttpRequestInfo restricted_port_request; |
| 10453 restricted_port_request.method = "GET"; | 10187 restricted_port_request.method = "GET"; |
| 10454 restricted_port_request.url = GURL("http://www.example.org:1023/"); | 10188 restricted_port_request.url = GURL("http://www.example.org:1023/"); |
| 10455 restricted_port_request.load_flags = 0; | 10189 restricted_port_request.load_flags = 0; |
| 10456 | 10190 |
| 10457 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10191 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10458 StaticSocketDataProvider first_data; | 10192 StaticSocketDataProvider first_data; |
| 10459 first_data.set_connect_data(mock_connect); | 10193 first_data.set_connect_data(mock_connect); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10492 // Valid change to restricted port should pass. | 10226 // Valid change to restricted port should pass. |
| 10493 EXPECT_EQ(OK, callback.WaitForResult()); | 10227 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10494 } | 10228 } |
| 10495 | 10229 |
| 10496 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10230 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10497 // to an unrestricted (port >= 1024) when the original traffic was on a | 10231 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10498 // restricted port (port < 1024). Ensure that we can redirect in all other | 10232 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10499 // cases. | 10233 // cases. |
| 10500 TEST_P(HttpNetworkTransactionTest, | 10234 TEST_P(HttpNetworkTransactionTest, |
| 10501 AlternateProtocolPortUnrestrictedAllowed1) { | 10235 AlternateProtocolPortUnrestrictedAllowed1) { |
| 10502 session_deps_.parse_alternative_services = true; | |
| 10503 session_deps_.enable_alternative_service_with_different_host = false; | 10236 session_deps_.enable_alternative_service_with_different_host = false; |
| 10504 | 10237 |
| 10505 HttpRequestInfo unrestricted_port_request; | 10238 HttpRequestInfo unrestricted_port_request; |
| 10506 unrestricted_port_request.method = "GET"; | 10239 unrestricted_port_request.method = "GET"; |
| 10507 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); | 10240 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); |
| 10508 unrestricted_port_request.load_flags = 0; | 10241 unrestricted_port_request.load_flags = 0; |
| 10509 | 10242 |
| 10510 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10243 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10511 StaticSocketDataProvider first_data; | 10244 StaticSocketDataProvider first_data; |
| 10512 first_data.set_connect_data(mock_connect); | 10245 first_data.set_connect_data(mock_connect); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10544 // Valid change to restricted port should pass. | 10277 // Valid change to restricted port should pass. |
| 10545 EXPECT_EQ(OK, callback.WaitForResult()); | 10278 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10546 } | 10279 } |
| 10547 | 10280 |
| 10548 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10281 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10549 // to an unrestricted (port >= 1024) when the original traffic was on a | 10282 // to an unrestricted (port >= 1024) when the original traffic was on a |
| 10550 // restricted port (port < 1024). Ensure that we can redirect in all other | 10283 // restricted port (port < 1024). Ensure that we can redirect in all other |
| 10551 // cases. | 10284 // cases. |
| 10552 TEST_P(HttpNetworkTransactionTest, | 10285 TEST_P(HttpNetworkTransactionTest, |
| 10553 AlternateProtocolPortUnrestrictedAllowed2) { | 10286 AlternateProtocolPortUnrestrictedAllowed2) { |
| 10554 session_deps_.parse_alternative_services = true; | |
| 10555 session_deps_.enable_alternative_service_with_different_host = false; | 10287 session_deps_.enable_alternative_service_with_different_host = false; |
| 10556 | 10288 |
| 10557 HttpRequestInfo unrestricted_port_request; | 10289 HttpRequestInfo unrestricted_port_request; |
| 10558 unrestricted_port_request.method = "GET"; | 10290 unrestricted_port_request.method = "GET"; |
| 10559 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); | 10291 unrestricted_port_request.url = GURL("http://www.example.org:1024/"); |
| 10560 unrestricted_port_request.load_flags = 0; | 10292 unrestricted_port_request.load_flags = 0; |
| 10561 | 10293 |
| 10562 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 10294 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 10563 StaticSocketDataProvider first_data; | 10295 StaticSocketDataProvider first_data; |
| 10564 first_data.set_connect_data(mock_connect); | 10296 first_data.set_connect_data(mock_connect); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 10594 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 10326 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
| 10595 EXPECT_EQ(ERR_IO_PENDING, rv); | 10327 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 10596 // Valid change to an unrestricted port should pass. | 10328 // Valid change to an unrestricted port should pass. |
| 10597 EXPECT_EQ(OK, callback.WaitForResult()); | 10329 EXPECT_EQ(OK, callback.WaitForResult()); |
| 10598 } | 10330 } |
| 10599 | 10331 |
| 10600 // Ensure that we are not allowed to redirect traffic via an alternate protocol | 10332 // Ensure that we are not allowed to redirect traffic via an alternate protocol |
| 10601 // to an unsafe port, and that we resume the second HttpStreamFactoryImpl::Job | 10333 // to an unsafe port, and that we resume the second HttpStreamFactoryImpl::Job |
| 10602 // once the alternate protocol request fails. | 10334 // once the alternate protocol request fails. |
| 10603 TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) { | 10335 TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) { |
| 10604 session_deps_.parse_alternative_services = true; | |
| 10605 session_deps_.enable_alternative_service_with_different_host = false; | 10336 session_deps_.enable_alternative_service_with_different_host = false; |
| 10606 | 10337 |
| 10607 HttpRequestInfo request; | 10338 HttpRequestInfo request; |
| 10608 request.method = "GET"; | 10339 request.method = "GET"; |
| 10609 request.url = GURL("http://www.example.org/"); | 10340 request.url = GURL("http://www.example.org/"); |
| 10610 request.load_flags = 0; | 10341 request.load_flags = 0; |
| 10611 | 10342 |
| 10612 // The alternate protocol request will error out before we attempt to connect, | 10343 // The alternate protocol request will error out before we attempt to connect, |
| 10613 // so only the standard HTTP request will try to connect. | 10344 // so only the standard HTTP request will try to connect. |
| 10614 MockRead data_reads[] = { | 10345 MockRead data_reads[] = { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 10645 ASSERT_TRUE(response); | 10376 ASSERT_TRUE(response); |
| 10646 ASSERT_TRUE(response->headers); | 10377 ASSERT_TRUE(response->headers); |
| 10647 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10378 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10648 | 10379 |
| 10649 std::string response_data; | 10380 std::string response_data; |
| 10650 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10381 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10651 EXPECT_EQ("hello world", response_data); | 10382 EXPECT_EQ("hello world", response_data); |
| 10652 } | 10383 } |
| 10653 | 10384 |
| 10654 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { | 10385 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { |
| 10655 session_deps_.parse_alternative_services = false; | 10386 session_deps_.enable_alternative_service_with_different_host = true; |
| 10656 session_deps_.enable_alternative_service_with_different_host = false; | |
| 10657 | 10387 |
| 10658 HttpRequestInfo request; | 10388 HttpRequestInfo request; |
| 10659 request.method = "GET"; | 10389 request.method = "GET"; |
| 10660 request.url = GURL("http://www.example.org/"); | 10390 request.url = GURL("http://www.example.org/"); |
| 10661 request.load_flags = 0; | 10391 request.load_flags = 0; |
| 10662 | 10392 |
| 10663 std::string alternate_protocol_http_header = | 10393 std::string alternative_service_http_header = |
| 10664 GetAlternateProtocolHttpHeader(); | 10394 GetAlternativeServiceHttpHeader(); |
| 10665 | 10395 |
| 10666 MockRead data_reads[] = { | 10396 MockRead data_reads[] = { |
| 10667 MockRead("HTTP/1.1 200 OK\r\n"), | 10397 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10668 MockRead(alternate_protocol_http_header.c_str()), | 10398 MockRead(alternative_service_http_header.c_str()), |
| 10669 MockRead("\r\n"), | 10399 MockRead("\r\n"), |
| 10670 MockRead("hello world"), | 10400 MockRead("hello world"), |
| 10671 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10401 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10672 MockRead(ASYNC, OK)}; | 10402 MockRead(ASYNC, OK)}; |
| 10673 | 10403 |
| 10674 StaticSocketDataProvider first_transaction( | 10404 StaticSocketDataProvider first_transaction( |
| 10675 data_reads, arraysize(data_reads), NULL, 0); | 10405 data_reads, arraysize(data_reads), NULL, 0); |
| 10676 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10406 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 10677 | 10407 |
| 10678 SSLSocketDataProvider ssl(ASYNC, OK); | 10408 SSLSocketDataProvider ssl(ASYNC, OK); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10735 ASSERT_TRUE(response->headers); | 10465 ASSERT_TRUE(response->headers); |
| 10736 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10466 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10737 EXPECT_TRUE(response->was_fetched_via_spdy); | 10467 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10738 EXPECT_TRUE(response->was_npn_negotiated); | 10468 EXPECT_TRUE(response->was_npn_negotiated); |
| 10739 | 10469 |
| 10740 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10470 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 10741 EXPECT_EQ("hello!", response_data); | 10471 EXPECT_EQ("hello!", response_data); |
| 10742 } | 10472 } |
| 10743 | 10473 |
| 10744 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { | 10474 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { |
| 10745 session_deps_.parse_alternative_services = false; | 10475 session_deps_.enable_alternative_service_with_different_host = true; |
| 10746 session_deps_.enable_alternative_service_with_different_host = false; | |
| 10747 | 10476 |
| 10748 HttpRequestInfo request; | 10477 HttpRequestInfo request; |
| 10749 request.method = "GET"; | 10478 request.method = "GET"; |
| 10750 request.url = GURL("http://www.example.org/"); | 10479 request.url = GURL("http://www.example.org/"); |
| 10751 request.load_flags = 0; | 10480 request.load_flags = 0; |
| 10752 | 10481 |
| 10753 std::string alternate_protocol_http_header = | 10482 std::string alternative_service_http_header = |
| 10754 GetAlternateProtocolHttpHeader(); | 10483 GetAlternativeServiceHttpHeader(); |
| 10755 | 10484 |
| 10756 MockRead data_reads[] = { | 10485 MockRead data_reads[] = { |
| 10757 MockRead("HTTP/1.1 200 OK\r\n"), | 10486 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10758 MockRead(alternate_protocol_http_header.c_str()), | 10487 MockRead(alternative_service_http_header.c_str()), |
| 10759 MockRead("\r\n"), | 10488 MockRead("\r\n"), |
| 10760 MockRead("hello world"), | 10489 MockRead("hello world"), |
| 10761 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10490 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10762 MockRead(ASYNC, OK), | 10491 MockRead(ASYNC, OK), |
| 10763 }; | 10492 }; |
| 10764 | 10493 |
| 10765 StaticSocketDataProvider first_transaction( | 10494 StaticSocketDataProvider first_transaction( |
| 10766 data_reads, arraysize(data_reads), NULL, 0); | 10495 data_reads, arraysize(data_reads), NULL, 0); |
| 10767 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. | 10496 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. |
| 10768 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10497 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10859 response = trans3.GetResponseInfo(); | 10588 response = trans3.GetResponseInfo(); |
| 10860 ASSERT_TRUE(response); | 10589 ASSERT_TRUE(response); |
| 10861 ASSERT_TRUE(response->headers); | 10590 ASSERT_TRUE(response->headers); |
| 10862 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10591 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10863 EXPECT_TRUE(response->was_fetched_via_spdy); | 10592 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10864 EXPECT_TRUE(response->was_npn_negotiated); | 10593 EXPECT_TRUE(response->was_npn_negotiated); |
| 10865 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); | 10594 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); |
| 10866 EXPECT_EQ("hello!", response_data); | 10595 EXPECT_EQ("hello!", response_data); |
| 10867 } | 10596 } |
| 10868 | 10597 |
| 10869 TEST_P(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { | 10598 TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { |
| 10870 session_deps_.parse_alternative_services = false; | 10599 session_deps_.enable_alternative_service_with_different_host = true; |
| 10871 session_deps_.enable_alternative_service_with_different_host = false; | |
| 10872 | 10600 |
| 10873 HttpRequestInfo request; | 10601 HttpRequestInfo request; |
| 10874 request.method = "GET"; | 10602 request.method = "GET"; |
| 10875 request.url = GURL("http://www.example.org/"); | 10603 request.url = GURL("http://www.example.com/"); |
| 10876 request.load_flags = 0; | 10604 request.load_flags = 0; |
| 10877 | 10605 |
| 10878 std::string alternate_protocol_http_header = | 10606 std::string alternative_service_http_header = |
| 10879 GetAlternateProtocolHttpHeader(); | 10607 GetAlternativeServiceHttpHeader(); |
| 10880 | 10608 |
| 10881 MockRead data_reads[] = { | 10609 MockRead data_reads[] = { |
| 10882 MockRead("HTTP/1.1 200 OK\r\n"), | 10610 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10883 MockRead(alternate_protocol_http_header.c_str()), | 10611 MockRead(alternative_service_http_header.c_str()), |
| 10884 MockRead("\r\n"), | 10612 MockRead("\r\n"), |
| 10885 MockRead("hello world"), | 10613 MockRead("hello world"), |
| 10886 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10614 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10887 MockRead(ASYNC, OK), | 10615 MockRead(ASYNC, OK), |
| 10888 }; | 10616 }; |
| 10889 | 10617 |
| 10890 StaticSocketDataProvider first_transaction( | 10618 StaticSocketDataProvider first_transaction( |
| 10891 data_reads, arraysize(data_reads), NULL, 0); | 10619 data_reads, arraysize(data_reads), NULL, 0); |
| 10892 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10620 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 10893 | 10621 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10987 const net::CompletionCallback& callback, | 10715 const net::CompletionCallback& callback, |
| 10988 std::unique_ptr<Request>* request) override { | 10716 std::unique_ptr<Request>* request) override { |
| 10989 resolver->reset(new ForwardingProxyResolver(resolver_)); | 10717 resolver->reset(new ForwardingProxyResolver(resolver_)); |
| 10990 return OK; | 10718 return OK; |
| 10991 } | 10719 } |
| 10992 | 10720 |
| 10993 private: | 10721 private: |
| 10994 ProxyResolver* resolver_; | 10722 ProxyResolver* resolver_; |
| 10995 }; | 10723 }; |
| 10996 | 10724 |
| 10997 TEST_P(HttpNetworkTransactionTest, | 10725 TEST_P(HttpNetworkTransactionTest, UseAlternativeServiceForTunneledNpnSpdy) { |
| 10998 UseAlternateProtocolForTunneledNpnSpdy) { | 10726 session_deps_.enable_alternative_service_with_different_host = true; |
| 10999 session_deps_.parse_alternative_services = false; | |
| 11000 session_deps_.enable_alternative_service_with_different_host = false; | |
| 11001 | 10727 |
| 11002 ProxyConfig proxy_config; | 10728 ProxyConfig proxy_config; |
| 11003 proxy_config.set_auto_detect(true); | 10729 proxy_config.set_auto_detect(true); |
| 11004 proxy_config.set_pac_url(GURL("http://fooproxyurl")); | 10730 proxy_config.set_pac_url(GURL("http://fooproxyurl")); |
| 11005 | 10731 |
| 11006 CapturingProxyResolver capturing_proxy_resolver; | 10732 CapturingProxyResolver capturing_proxy_resolver; |
| 11007 session_deps_.proxy_service.reset(new ProxyService( | 10733 session_deps_.proxy_service.reset(new ProxyService( |
| 11008 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), | 10734 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), |
| 11009 base::WrapUnique( | 10735 base::WrapUnique( |
| 11010 new CapturingProxyResolverFactory(&capturing_proxy_resolver)), | 10736 new CapturingProxyResolverFactory(&capturing_proxy_resolver)), |
| 11011 NULL)); | 10737 NULL)); |
| 11012 TestNetLog net_log; | 10738 TestNetLog net_log; |
| 11013 session_deps_.net_log = &net_log; | 10739 session_deps_.net_log = &net_log; |
| 11014 | 10740 |
| 11015 HttpRequestInfo request; | 10741 HttpRequestInfo request; |
| 11016 request.method = "GET"; | 10742 request.method = "GET"; |
| 11017 request.url = GURL("http://www.example.org/"); | 10743 request.url = GURL("http://www.example.org/"); |
| 11018 request.load_flags = 0; | 10744 request.load_flags = 0; |
| 11019 | 10745 |
| 11020 std::string alternate_protocol_http_header = | 10746 std::string alternative_service_http_header = |
| 11021 GetAlternateProtocolHttpHeader(); | 10747 GetAlternativeServiceHttpHeader(); |
| 11022 | 10748 |
| 11023 MockRead data_reads[] = { | 10749 MockRead data_reads[] = { |
| 11024 MockRead("HTTP/1.1 200 OK\r\n"), | 10750 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11025 MockRead(alternate_protocol_http_header.c_str()), | 10751 MockRead(alternative_service_http_header.c_str()), |
| 11026 MockRead("\r\n"), | 10752 MockRead("\r\n"), |
| 11027 MockRead("hello world"), | 10753 MockRead("hello world"), |
| 11028 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10754 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 11029 MockRead(ASYNC, OK), | 10755 MockRead(ASYNC, OK), |
| 11030 }; | 10756 }; |
| 11031 | 10757 |
| 11032 StaticSocketDataProvider first_transaction( | 10758 StaticSocketDataProvider first_transaction( |
| 11033 data_reads, arraysize(data_reads), NULL, 0); | 10759 data_reads, arraysize(data_reads), NULL, 0); |
| 11034 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10760 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11035 | 10761 |
| 11036 SSLSocketDataProvider ssl(ASYNC, OK); | 10762 SSLSocketDataProvider ssl(ASYNC, OK); |
| 11037 ssl.SetNextProto(GetProtocol()); | 10763 ssl.SetNextProto(GetProtocol()); |
| 11038 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 10764 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 11039 ASSERT_TRUE(ssl.cert); | 10765 ASSERT_TRUE(ssl.cert); |
| 11040 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 10766 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 11041 | 10767 |
| 11042 std::unique_ptr<SpdySerializedFrame> req( | 10768 std::unique_ptr<SpdySerializedFrame> req( |
| 11043 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 10769 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 11044 MockWrite spdy_writes[] = { | 10770 MockWrite spdy_writes[] = { |
| 11045 MockWrite(ASYNC, 0, | 10771 MockWrite(ASYNC, 0, |
| 11046 "CONNECT www.example.org:443 HTTP/1.1\r\n" | 10772 "CONNECT www.example.com:443 HTTP/1.1\r\n" |
| 11047 "Host: www.example.org:443\r\n" | 10773 "Host: www.example.com:443\r\n" |
| 11048 "Proxy-Connection: keep-alive\r\n\r\n"), | 10774 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 11049 CreateMockWrite(*req, 2), | 10775 CreateMockWrite(*req, 2), |
| 11050 }; | 10776 }; |
| 11051 | 10777 |
| 11052 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; | 10778 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; |
| 11053 | 10779 |
| 11054 std::unique_ptr<SpdySerializedFrame> resp( | 10780 std::unique_ptr<SpdySerializedFrame> resp( |
| 11055 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 10781 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 11056 std::unique_ptr<SpdySerializedFrame> data( | 10782 std::unique_ptr<SpdySerializedFrame> data( |
| 11057 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 10783 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11114 EXPECT_EQ("https://www.example.org/", | 10840 EXPECT_EQ("https://www.example.org/", |
| 11115 capturing_proxy_resolver.resolved()[1].spec()); | 10841 capturing_proxy_resolver.resolved()[1].spec()); |
| 11116 | 10842 |
| 11117 LoadTimingInfo load_timing_info; | 10843 LoadTimingInfo load_timing_info; |
| 11118 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 10844 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 11119 TestLoadTimingNotReusedWithPac(load_timing_info, | 10845 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 11120 CONNECT_TIMING_HAS_SSL_TIMES); | 10846 CONNECT_TIMING_HAS_SSL_TIMES); |
| 11121 } | 10847 } |
| 11122 | 10848 |
| 11123 TEST_P(HttpNetworkTransactionTest, | 10849 TEST_P(HttpNetworkTransactionTest, |
| 11124 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { | 10850 UseAlternativeServiceForNpnSpdyWithExistingSpdySession) { |
| 11125 session_deps_.parse_alternative_services = false; | 10851 session_deps_.enable_alternative_service_with_different_host = true; |
| 11126 session_deps_.enable_alternative_service_with_different_host = false; | |
| 11127 | 10852 |
| 11128 HttpRequestInfo request; | 10853 HttpRequestInfo request; |
| 11129 request.method = "GET"; | 10854 request.method = "GET"; |
| 11130 request.url = GURL("http://www.example.org/"); | 10855 request.url = GURL("http://www.example.org/"); |
| 11131 request.load_flags = 0; | 10856 request.load_flags = 0; |
| 11132 | 10857 |
| 11133 std::string alternate_protocol_http_header = | 10858 std::string alternative_service_http_header = |
| 11134 GetAlternateProtocolHttpHeader(); | 10859 GetAlternativeServiceHttpHeader(); |
| 11135 | 10860 |
| 11136 MockRead data_reads[] = { | 10861 MockRead data_reads[] = { |
| 11137 MockRead("HTTP/1.1 200 OK\r\n"), | 10862 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11138 MockRead(alternate_protocol_http_header.c_str()), | 10863 MockRead(alternative_service_http_header.c_str()), |
| 11139 MockRead("\r\n"), | 10864 MockRead("\r\n"), |
| 11140 MockRead("hello world"), | 10865 MockRead("hello world"), |
| 11141 MockRead(ASYNC, OK), | 10866 MockRead(ASYNC, OK), |
| 11142 }; | 10867 }; |
| 11143 | 10868 |
| 11144 StaticSocketDataProvider first_transaction( | 10869 StaticSocketDataProvider first_transaction( |
| 11145 data_reads, arraysize(data_reads), NULL, 0); | 10870 data_reads, arraysize(data_reads), NULL, 0); |
| 11146 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10871 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11147 | 10872 |
| 11148 SSLSocketDataProvider ssl(ASYNC, OK); | 10873 SSLSocketDataProvider ssl(ASYNC, OK); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11181 const HttpResponseInfo* response = trans->GetResponseInfo(); | 10906 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 11182 ASSERT_TRUE(response); | 10907 ASSERT_TRUE(response); |
| 11183 ASSERT_TRUE(response->headers); | 10908 ASSERT_TRUE(response->headers); |
| 11184 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10909 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 11185 | 10910 |
| 11186 std::string response_data; | 10911 std::string response_data; |
| 11187 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 10912 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 11188 EXPECT_EQ("hello world", response_data); | 10913 EXPECT_EQ("hello world", response_data); |
| 11189 | 10914 |
| 11190 // Set up an initial SpdySession in the pool to reuse. | 10915 // Set up an initial SpdySession in the pool to reuse. |
| 11191 HostPortPair host_port_pair("www.example.org", 443); | 10916 HostPortPair host_port_pair("www.example.com", 443); |
| 11192 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 10917 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 11193 PRIVACY_MODE_DISABLED); | 10918 PRIVACY_MODE_DISABLED); |
| 11194 base::WeakPtr<SpdySession> spdy_session = | 10919 base::WeakPtr<SpdySession> spdy_session = |
| 11195 CreateSecureSpdySession(session.get(), key, BoundNetLog()); | 10920 CreateSecureSpdySession(session.get(), key, BoundNetLog()); |
| 11196 | 10921 |
| 11197 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 10922 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11198 | 10923 |
| 11199 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10924 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11200 EXPECT_EQ(ERR_IO_PENDING, rv); | 10925 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 11201 EXPECT_EQ(OK, callback.WaitForResult()); | 10926 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11818 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); | 11543 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); |
| 11819 EXPECT_EQ(0, rv); | 11544 EXPECT_EQ(0, rv); |
| 11820 | 11545 |
| 11821 // Finally, the socket is released to the group. | 11546 // Finally, the socket is released to the group. |
| 11822 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 11547 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 11823 } | 11548 } |
| 11824 | 11549 |
| 11825 // This tests the case that a request is issued via http instead of spdy after | 11550 // This tests the case that a request is issued via http instead of spdy after |
| 11826 // npn is negotiated. | 11551 // npn is negotiated. |
| 11827 TEST_P(HttpNetworkTransactionTest, NpnWithHttpOverSSL) { | 11552 TEST_P(HttpNetworkTransactionTest, NpnWithHttpOverSSL) { |
| 11828 session_deps_.parse_alternative_services = true; | |
| 11829 session_deps_.enable_alternative_service_with_different_host = false; | 11553 session_deps_.enable_alternative_service_with_different_host = false; |
| 11830 | 11554 |
| 11831 HttpRequestInfo request; | 11555 HttpRequestInfo request; |
| 11832 request.method = "GET"; | 11556 request.method = "GET"; |
| 11833 request.url = GURL("https://www.example.org/"); | 11557 request.url = GURL("https://www.example.org/"); |
| 11834 request.load_flags = 0; | 11558 request.load_flags = 0; |
| 11835 | 11559 |
| 11836 MockWrite data_writes[] = { | 11560 MockWrite data_writes[] = { |
| 11837 MockWrite( | 11561 MockWrite( |
| 11838 "GET / HTTP/1.1\r\n" | 11562 "GET / HTTP/1.1\r\n" |
| 11839 "Host: www.example.org\r\n" | 11563 "Host: www.example.org\r\n" |
| 11840 "Connection: keep-alive\r\n\r\n"), | 11564 "Connection: keep-alive\r\n\r\n"), |
| 11841 }; | 11565 }; |
| 11842 | 11566 |
| 11843 std::string alternate_protocol_http_header = | 11567 std::string alternative_service_http_header = |
| 11844 GetAlternateProtocolHttpHeader(); | 11568 GetAlternativeServiceHttpHeader(); |
| 11845 | 11569 |
| 11846 MockRead data_reads[] = { | 11570 MockRead data_reads[] = { |
| 11847 MockRead("HTTP/1.1 200 OK\r\n"), | 11571 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11848 MockRead(alternate_protocol_http_header.c_str()), | 11572 MockRead(alternative_service_http_header.c_str()), |
| 11849 MockRead("\r\n"), | 11573 MockRead("\r\n"), |
| 11850 MockRead("hello world"), | 11574 MockRead("hello world"), |
| 11851 MockRead(SYNCHRONOUS, OK), | 11575 MockRead(SYNCHRONOUS, OK), |
| 11852 }; | 11576 }; |
| 11853 | 11577 |
| 11854 SSLSocketDataProvider ssl(ASYNC, OK); | 11578 SSLSocketDataProvider ssl(ASYNC, OK); |
| 11855 ssl.SetNextProto(kProtoHTTP11); | 11579 ssl.SetNextProto(kProtoHTTP11); |
| 11856 | 11580 |
| 11857 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11581 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 11858 | 11582 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 11881 EXPECT_EQ("hello world", response_data); | 11605 EXPECT_EQ("hello world", response_data); |
| 11882 | 11606 |
| 11883 EXPECT_FALSE(response->was_fetched_via_spdy); | 11607 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 11884 EXPECT_TRUE(response->was_npn_negotiated); | 11608 EXPECT_TRUE(response->was_npn_negotiated); |
| 11885 } | 11609 } |
| 11886 | 11610 |
| 11887 // Simulate the SSL handshake completing with an NPN negotiation followed by an | 11611 // Simulate the SSL handshake completing with an NPN negotiation followed by an |
| 11888 // immediate server closing of the socket. | 11612 // immediate server closing of the socket. |
| 11889 // Regression test for https://crbug.com/46369. | 11613 // Regression test for https://crbug.com/46369. |
| 11890 TEST_P(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { | 11614 TEST_P(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { |
| 11891 session_deps_.parse_alternative_services = true; | |
| 11892 session_deps_.enable_alternative_service_with_different_host = false; | 11615 session_deps_.enable_alternative_service_with_different_host = false; |
| 11893 | 11616 |
| 11894 HttpRequestInfo request; | 11617 HttpRequestInfo request; |
| 11895 request.method = "GET"; | 11618 request.method = "GET"; |
| 11896 request.url = GURL("https://www.example.org/"); | 11619 request.url = GURL("https://www.example.org/"); |
| 11897 request.load_flags = 0; | 11620 request.load_flags = 0; |
| 11898 | 11621 |
| 11899 SSLSocketDataProvider ssl(ASYNC, OK); | 11622 SSLSocketDataProvider ssl(ASYNC, OK); |
| 11900 ssl.SetNextProto(GetProtocol()); | 11623 ssl.SetNextProto(GetProtocol()); |
| 11901 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11624 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11941 return HttpAuthHandlerMock::GenerateAuthTokenImpl( | 11664 return HttpAuthHandlerMock::GenerateAuthTokenImpl( |
| 11942 credentials, request, callback, auth_token); | 11665 credentials, request, callback, auth_token); |
| 11943 } | 11666 } |
| 11944 | 11667 |
| 11945 private: | 11668 private: |
| 11946 GURL* url_; | 11669 GURL* url_; |
| 11947 }; | 11670 }; |
| 11948 | 11671 |
| 11949 // This test ensures that the URL passed into the proxy is upgraded to https | 11672 // This test ensures that the URL passed into the proxy is upgraded to https |
| 11950 // when doing an Alternate Protocol upgrade. | 11673 // when doing an Alternate Protocol upgrade. |
| 11951 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { | 11674 TEST_P(HttpNetworkTransactionTest, SpdyAlternativeServiceThroughProxy) { |
| 11952 session_deps_.parse_alternative_services = false; | |
| 11953 session_deps_.enable_alternative_service_with_different_host = false; | 11675 session_deps_.enable_alternative_service_with_different_host = false; |
| 11954 | 11676 |
| 11955 session_deps_.proxy_service = | 11677 session_deps_.proxy_service = |
| 11956 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); | 11678 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); |
| 11957 TestNetLog net_log; | 11679 TestNetLog net_log; |
| 11958 session_deps_.net_log = &net_log; | 11680 session_deps_.net_log = &net_log; |
| 11959 GURL request_url; | 11681 GURL request_url; |
| 11960 { | 11682 { |
| 11961 HttpAuthHandlerMock::Factory* auth_factory = | 11683 HttpAuthHandlerMock::Factory* auth_factory = |
| 11962 new HttpAuthHandlerMock::Factory(); | 11684 new HttpAuthHandlerMock::Factory(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 11974 | 11696 |
| 11975 // First round goes unauthenticated through the proxy. | 11697 // First round goes unauthenticated through the proxy. |
| 11976 MockWrite data_writes_1[] = { | 11698 MockWrite data_writes_1[] = { |
| 11977 MockWrite( | 11699 MockWrite( |
| 11978 "GET http://www.example.org/ HTTP/1.1\r\n" | 11700 "GET http://www.example.org/ HTTP/1.1\r\n" |
| 11979 "Host: www.example.org\r\n" | 11701 "Host: www.example.org\r\n" |
| 11980 "Proxy-Connection: keep-alive\r\n" | 11702 "Proxy-Connection: keep-alive\r\n" |
| 11981 "\r\n"), | 11703 "\r\n"), |
| 11982 }; | 11704 }; |
| 11983 MockRead data_reads_1[] = { | 11705 MockRead data_reads_1[] = { |
| 11984 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 11706 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 11985 MockRead("HTTP/1.1 200 OK\r\n"), | 11707 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11986 MockRead("Alternate-Protocol: 443:"), | 11708 MockRead("Alt-Svc: "), |
| 11987 MockRead(GetAlternateProtocolFromParam()), | 11709 MockRead(GetAlternateProtocolFromParam()), |
| 11988 MockRead("\r\n"), | 11710 MockRead("=\":443\"\r\n"), |
| 11989 MockRead("Proxy-Connection: close\r\n"), | 11711 MockRead("Proxy-Connection: close\r\n"), |
| 11990 MockRead("\r\n"), | 11712 MockRead("\r\n"), |
| 11991 }; | 11713 }; |
| 11992 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), | 11714 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), |
| 11993 data_writes_1, arraysize(data_writes_1)); | 11715 data_writes_1, arraysize(data_writes_1)); |
| 11994 | 11716 |
| 11995 // Second round tries to tunnel to www.example.org due to the | 11717 // Second round tries to tunnel to www.example.org due to the |
| 11996 // Alternate-Protocol announcement in the first round. It fails due | 11718 // Alternate-Protocol announcement in the first round. It fails due |
| 11997 // to a proxy authentication challenge. | 11719 // to a proxy authentication challenge. |
| 11998 // After the failure, a tunnel is established to www.example.org using | 11720 // After the failure, a tunnel is established to www.example.org using |
| 11999 // Proxy-Authorization headers. There is then a SPDY request round. | 11721 // Proxy-Authorization headers. There is then a SPDY request round. |
| 12000 // | 11722 // |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12875 // certificate was removed from the client auth cache. | 12597 // certificate was removed from the client auth cache. |
| 12876 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( | 12598 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( |
| 12877 HostPortPair("proxy", 70), &client_cert, &client_private_key)); | 12599 HostPortPair("proxy", 70), &client_cert, &client_private_key)); |
| 12878 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( | 12600 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( |
| 12879 HostPortPair("www.example.com", 443), &client_cert, | 12601 HostPortPair("www.example.com", 443), &client_cert, |
| 12880 &client_private_key)); | 12602 &client_private_key)); |
| 12881 } | 12603 } |
| 12882 } | 12604 } |
| 12883 | 12605 |
| 12884 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) { | 12606 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPooling) { |
| 12885 session_deps_.parse_alternative_services = true; | |
| 12886 session_deps_.enable_alternative_service_with_different_host = false; | 12607 session_deps_.enable_alternative_service_with_different_host = false; |
| 12887 | 12608 |
| 12888 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 12609 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
| 12889 session_deps_.host_resolver.reset(new MockCachingHostResolver()); | 12610 session_deps_.host_resolver.reset(new MockCachingHostResolver()); |
| 12890 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12611 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12891 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 12612 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
| 12892 pool_peer.DisableDomainAuthenticationVerification(); | 12613 pool_peer.DisableDomainAuthenticationVerification(); |
| 12893 | 12614 |
| 12894 SSLSocketDataProvider ssl(ASYNC, OK); | 12615 SSLSocketDataProvider ssl(ASYNC, OK); |
| 12895 ssl.SetNextProto(GetProtocol()); | 12616 ssl.SetNextProto(GetProtocol()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12973 ASSERT_TRUE(response); | 12694 ASSERT_TRUE(response); |
| 12974 ASSERT_TRUE(response->headers); | 12695 ASSERT_TRUE(response->headers); |
| 12975 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 12696 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 12976 EXPECT_TRUE(response->was_fetched_via_spdy); | 12697 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 12977 EXPECT_TRUE(response->was_npn_negotiated); | 12698 EXPECT_TRUE(response->was_npn_negotiated); |
| 12978 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 12699 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 12979 EXPECT_EQ("hello!", response_data); | 12700 EXPECT_EQ("hello!", response_data); |
| 12980 } | 12701 } |
| 12981 | 12702 |
| 12982 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { | 12703 TEST_P(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { |
| 12983 session_deps_.parse_alternative_services = true; | |
| 12984 session_deps_.enable_alternative_service_with_different_host = false; | 12704 session_deps_.enable_alternative_service_with_different_host = false; |
| 12985 | 12705 |
| 12986 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 12706 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
| 12987 session_deps_.host_resolver.reset(new MockCachingHostResolver()); | 12707 session_deps_.host_resolver.reset(new MockCachingHostResolver()); |
| 12988 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12708 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12989 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 12709 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
| 12990 pool_peer.DisableDomainAuthenticationVerification(); | 12710 pool_peer.DisableDomainAuthenticationVerification(); |
| 12991 | 12711 |
| 12992 SSLSocketDataProvider ssl(ASYNC, OK); | 12712 SSLSocketDataProvider ssl(ASYNC, OK); |
| 12993 ssl.SetNextProto(GetProtocol()); | 12713 ssl.SetNextProto(GetProtocol()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13099 return &host_resolver_; | 12819 return &host_resolver_; |
| 13100 } | 12820 } |
| 13101 | 12821 |
| 13102 private: | 12822 private: |
| 13103 MockCachingHostResolver host_resolver_; | 12823 MockCachingHostResolver host_resolver_; |
| 13104 const HostPortPair host_port_; | 12824 const HostPortPair host_port_; |
| 13105 }; | 12825 }; |
| 13106 | 12826 |
| 13107 TEST_P(HttpNetworkTransactionTest, | 12827 TEST_P(HttpNetworkTransactionTest, |
| 13108 UseIPConnectionPoolingWithHostCacheExpiration) { | 12828 UseIPConnectionPoolingWithHostCacheExpiration) { |
| 13109 session_deps_.parse_alternative_services = true; | |
| 13110 session_deps_.enable_alternative_service_with_different_host = false; | 12829 session_deps_.enable_alternative_service_with_different_host = false; |
| 13111 | 12830 |
| 13112 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. | 12831 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. |
| 13113 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); | 12832 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); |
| 13114 HttpNetworkSession::Params params = | 12833 HttpNetworkSession::Params params = |
| 13115 SpdySessionDependencies::CreateSessionParams(&session_deps_); | 12834 SpdySessionDependencies::CreateSessionParams(&session_deps_); |
| 13116 params.host_resolver = &host_resolver; | 12835 params.host_resolver = &host_resolver; |
| 13117 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12836 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13118 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 12837 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
| 13119 pool_peer.DisableDomainAuthenticationVerification(); | 12838 pool_peer.DisableDomainAuthenticationVerification(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13357 SequencedSocketData data(reads.data(), reads.size(), writes.data(), | 13076 SequencedSocketData data(reads.data(), reads.size(), writes.data(), |
| 13358 writes.size()); | 13077 writes.size()); |
| 13359 session_deps_.socket_factory->AddSocketDataProvider(&data); | 13078 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 13360 | 13079 |
| 13361 // Connection to the server fails. | 13080 // Connection to the server fails. |
| 13362 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 13081 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 13363 StaticSocketDataProvider data_refused; | 13082 StaticSocketDataProvider data_refused; |
| 13364 data_refused.set_connect_data(mock_connect); | 13083 data_refused.set_connect_data(mock_connect); |
| 13365 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); | 13084 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); |
| 13366 | 13085 |
| 13367 session_deps_.parse_alternative_services = true; | |
| 13368 session_deps_.enable_alternative_service_with_different_host = true; | 13086 session_deps_.enable_alternative_service_with_different_host = true; |
| 13369 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13087 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13370 base::WeakPtr<HttpServerProperties> http_server_properties = | 13088 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13371 session->http_server_properties(); | 13089 session->http_server_properties(); |
| 13372 AlternativeService alternative_service( | 13090 AlternativeService alternative_service( |
| 13373 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13091 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13374 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13092 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13375 http_server_properties->SetAlternativeService(server, alternative_service, | 13093 http_server_properties->SetAlternativeService(server, alternative_service, |
| 13376 expiration); | 13094 expiration); |
| 13377 | 13095 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13462 session_deps_.socket_factory->AddSocketDataProvider(&data); | 13180 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 13463 | 13181 |
| 13464 // This test documents that an alternate Job should not be used if HTTP/1.1 is | 13182 // This test documents that an alternate Job should not be used if HTTP/1.1 is |
| 13465 // negotiated. In order to test this, a failed connection to the server is | 13183 // negotiated. In order to test this, a failed connection to the server is |
| 13466 // mocked. This way the request relies on the alternate Job. | 13184 // mocked. This way the request relies on the alternate Job. |
| 13467 StaticSocketDataProvider data_refused; | 13185 StaticSocketDataProvider data_refused; |
| 13468 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); | 13186 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); |
| 13469 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); | 13187 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); |
| 13470 | 13188 |
| 13471 // Set up alternative service for server. | 13189 // Set up alternative service for server. |
| 13472 session_deps_.parse_alternative_services = true; | |
| 13473 session_deps_.enable_alternative_service_with_different_host = true; | 13190 session_deps_.enable_alternative_service_with_different_host = true; |
| 13474 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13191 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13475 base::WeakPtr<HttpServerProperties> http_server_properties = | 13192 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13476 session->http_server_properties(); | 13193 session->http_server_properties(); |
| 13477 AlternativeService alternative_service( | 13194 AlternativeService alternative_service( |
| 13478 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13195 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13479 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13196 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13480 http_server_properties->SetAlternativeService(server, alternative_service, | 13197 http_server_properties->SetAlternativeService(server, alternative_service, |
| 13481 expiration); | 13198 expiration); |
| 13482 | 13199 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13536 MockRead("HTTP/1.1 200 OK\r\n"), | 13253 MockRead("HTTP/1.1 200 OK\r\n"), |
| 13537 MockRead("Content-Type: text/html\r\n"), | 13254 MockRead("Content-Type: text/html\r\n"), |
| 13538 MockRead("Content-Length: 7\r\n\r\n"), | 13255 MockRead("Content-Length: 7\r\n\r\n"), |
| 13539 MockRead("another"), | 13256 MockRead("another"), |
| 13540 }; | 13257 }; |
| 13541 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), | 13258 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
| 13542 http_writes, arraysize(http_writes)); | 13259 http_writes, arraysize(http_writes)); |
| 13543 session_deps_.socket_factory->AddSocketDataProvider(&http_data); | 13260 session_deps_.socket_factory->AddSocketDataProvider(&http_data); |
| 13544 | 13261 |
| 13545 // Set up alternative service for server. | 13262 // Set up alternative service for server. |
| 13546 session_deps_.parse_alternative_services = true; | |
| 13547 session_deps_.enable_alternative_service_with_different_host = true; | 13263 session_deps_.enable_alternative_service_with_different_host = true; |
| 13548 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13264 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13549 base::WeakPtr<HttpServerProperties> http_server_properties = | 13265 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13550 session->http_server_properties(); | 13266 session->http_server_properties(); |
| 13551 AlternativeService alternative_service( | 13267 AlternativeService alternative_service( |
| 13552 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13268 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13553 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13269 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13554 http_server_properties->SetAlternativeService(server, alternative_service, | 13270 http_server_properties->SetAlternativeService(server, alternative_service, |
| 13555 expiration); | 13271 expiration); |
| 13556 | 13272 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13646 session_deps_.socket_factory->AddSocketDataProvider(&http_data); | 13362 session_deps_.socket_factory->AddSocketDataProvider(&http_data); |
| 13647 | 13363 |
| 13648 // This test documents that an alternate Job should not pool to an already | 13364 // This test documents that an alternate Job should not pool to an already |
| 13649 // existing HTTP/1.1 connection. In order to test this, a failed connection | 13365 // existing HTTP/1.1 connection. In order to test this, a failed connection |
| 13650 // to the server is mocked. This way |request2| relies on the alternate Job. | 13366 // to the server is mocked. This way |request2| relies on the alternate Job. |
| 13651 StaticSocketDataProvider data_refused; | 13367 StaticSocketDataProvider data_refused; |
| 13652 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); | 13368 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); |
| 13653 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); | 13369 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); |
| 13654 | 13370 |
| 13655 // Set up alternative service for server. | 13371 // Set up alternative service for server. |
| 13656 session_deps_.parse_alternative_services = true; | |
| 13657 session_deps_.enable_alternative_service_with_different_host = false; | 13372 session_deps_.enable_alternative_service_with_different_host = false; |
| 13658 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13373 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13659 base::WeakPtr<HttpServerProperties> http_server_properties = | 13374 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13660 session->http_server_properties(); | 13375 session->http_server_properties(); |
| 13661 AlternativeService alternative_service( | 13376 AlternativeService alternative_service( |
| 13662 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13377 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13663 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13378 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13664 http_server_properties->SetAlternativeService(server, alternative_service, | 13379 http_server_properties->SetAlternativeService(server, alternative_service, |
| 13665 expiration); | 13380 expiration); |
| 13666 | 13381 |
| (...skipping 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15974 base::MessageLoop::current()->RunUntilIdle(); | 15689 base::MessageLoop::current()->RunUntilIdle(); |
| 15975 | 15690 |
| 15976 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15691 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15977 HttpRequestHeaders headers; | 15692 HttpRequestHeaders headers; |
| 15978 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15693 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15979 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15694 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15980 } | 15695 } |
| 15981 #endif // !defined(OS_IOS) | 15696 #endif // !defined(OS_IOS) |
| 15982 | 15697 |
| 15983 } // namespace net | 15698 } // namespace net |
| OLD | NEW |