| 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 9860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9871 http_server_properties->GetAlternativeServices(test_server); | 9871 http_server_properties->GetAlternativeServices(test_server); |
| 9872 EXPECT_TRUE(alternative_service_vector.empty()); | 9872 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9873 | 9873 |
| 9874 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 9874 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 9875 | 9875 |
| 9876 const HttpResponseInfo* response = trans.GetResponseInfo(); | 9876 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 9877 ASSERT_TRUE(response); | 9877 ASSERT_TRUE(response); |
| 9878 ASSERT_TRUE(response->headers); | 9878 ASSERT_TRUE(response->headers); |
| 9879 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9879 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9880 EXPECT_FALSE(response->was_fetched_via_spdy); | 9880 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9881 EXPECT_FALSE(response->was_npn_negotiated); | 9881 EXPECT_FALSE(response->was_alpn_negotiated); |
| 9882 | 9882 |
| 9883 std::string response_data; | 9883 std::string response_data; |
| 9884 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 9884 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
| 9885 EXPECT_EQ("hello world", response_data); | 9885 EXPECT_EQ("hello world", response_data); |
| 9886 | 9886 |
| 9887 alternative_service_vector = | 9887 alternative_service_vector = |
| 9888 http_server_properties->GetAlternativeServices(test_server); | 9888 http_server_properties->GetAlternativeServices(test_server); |
| 9889 ASSERT_EQ(1u, alternative_service_vector.size()); | 9889 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 9890 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoHTTP2), | 9890 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoHTTP2), |
| 9891 alternative_service_vector[0].protocol); | 9891 alternative_service_vector[0].protocol); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9926 | 9926 |
| 9927 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 9927 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
| 9928 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 9928 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 9929 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 9929 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 9930 | 9930 |
| 9931 const HttpResponseInfo* response = trans.GetResponseInfo(); | 9931 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 9932 ASSERT_TRUE(response); | 9932 ASSERT_TRUE(response); |
| 9933 ASSERT_TRUE(response->headers); | 9933 ASSERT_TRUE(response->headers); |
| 9934 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9934 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9935 EXPECT_FALSE(response->was_fetched_via_spdy); | 9935 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9936 EXPECT_FALSE(response->was_npn_negotiated); | 9936 EXPECT_FALSE(response->was_alpn_negotiated); |
| 9937 | 9937 |
| 9938 std::string response_data; | 9938 std::string response_data; |
| 9939 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 9939 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
| 9940 EXPECT_EQ("hello world", response_data); | 9940 EXPECT_EQ("hello world", response_data); |
| 9941 | 9941 |
| 9942 alternative_service_vector = | 9942 alternative_service_vector = |
| 9943 http_server_properties->GetAlternativeServices(test_server); | 9943 http_server_properties->GetAlternativeServices(test_server); |
| 9944 EXPECT_TRUE(alternative_service_vector.empty()); | 9944 EXPECT_TRUE(alternative_service_vector.empty()); |
| 9945 } | 9945 } |
| 9946 | 9946 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10069 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 10069 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 10070 | 10070 |
| 10071 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 10071 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
| 10072 EXPECT_THAT(callback.GetResult(rv), IsOk()); | 10072 EXPECT_THAT(callback.GetResult(rv), IsOk()); |
| 10073 | 10073 |
| 10074 const HttpResponseInfo* response = trans.GetResponseInfo(); | 10074 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 10075 ASSERT_TRUE(response); | 10075 ASSERT_TRUE(response); |
| 10076 ASSERT_TRUE(response->headers); | 10076 ASSERT_TRUE(response->headers); |
| 10077 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10077 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10078 EXPECT_FALSE(response->was_fetched_via_spdy); | 10078 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10079 EXPECT_FALSE(response->was_npn_negotiated); | 10079 EXPECT_FALSE(response->was_alpn_negotiated); |
| 10080 | 10080 |
| 10081 std::string response_data; | 10081 std::string response_data; |
| 10082 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 10082 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
| 10083 EXPECT_EQ("hello world", response_data); | 10083 EXPECT_EQ("hello world", response_data); |
| 10084 | 10084 |
| 10085 alternative_service_vector = | 10085 alternative_service_vector = |
| 10086 http_server_properties->GetAlternativeServices(test_server); | 10086 http_server_properties->GetAlternativeServices(test_server); |
| 10087 EXPECT_TRUE(alternative_service_vector.empty()); | 10087 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10088 } | 10088 } |
| 10089 | 10089 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10122 http_server_properties->GetAlternativeServices(test_server); | 10122 http_server_properties->GetAlternativeServices(test_server); |
| 10123 EXPECT_TRUE(alternative_service_vector.empty()); | 10123 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10124 | 10124 |
| 10125 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 10125 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 10126 | 10126 |
| 10127 const HttpResponseInfo* response = trans.GetResponseInfo(); | 10127 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 10128 ASSERT_TRUE(response); | 10128 ASSERT_TRUE(response); |
| 10129 ASSERT_TRUE(response->headers); | 10129 ASSERT_TRUE(response->headers); |
| 10130 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10130 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10131 EXPECT_FALSE(response->was_fetched_via_spdy); | 10131 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10132 EXPECT_FALSE(response->was_npn_negotiated); | 10132 EXPECT_FALSE(response->was_alpn_negotiated); |
| 10133 | 10133 |
| 10134 std::string response_data; | 10134 std::string response_data; |
| 10135 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 10135 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
| 10136 EXPECT_EQ("hello world", response_data); | 10136 EXPECT_EQ("hello world", response_data); |
| 10137 | 10137 |
| 10138 alternative_service_vector = | 10138 alternative_service_vector = |
| 10139 http_server_properties->GetAlternativeServices(test_server); | 10139 http_server_properties->GetAlternativeServices(test_server); |
| 10140 ASSERT_EQ(2u, alternative_service_vector.size()); | 10140 ASSERT_EQ(2u, alternative_service_vector.size()); |
| 10141 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoHTTP2), | 10141 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoHTTP2), |
| 10142 alternative_service_vector[0].protocol); | 10142 alternative_service_vector[0].protocol); |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10713 | 10713 |
| 10714 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10714 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10715 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 10715 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 10716 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 10716 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 10717 | 10717 |
| 10718 response = trans->GetResponseInfo(); | 10718 response = trans->GetResponseInfo(); |
| 10719 ASSERT_TRUE(response); | 10719 ASSERT_TRUE(response); |
| 10720 ASSERT_TRUE(response->headers); | 10720 ASSERT_TRUE(response->headers); |
| 10721 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10721 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10722 EXPECT_TRUE(response->was_fetched_via_spdy); | 10722 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10723 EXPECT_TRUE(response->was_npn_negotiated); | 10723 EXPECT_TRUE(response->was_alpn_negotiated); |
| 10724 | 10724 |
| 10725 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 10725 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 10726 EXPECT_EQ("hello!", response_data); | 10726 EXPECT_EQ("hello!", response_data); |
| 10727 } | 10727 } |
| 10728 | 10728 |
| 10729 TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { | 10729 TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { |
| 10730 HttpRequestInfo request; | 10730 HttpRequestInfo request; |
| 10731 request.method = "GET"; | 10731 request.method = "GET"; |
| 10732 request.url = GURL("https://www.example.org/"); | 10732 request.url = GURL("https://www.example.org/"); |
| 10733 request.load_flags = 0; | 10733 request.load_flags = 0; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10823 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 10823 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 10824 | 10824 |
| 10825 EXPECT_THAT(callback2.WaitForResult(), IsOk()); | 10825 EXPECT_THAT(callback2.WaitForResult(), IsOk()); |
| 10826 EXPECT_THAT(callback3.WaitForResult(), IsOk()); | 10826 EXPECT_THAT(callback3.WaitForResult(), IsOk()); |
| 10827 | 10827 |
| 10828 response = trans2.GetResponseInfo(); | 10828 response = trans2.GetResponseInfo(); |
| 10829 ASSERT_TRUE(response); | 10829 ASSERT_TRUE(response); |
| 10830 ASSERT_TRUE(response->headers); | 10830 ASSERT_TRUE(response->headers); |
| 10831 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10831 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10832 EXPECT_TRUE(response->was_fetched_via_spdy); | 10832 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10833 EXPECT_TRUE(response->was_npn_negotiated); | 10833 EXPECT_TRUE(response->was_alpn_negotiated); |
| 10834 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); | 10834 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); |
| 10835 EXPECT_EQ("hello!", response_data); | 10835 EXPECT_EQ("hello!", response_data); |
| 10836 | 10836 |
| 10837 response = trans3.GetResponseInfo(); | 10837 response = trans3.GetResponseInfo(); |
| 10838 ASSERT_TRUE(response); | 10838 ASSERT_TRUE(response); |
| 10839 ASSERT_TRUE(response->headers); | 10839 ASSERT_TRUE(response->headers); |
| 10840 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10840 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10841 EXPECT_TRUE(response->was_fetched_via_spdy); | 10841 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10842 EXPECT_TRUE(response->was_npn_negotiated); | 10842 EXPECT_TRUE(response->was_alpn_negotiated); |
| 10843 ASSERT_THAT(ReadTransaction(&trans3, &response_data), IsOk()); | 10843 ASSERT_THAT(ReadTransaction(&trans3, &response_data), IsOk()); |
| 10844 EXPECT_EQ("hello!", response_data); | 10844 EXPECT_EQ("hello!", response_data); |
| 10845 } | 10845 } |
| 10846 | 10846 |
| 10847 TEST_F(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { | 10847 TEST_F(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { |
| 10848 HttpRequestInfo request; | 10848 HttpRequestInfo request; |
| 10849 request.method = "GET"; | 10849 request.method = "GET"; |
| 10850 request.url = GURL("https://www.example.org/"); | 10850 request.url = GURL("https://www.example.org/"); |
| 10851 request.load_flags = 0; | 10851 request.load_flags = 0; |
| 10852 | 10852 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10903 | 10903 |
| 10904 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 10904 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 10905 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 10905 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 10906 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 10906 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 10907 | 10907 |
| 10908 response = trans->GetResponseInfo(); | 10908 response = trans->GetResponseInfo(); |
| 10909 ASSERT_TRUE(response); | 10909 ASSERT_TRUE(response); |
| 10910 ASSERT_TRUE(response->headers); | 10910 ASSERT_TRUE(response->headers); |
| 10911 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 10911 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 10912 EXPECT_FALSE(response->was_fetched_via_spdy); | 10912 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 10913 EXPECT_FALSE(response->was_npn_negotiated); | 10913 EXPECT_FALSE(response->was_alpn_negotiated); |
| 10914 | 10914 |
| 10915 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 10915 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 10916 EXPECT_EQ("hello world", response_data); | 10916 EXPECT_EQ("hello world", response_data); |
| 10917 } | 10917 } |
| 10918 | 10918 |
| 10919 class CapturingProxyResolver : public ProxyResolver { | 10919 class CapturingProxyResolver : public ProxyResolver { |
| 10920 public: | 10920 public: |
| 10921 CapturingProxyResolver() {} | 10921 CapturingProxyResolver() {} |
| 10922 ~CapturingProxyResolver() override {} | 10922 ~CapturingProxyResolver() override {} |
| 10923 | 10923 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11041 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 11041 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 11042 | 11042 |
| 11043 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 11043 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
| 11044 EXPECT_THAT(callback.GetResult(rv), IsOk()); | 11044 EXPECT_THAT(callback.GetResult(rv), IsOk()); |
| 11045 | 11045 |
| 11046 const HttpResponseInfo* response = trans.GetResponseInfo(); | 11046 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 11047 ASSERT_TRUE(response); | 11047 ASSERT_TRUE(response); |
| 11048 ASSERT_TRUE(response->headers); | 11048 ASSERT_TRUE(response->headers); |
| 11049 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 11049 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 11050 EXPECT_TRUE(response->was_fetched_via_spdy); | 11050 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 11051 EXPECT_TRUE(response->was_npn_negotiated); | 11051 EXPECT_TRUE(response->was_alpn_negotiated); |
| 11052 | 11052 |
| 11053 std::string response_data; | 11053 std::string response_data; |
| 11054 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 11054 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
| 11055 EXPECT_EQ("hello!", response_data); | 11055 EXPECT_EQ("hello!", response_data); |
| 11056 | 11056 |
| 11057 // Origin host bypasses proxy, no resolution should have happened. | 11057 // Origin host bypasses proxy, no resolution should have happened. |
| 11058 ASSERT_TRUE(capturing_proxy_resolver.resolved().empty()); | 11058 ASSERT_TRUE(capturing_proxy_resolver.resolved().empty()); |
| 11059 } | 11059 } |
| 11060 | 11060 |
| 11061 TEST_F(HttpNetworkTransactionTest, UseAlternativeServiceForTunneledNpnSpdy) { | 11061 TEST_F(HttpNetworkTransactionTest, UseAlternativeServiceForTunneledNpnSpdy) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11139 | 11139 |
| 11140 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11140 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11141 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 11141 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 11142 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 11142 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 11143 | 11143 |
| 11144 const HttpResponseInfo* response = trans->GetResponseInfo(); | 11144 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 11145 ASSERT_TRUE(response); | 11145 ASSERT_TRUE(response); |
| 11146 ASSERT_TRUE(response->headers); | 11146 ASSERT_TRUE(response->headers); |
| 11147 EXPECT_EQ("HTTP/0.9 200 OK", response->headers->GetStatusLine()); | 11147 EXPECT_EQ("HTTP/0.9 200 OK", response->headers->GetStatusLine()); |
| 11148 EXPECT_FALSE(response->was_fetched_via_spdy); | 11148 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 11149 EXPECT_TRUE(response->was_npn_negotiated); | 11149 EXPECT_TRUE(response->was_alpn_negotiated); |
| 11150 | 11150 |
| 11151 std::string response_data; | 11151 std::string response_data; |
| 11152 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 11152 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 11153 EXPECT_EQ("hello world", response_data); | 11153 EXPECT_EQ("hello world", response_data); |
| 11154 | 11154 |
| 11155 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11155 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 11156 | 11156 |
| 11157 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11157 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11158 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 11158 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 11159 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 11159 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 11160 | 11160 |
| 11161 response = trans->GetResponseInfo(); | 11161 response = trans->GetResponseInfo(); |
| 11162 ASSERT_TRUE(response); | 11162 ASSERT_TRUE(response); |
| 11163 ASSERT_TRUE(response->headers); | 11163 ASSERT_TRUE(response->headers); |
| 11164 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 11164 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 11165 EXPECT_TRUE(response->was_fetched_via_spdy); | 11165 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 11166 EXPECT_TRUE(response->was_npn_negotiated); | 11166 EXPECT_TRUE(response->was_alpn_negotiated); |
| 11167 | 11167 |
| 11168 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 11168 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 11169 EXPECT_EQ("hello!", response_data); | 11169 EXPECT_EQ("hello!", response_data); |
| 11170 ASSERT_EQ(2u, capturing_proxy_resolver.resolved().size()); | 11170 ASSERT_EQ(2u, capturing_proxy_resolver.resolved().size()); |
| 11171 EXPECT_EQ("https://www.example.org/", | 11171 EXPECT_EQ("https://www.example.org/", |
| 11172 capturing_proxy_resolver.resolved()[0].spec()); | 11172 capturing_proxy_resolver.resolved()[0].spec()); |
| 11173 EXPECT_EQ("https://www.example.org/", | 11173 EXPECT_EQ("https://www.example.org/", |
| 11174 capturing_proxy_resolver.resolved()[1].spec()); | 11174 capturing_proxy_resolver.resolved()[1].spec()); |
| 11175 | 11175 |
| 11176 LoadTimingInfo load_timing_info; | 11176 LoadTimingInfo load_timing_info; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11253 | 11253 |
| 11254 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 11254 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 11255 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 11255 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 11256 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 11256 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 11257 | 11257 |
| 11258 response = trans->GetResponseInfo(); | 11258 response = trans->GetResponseInfo(); |
| 11259 ASSERT_TRUE(response); | 11259 ASSERT_TRUE(response); |
| 11260 ASSERT_TRUE(response->headers); | 11260 ASSERT_TRUE(response->headers); |
| 11261 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 11261 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 11262 EXPECT_TRUE(response->was_fetched_via_spdy); | 11262 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 11263 EXPECT_TRUE(response->was_npn_negotiated); | 11263 EXPECT_TRUE(response->was_alpn_negotiated); |
| 11264 | 11264 |
| 11265 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 11265 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 11266 EXPECT_EQ("hello!", response_data); | 11266 EXPECT_EQ("hello!", response_data); |
| 11267 } | 11267 } |
| 11268 | 11268 |
| 11269 // GenerateAuthToken is a mighty big test. | 11269 // GenerateAuthToken is a mighty big test. |
| 11270 // It tests all permutation of GenerateAuthToken behavior: | 11270 // It tests all permutation of GenerateAuthToken behavior: |
| 11271 // - Synchronous and Asynchronous completion. | 11271 // - Synchronous and Asynchronous completion. |
| 11272 // - OK or error on completion. | 11272 // - OK or error on completion. |
| 11273 // - Direct connection, non-authenticating proxy, and authenticating proxy. | 11273 // - Direct connection, non-authenticating proxy, and authenticating proxy. |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11920 const HttpResponseInfo* response = trans.GetResponseInfo(); | 11920 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 11921 ASSERT_TRUE(response); | 11921 ASSERT_TRUE(response); |
| 11922 ASSERT_TRUE(response->headers); | 11922 ASSERT_TRUE(response->headers); |
| 11923 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11923 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 11924 | 11924 |
| 11925 std::string response_data; | 11925 std::string response_data; |
| 11926 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 11926 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
| 11927 EXPECT_EQ("hello world", response_data); | 11927 EXPECT_EQ("hello world", response_data); |
| 11928 | 11928 |
| 11929 EXPECT_FALSE(response->was_fetched_via_spdy); | 11929 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 11930 EXPECT_TRUE(response->was_npn_negotiated); | 11930 EXPECT_TRUE(response->was_alpn_negotiated); |
| 11931 } | 11931 } |
| 11932 | 11932 |
| 11933 // Simulate the SSL handshake completing with an NPN negotiation followed by an | 11933 // Simulate the SSL handshake completing with an NPN negotiation followed by an |
| 11934 // immediate server closing of the socket. | 11934 // immediate server closing of the socket. |
| 11935 // Regression test for https://crbug.com/46369. | 11935 // Regression test for https://crbug.com/46369. |
| 11936 TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { | 11936 TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { |
| 11937 HttpRequestInfo request; | 11937 HttpRequestInfo request; |
| 11938 request.method = "GET"; | 11938 request.method = "GET"; |
| 11939 request.url = GURL("https://www.example.org/"); | 11939 request.url = GURL("https://www.example.org/"); |
| 11940 request.load_flags = 0; | 11940 request.load_flags = 0; |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12833 | 12833 |
| 12834 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 12834 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 12835 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 12835 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 12836 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 12836 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 12837 | 12837 |
| 12838 response = trans2.GetResponseInfo(); | 12838 response = trans2.GetResponseInfo(); |
| 12839 ASSERT_TRUE(response); | 12839 ASSERT_TRUE(response); |
| 12840 ASSERT_TRUE(response->headers); | 12840 ASSERT_TRUE(response->headers); |
| 12841 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 12841 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 12842 EXPECT_TRUE(response->was_fetched_via_spdy); | 12842 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 12843 EXPECT_TRUE(response->was_npn_negotiated); | 12843 EXPECT_TRUE(response->was_alpn_negotiated); |
| 12844 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); | 12844 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); |
| 12845 EXPECT_EQ("hello!", response_data); | 12845 EXPECT_EQ("hello!", response_data); |
| 12846 } | 12846 } |
| 12847 | 12847 |
| 12848 TEST_F(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { | 12848 TEST_F(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { |
| 12849 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 12849 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
| 12850 session_deps_.host_resolver.reset(new MockCachingHostResolver()); | 12850 session_deps_.host_resolver.reset(new MockCachingHostResolver()); |
| 12851 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12851 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12852 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 12852 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
| 12853 pool_peer.DisableDomainAuthenticationVerification(); | 12853 pool_peer.DisableDomainAuthenticationVerification(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12910 | 12910 |
| 12911 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 12911 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 12912 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 12912 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 12913 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 12913 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 12914 | 12914 |
| 12915 response = trans2.GetResponseInfo(); | 12915 response = trans2.GetResponseInfo(); |
| 12916 ASSERT_TRUE(response); | 12916 ASSERT_TRUE(response); |
| 12917 ASSERT_TRUE(response->headers); | 12917 ASSERT_TRUE(response->headers); |
| 12918 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 12918 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 12919 EXPECT_TRUE(response->was_fetched_via_spdy); | 12919 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 12920 EXPECT_TRUE(response->was_npn_negotiated); | 12920 EXPECT_TRUE(response->was_alpn_negotiated); |
| 12921 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); | 12921 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); |
| 12922 EXPECT_EQ("hello!", response_data); | 12922 EXPECT_EQ("hello!", response_data); |
| 12923 } | 12923 } |
| 12924 | 12924 |
| 12925 class OneTimeCachingHostResolver : public HostResolver { | 12925 class OneTimeCachingHostResolver : public HostResolver { |
| 12926 public: | 12926 public: |
| 12927 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) | 12927 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) |
| 12928 : host_port_(host_port) {} | 12928 : host_port_(host_port) {} |
| 12929 ~OneTimeCachingHostResolver() override {} | 12929 ~OneTimeCachingHostResolver() override {} |
| 12930 | 12930 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13038 | 13038 |
| 13039 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); | 13039 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 13040 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 13040 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 13041 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 13041 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 13042 | 13042 |
| 13043 response = trans2.GetResponseInfo(); | 13043 response = trans2.GetResponseInfo(); |
| 13044 ASSERT_TRUE(response); | 13044 ASSERT_TRUE(response); |
| 13045 ASSERT_TRUE(response->headers); | 13045 ASSERT_TRUE(response->headers); |
| 13046 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 13046 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 13047 EXPECT_TRUE(response->was_fetched_via_spdy); | 13047 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 13048 EXPECT_TRUE(response->was_npn_negotiated); | 13048 EXPECT_TRUE(response->was_alpn_negotiated); |
| 13049 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); | 13049 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); |
| 13050 EXPECT_EQ("hello!", response_data); | 13050 EXPECT_EQ("hello!", response_data); |
| 13051 } | 13051 } |
| 13052 | 13052 |
| 13053 TEST_F(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) { | 13053 TEST_F(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) { |
| 13054 const std::string https_url = "https://www.example.org:8080/"; | 13054 const std::string https_url = "https://www.example.org:8080/"; |
| 13055 const std::string http_url = "http://www.example.org:8080/"; | 13055 const std::string http_url = "http://www.example.org:8080/"; |
| 13056 | 13056 |
| 13057 // SPDY GET for HTTPS URL | 13057 // SPDY GET for HTTPS URL |
| 13058 SpdySerializedFrame req1( | 13058 SpdySerializedFrame req1( |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13160 expiration); | 13160 expiration); |
| 13161 | 13161 |
| 13162 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 13162 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 13163 HttpRequestInfo request; | 13163 HttpRequestInfo request; |
| 13164 request.method = "GET"; | 13164 request.method = "GET"; |
| 13165 request.url = GURL("https://www.example.org:443"); | 13165 request.url = GURL("https://www.example.org:443"); |
| 13166 request.load_flags = 0; | 13166 request.load_flags = 0; |
| 13167 TestCompletionCallback callback; | 13167 TestCompletionCallback callback; |
| 13168 | 13168 |
| 13169 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is | 13169 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is |
| 13170 // negotiated, the alternate Job should fail with ERR_NPN_NEGOTIATION_FAILED. | 13170 // negotiated, the alternate Job should fail with ERR_ALPN_NEGOTIATION_FAILED. |
| 13171 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 13171 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
| 13172 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_NPN_NEGOTIATION_FAILED)); | 13172 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_ALPN_NEGOTIATION_FAILED)); |
| 13173 } | 13173 } |
| 13174 | 13174 |
| 13175 // A request to a server with an alternative service fires two Jobs: one to the | 13175 // A request to a server with an alternative service fires two Jobs: one to the |
| 13176 // server, and an alternate one to the alternative server. If the former | 13176 // server, and an alternate one to the alternative server. If the former |
| 13177 // succeeds, the request should succeed, even if the latter fails because | 13177 // succeeds, the request should succeed, even if the latter fails because |
| 13178 // HTTP/1.1 is negotiated which is insufficient for alternative service. | 13178 // HTTP/1.1 is negotiated which is insufficient for alternative service. |
| 13179 TEST_F(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) { | 13179 TEST_F(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) { |
| 13180 url::SchemeHostPort server("https", "www.example.org", 443); | 13180 url::SchemeHostPort server("https", "www.example.org", 443); |
| 13181 HostPortPair alternative("www.example.org", 444); | 13181 HostPortPair alternative("www.example.org", 444); |
| 13182 | 13182 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13343 request1.url = GURL(alternative_url); | 13343 request1.url = GURL(alternative_url); |
| 13344 request1.load_flags = 0; | 13344 request1.load_flags = 0; |
| 13345 TestCompletionCallback callback1; | 13345 TestCompletionCallback callback1; |
| 13346 | 13346 |
| 13347 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); | 13347 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); |
| 13348 EXPECT_THAT(callback1.GetResult(rv), IsOk()); | 13348 EXPECT_THAT(callback1.GetResult(rv), IsOk()); |
| 13349 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); | 13349 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); |
| 13350 ASSERT_TRUE(response1); | 13350 ASSERT_TRUE(response1); |
| 13351 ASSERT_TRUE(response1->headers); | 13351 ASSERT_TRUE(response1->headers); |
| 13352 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); | 13352 EXPECT_EQ("HTTP/1.1 200 OK", response1->headers->GetStatusLine()); |
| 13353 EXPECT_TRUE(response1->was_npn_negotiated); | 13353 EXPECT_TRUE(response1->was_alpn_negotiated); |
| 13354 EXPECT_FALSE(response1->was_fetched_via_spdy); | 13354 EXPECT_FALSE(response1->was_fetched_via_spdy); |
| 13355 std::string response_data1; | 13355 std::string response_data1; |
| 13356 ASSERT_THAT(ReadTransaction(&trans1, &response_data1), IsOk()); | 13356 ASSERT_THAT(ReadTransaction(&trans1, &response_data1), IsOk()); |
| 13357 EXPECT_EQ("first HTTP/1.1 response from alternative", response_data1); | 13357 EXPECT_EQ("first HTTP/1.1 response from alternative", response_data1); |
| 13358 | 13358 |
| 13359 // Request for origin.example.org, which has an alternative service. This | 13359 // Request for origin.example.org, which has an alternative service. This |
| 13360 // will start two Jobs: the alternative looks for connections to pool to, | 13360 // will start two Jobs: the alternative looks for connections to pool to, |
| 13361 // finds one which is HTTP/1.1, and should ignore it, and should not try to | 13361 // finds one which is HTTP/1.1, and should ignore it, and should not try to |
| 13362 // open other connections to alternative server. The Job to server fails, so | 13362 // open other connections to alternative server. The Job to server fails, so |
| 13363 // this request fails. | 13363 // this request fails. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 13379 request3.url = GURL(alternative_url); | 13379 request3.url = GURL(alternative_url); |
| 13380 request3.load_flags = 0; | 13380 request3.load_flags = 0; |
| 13381 TestCompletionCallback callback3; | 13381 TestCompletionCallback callback3; |
| 13382 | 13382 |
| 13383 rv = trans3.Start(&request3, callback3.callback(), BoundNetLog()); | 13383 rv = trans3.Start(&request3, callback3.callback(), BoundNetLog()); |
| 13384 EXPECT_THAT(callback3.GetResult(rv), IsOk()); | 13384 EXPECT_THAT(callback3.GetResult(rv), IsOk()); |
| 13385 const HttpResponseInfo* response3 = trans3.GetResponseInfo(); | 13385 const HttpResponseInfo* response3 = trans3.GetResponseInfo(); |
| 13386 ASSERT_TRUE(response3); | 13386 ASSERT_TRUE(response3); |
| 13387 ASSERT_TRUE(response3->headers); | 13387 ASSERT_TRUE(response3->headers); |
| 13388 EXPECT_EQ("HTTP/1.1 200 OK", response3->headers->GetStatusLine()); | 13388 EXPECT_EQ("HTTP/1.1 200 OK", response3->headers->GetStatusLine()); |
| 13389 EXPECT_TRUE(response3->was_npn_negotiated); | 13389 EXPECT_TRUE(response3->was_alpn_negotiated); |
| 13390 EXPECT_FALSE(response3->was_fetched_via_spdy); | 13390 EXPECT_FALSE(response3->was_fetched_via_spdy); |
| 13391 std::string response_data3; | 13391 std::string response_data3; |
| 13392 ASSERT_THAT(ReadTransaction(&trans3, &response_data3), IsOk()); | 13392 ASSERT_THAT(ReadTransaction(&trans3, &response_data3), IsOk()); |
| 13393 EXPECT_EQ("second HTTP/1.1 response from alternative", response_data3); | 13393 EXPECT_EQ("second HTTP/1.1 response from alternative", response_data3); |
| 13394 } | 13394 } |
| 13395 | 13395 |
| 13396 TEST_F(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttpOverTunnel) { | 13396 TEST_F(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttpOverTunnel) { |
| 13397 const std::string https_url = "https://www.example.org:8080/"; | 13397 const std::string https_url = "https://www.example.org:8080/"; |
| 13398 const std::string http_url = "http://www.example.org:8080/"; | 13398 const std::string http_url = "http://www.example.org:8080/"; |
| 13399 | 13399 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13786 | 13786 |
| 13787 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); | 13787 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
| 13788 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 13788 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 13789 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 13789 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 13790 | 13790 |
| 13791 const HttpResponseInfo* response = trans->GetResponseInfo(); | 13791 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 13792 ASSERT_TRUE(response); | 13792 ASSERT_TRUE(response); |
| 13793 ASSERT_TRUE(response->headers); | 13793 ASSERT_TRUE(response->headers); |
| 13794 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 13794 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 13795 EXPECT_TRUE(response->was_fetched_via_spdy); | 13795 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 13796 EXPECT_TRUE(response->was_npn_negotiated); | 13796 EXPECT_TRUE(response->was_alpn_negotiated); |
| 13797 | 13797 |
| 13798 std::string response_data; | 13798 std::string response_data; |
| 13799 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 13799 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 13800 EXPECT_EQ("hello!", response_data); | 13800 EXPECT_EQ("hello!", response_data); |
| 13801 trans.reset(); | 13801 trans.reset(); |
| 13802 EXPECT_TRUE( | 13802 EXPECT_TRUE( |
| 13803 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); | 13803 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); |
| 13804 | 13804 |
| 13805 HostPortPair host_port_pair_b("www.b.com", 443); | 13805 HostPortPair host_port_pair_b("www.b.com", 443); |
| 13806 SpdySessionKey spdy_session_key_b( | 13806 SpdySessionKey spdy_session_key_b( |
| 13807 host_port_pair_b, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); | 13807 host_port_pair_b, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); |
| 13808 EXPECT_FALSE( | 13808 EXPECT_FALSE( |
| 13809 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); | 13809 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); |
| 13810 HttpRequestInfo request2; | 13810 HttpRequestInfo request2; |
| 13811 request2.method = "GET"; | 13811 request2.method = "GET"; |
| 13812 request2.url = GURL("https://www.b.com/"); | 13812 request2.url = GURL("https://www.b.com/"); |
| 13813 request2.load_flags = 0; | 13813 request2.load_flags = 0; |
| 13814 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13814 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13815 | 13815 |
| 13816 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); | 13816 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); |
| 13817 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 13817 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 13818 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 13818 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 13819 | 13819 |
| 13820 response = trans->GetResponseInfo(); | 13820 response = trans->GetResponseInfo(); |
| 13821 ASSERT_TRUE(response); | 13821 ASSERT_TRUE(response); |
| 13822 ASSERT_TRUE(response->headers); | 13822 ASSERT_TRUE(response->headers); |
| 13823 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 13823 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 13824 EXPECT_TRUE(response->was_fetched_via_spdy); | 13824 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 13825 EXPECT_TRUE(response->was_npn_negotiated); | 13825 EXPECT_TRUE(response->was_alpn_negotiated); |
| 13826 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 13826 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 13827 EXPECT_EQ("hello!", response_data); | 13827 EXPECT_EQ("hello!", response_data); |
| 13828 EXPECT_FALSE( | 13828 EXPECT_FALSE( |
| 13829 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); | 13829 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); |
| 13830 EXPECT_TRUE( | 13830 EXPECT_TRUE( |
| 13831 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); | 13831 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); |
| 13832 | 13832 |
| 13833 HostPortPair host_port_pair_a1("www.a.com", 80); | 13833 HostPortPair host_port_pair_a1("www.a.com", 80); |
| 13834 SpdySessionKey spdy_session_key_a1( | 13834 SpdySessionKey spdy_session_key_a1( |
| 13835 host_port_pair_a1, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); | 13835 host_port_pair_a1, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); |
| 13836 EXPECT_FALSE( | 13836 EXPECT_FALSE( |
| 13837 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a1)); | 13837 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a1)); |
| 13838 HttpRequestInfo request3; | 13838 HttpRequestInfo request3; |
| 13839 request3.method = "GET"; | 13839 request3.method = "GET"; |
| 13840 request3.url = GURL("http://www.a.com/"); | 13840 request3.url = GURL("http://www.a.com/"); |
| 13841 request3.load_flags = 0; | 13841 request3.load_flags = 0; |
| 13842 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13842 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13843 | 13843 |
| 13844 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); | 13844 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); |
| 13845 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 13845 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 13846 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 13846 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 13847 | 13847 |
| 13848 response = trans->GetResponseInfo(); | 13848 response = trans->GetResponseInfo(); |
| 13849 ASSERT_TRUE(response); | 13849 ASSERT_TRUE(response); |
| 13850 ASSERT_TRUE(response->headers); | 13850 ASSERT_TRUE(response->headers); |
| 13851 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 13851 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 13852 EXPECT_FALSE(response->was_fetched_via_spdy); | 13852 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 13853 EXPECT_FALSE(response->was_npn_negotiated); | 13853 EXPECT_FALSE(response->was_alpn_negotiated); |
| 13854 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 13854 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 13855 EXPECT_EQ("hello!", response_data); | 13855 EXPECT_EQ("hello!", response_data); |
| 13856 EXPECT_FALSE( | 13856 EXPECT_FALSE( |
| 13857 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); | 13857 HasSpdySession(session->spdy_session_pool(), spdy_session_key_a)); |
| 13858 EXPECT_FALSE( | 13858 EXPECT_FALSE( |
| 13859 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); | 13859 HasSpdySession(session->spdy_session_pool(), spdy_session_key_b)); |
| 13860 } | 13860 } |
| 13861 | 13861 |
| 13862 TEST_F(HttpNetworkTransactionTest, HttpSyncConnectError) { | 13862 TEST_F(HttpNetworkTransactionTest, HttpSyncConnectError) { |
| 13863 HttpRequestInfo request; | 13863 HttpRequestInfo request; |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14253 return ERR_UNEXPECTED; | 14253 return ERR_UNEXPECTED; |
| 14254 } | 14254 } |
| 14255 | 14255 |
| 14256 LoadState GetLoadState() const override { | 14256 LoadState GetLoadState() const override { |
| 14257 ADD_FAILURE(); | 14257 ADD_FAILURE(); |
| 14258 return LoadState(); | 14258 return LoadState(); |
| 14259 } | 14259 } |
| 14260 | 14260 |
| 14261 void SetPriority(RequestPriority priority) override { priority_ = priority; } | 14261 void SetPriority(RequestPriority priority) override { priority_ = priority; } |
| 14262 | 14262 |
| 14263 bool was_npn_negotiated() const override { return false; } | 14263 bool was_alpn_negotiated() const override { return false; } |
| 14264 | 14264 |
| 14265 NextProto negotiated_protocol() const override { return kProtoUnknown; } | 14265 NextProto negotiated_protocol() const override { return kProtoUnknown; } |
| 14266 | 14266 |
| 14267 bool using_spdy() const override { return false; } | 14267 bool using_spdy() const override { return false; } |
| 14268 | 14268 |
| 14269 const ConnectionAttempts& connection_attempts() const override { | 14269 const ConnectionAttempts& connection_attempts() const override { |
| 14270 static ConnectionAttempts no_attempts; | 14270 static ConnectionAttempts no_attempts; |
| 14271 return no_attempts; | 14271 return no_attempts; |
| 14272 } | 14272 } |
| 14273 | 14273 |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15575 base::RunLoop().RunUntilIdle(); | 15575 base::RunLoop().RunUntilIdle(); |
| 15576 | 15576 |
| 15577 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15577 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15578 HttpRequestHeaders headers; | 15578 HttpRequestHeaders headers; |
| 15579 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15579 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15580 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15580 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15581 } | 15581 } |
| 15582 #endif // !defined(OS_IOS) | 15582 #endif // !defined(OS_IOS) |
| 15583 | 15583 |
| 15584 } // namespace net | 15584 } // namespace net |
| OLD | NEW |