| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 const base::string16 kBaz(ASCIIToUTF16("baz")); | 126 const base::string16 kBaz(ASCIIToUTF16("baz")); |
| 127 const base::string16 kFirst(ASCIIToUTF16("first")); | 127 const base::string16 kFirst(ASCIIToUTF16("first")); |
| 128 const base::string16 kFoo(ASCIIToUTF16("foo")); | 128 const base::string16 kFoo(ASCIIToUTF16("foo")); |
| 129 const base::string16 kFoo2(ASCIIToUTF16("foo2")); | 129 const base::string16 kFoo2(ASCIIToUTF16("foo2")); |
| 130 const base::string16 kFoo3(ASCIIToUTF16("foo3")); | 130 const base::string16 kFoo3(ASCIIToUTF16("foo3")); |
| 131 const base::string16 kFou(ASCIIToUTF16("fou")); | 131 const base::string16 kFou(ASCIIToUTF16("fou")); |
| 132 const base::string16 kSecond(ASCIIToUTF16("second")); | 132 const base::string16 kSecond(ASCIIToUTF16("second")); |
| 133 const base::string16 kTestingNTLM(ASCIIToUTF16("testing-ntlm")); | 133 const base::string16 kTestingNTLM(ASCIIToUTF16("testing-ntlm")); |
| 134 const base::string16 kWrongPassword(ASCIIToUTF16("wrongpassword")); | 134 const base::string16 kWrongPassword(ASCIIToUTF16("wrongpassword")); |
| 135 | 135 |
| 136 const char kAlternativeServiceHttpHeader[] = |
| 137 "Alt-Svc: h2=\"mail.example.org:443\"\r\n"; |
| 138 |
| 136 int GetIdleSocketCountInTransportSocketPool(HttpNetworkSession* session) { | 139 int GetIdleSocketCountInTransportSocketPool(HttpNetworkSession* session) { |
| 137 return session->GetTransportSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) | 140 return session->GetTransportSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) |
| 138 ->IdleSocketCount(); | 141 ->IdleSocketCount(); |
| 139 } | 142 } |
| 140 | 143 |
| 141 int GetIdleSocketCountInSSLSocketPool(HttpNetworkSession* session) { | 144 int GetIdleSocketCountInSSLSocketPool(HttpNetworkSession* session) { |
| 142 return session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) | 145 return session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) |
| 143 ->IdleSocketCount(); | 146 ->IdleSocketCount(); |
| 144 } | 147 } |
| 145 | 148 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 } | 322 } |
| 320 | 323 |
| 321 NextProto GetProtocol() const { | 324 NextProto GetProtocol() const { |
| 322 return GetParam() == kTestCaseSPDY31 ? kProtoSPDY31 : kProtoHTTP2; | 325 return GetParam() == kTestCaseSPDY31 ? kProtoSPDY31 : kProtoHTTP2; |
| 323 } | 326 } |
| 324 | 327 |
| 325 bool GetDependenciesFromPriority() const { | 328 bool GetDependenciesFromPriority() const { |
| 326 return GetParam() == kTestCaseHTTP2PriorityDependencies; | 329 return GetParam() == kTestCaseHTTP2PriorityDependencies; |
| 327 } | 330 } |
| 328 | 331 |
| 329 const char* GetAlternateProtocolFromParam() { | |
| 330 return AlternateProtocolToString( | |
| 331 AlternateProtocolFromNextProto(GetProtocol())); | |
| 332 } | |
| 333 | |
| 334 std::string GetAlternativeServiceHttpHeader() { | |
| 335 return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() + | |
| 336 "=\"mail.example.org:443\"\r\n"; | |
| 337 } | |
| 338 | |
| 339 // Either |write_failure| specifies a write failure or |read_failure| | 332 // Either |write_failure| specifies a write failure or |read_failure| |
| 340 // specifies a read failure when using a reused socket. In either case, the | 333 // specifies a read failure when using a reused socket. In either case, the |
| 341 // failure should cause the network transaction to resend the request, and the | 334 // failure should cause the network transaction to resend the request, and the |
| 342 // other argument should be NULL. | 335 // other argument should be NULL. |
| 343 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure, | 336 void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure, |
| 344 const MockRead* read_failure); | 337 const MockRead* read_failure); |
| 345 | 338 |
| 346 // Either |write_failure| specifies a write failure or |read_failure| | 339 // Either |write_failure| specifies a write failure or |read_failure| |
| 347 // specifies a read failure when using a reused socket. In either case, the | 340 // specifies a read failure when using a reused socket. In either case, the |
| 348 // failure should cause the network transaction to resend the request, and the | 341 // failure should cause the network transaction to resend the request, and the |
| (...skipping 9591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9940 AuthCredentials(kFirst, kBar), callback4.callback()); | 9933 AuthCredentials(kFirst, kBar), callback4.callback()); |
| 9941 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 9934 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 9942 rv = callback4.WaitForResult(); | 9935 rv = callback4.WaitForResult(); |
| 9943 EXPECT_THAT(rv, IsOk()); | 9936 EXPECT_THAT(rv, IsOk()); |
| 9944 response = trans->GetResponseInfo(); | 9937 response = trans->GetResponseInfo(); |
| 9945 ASSERT_TRUE(response); | 9938 ASSERT_TRUE(response); |
| 9946 EXPECT_FALSE(response->auth_challenge); | 9939 EXPECT_FALSE(response->auth_challenge); |
| 9947 } | 9940 } |
| 9948 | 9941 |
| 9949 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { | 9942 TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) { |
| 9950 std::string alternative_service_http_header = | 9943 // SPDY/3.1 is not supported. |
| 9951 GetAlternativeServiceHttpHeader(); | 9944 if (GetProtocol() != kProtoHTTP2) { |
| 9945 return; |
| 9946 } |
| 9952 | 9947 |
| 9953 MockRead data_reads[] = { | 9948 MockRead data_reads[] = { |
| 9954 MockRead("HTTP/1.1 200 OK\r\n"), | 9949 MockRead("HTTP/1.1 200 OK\r\n"), |
| 9955 MockRead(alternative_service_http_header.c_str()), | 9950 MockRead(kAlternativeServiceHttpHeader), |
| 9956 MockRead("\r\n"), | 9951 MockRead("\r\n"), |
| 9957 MockRead("hello world"), | 9952 MockRead("hello world"), |
| 9958 MockRead(SYNCHRONOUS, OK), | 9953 MockRead(SYNCHRONOUS, OK), |
| 9959 }; | 9954 }; |
| 9960 | 9955 |
| 9961 HttpRequestInfo request; | 9956 HttpRequestInfo request; |
| 9962 request.method = "GET"; | 9957 request.method = "GET"; |
| 9963 request.url = GURL("https://www.example.org/"); | 9958 request.url = GURL("https://www.example.org/"); |
| 9964 request.load_flags = 0; | 9959 request.load_flags = 0; |
| 9965 | 9960 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10003 ASSERT_EQ(1u, alternative_service_vector.size()); | 9998 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 10004 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), | 9999 EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()), |
| 10005 alternative_service_vector[0].protocol); | 10000 alternative_service_vector[0].protocol); |
| 10006 EXPECT_EQ("mail.example.org", alternative_service_vector[0].host); | 10001 EXPECT_EQ("mail.example.org", alternative_service_vector[0].host); |
| 10007 EXPECT_EQ(443, alternative_service_vector[0].port); | 10002 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 10008 } | 10003 } |
| 10009 | 10004 |
| 10010 // Regression test for https://crbug.com/615497. | 10005 // Regression test for https://crbug.com/615497. |
| 10011 TEST_P(HttpNetworkTransactionTest, | 10006 TEST_P(HttpNetworkTransactionTest, |
| 10012 DoNotParseAlternativeServiceHeaderOnInsecureRequest) { | 10007 DoNotParseAlternativeServiceHeaderOnInsecureRequest) { |
| 10013 std::string alternative_service_http_header = | |
| 10014 GetAlternativeServiceHttpHeader(); | |
| 10015 | |
| 10016 MockRead data_reads[] = { | 10008 MockRead data_reads[] = { |
| 10017 MockRead("HTTP/1.1 200 OK\r\n"), | 10009 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10018 MockRead(alternative_service_http_header.c_str()), | 10010 MockRead(kAlternativeServiceHttpHeader), |
| 10019 MockRead("\r\n"), | 10011 MockRead("\r\n"), |
| 10020 MockRead("hello world"), | 10012 MockRead("hello world"), |
| 10021 MockRead(SYNCHRONOUS, OK), | 10013 MockRead(SYNCHRONOUS, OK), |
| 10022 }; | 10014 }; |
| 10023 | 10015 |
| 10024 HttpRequestInfo request; | 10016 HttpRequestInfo request; |
| 10025 request.method = "GET"; | 10017 request.method = "GET"; |
| 10026 request.url = GURL("http://www.example.org/"); | 10018 request.url = GURL("http://www.example.org/"); |
| 10027 request.load_flags = 0; | 10019 request.load_flags = 0; |
| 10028 | 10020 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10202 std::string response_data; | 10194 std::string response_data; |
| 10203 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 10195 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 10204 EXPECT_EQ("hello world", response_data); | 10196 EXPECT_EQ("hello world", response_data); |
| 10205 | 10197 |
| 10206 alternative_service_vector = | 10198 alternative_service_vector = |
| 10207 http_server_properties->GetAlternativeServices(test_server); | 10199 http_server_properties->GetAlternativeServices(test_server); |
| 10208 EXPECT_TRUE(alternative_service_vector.empty()); | 10200 EXPECT_TRUE(alternative_service_vector.empty()); |
| 10209 } | 10201 } |
| 10210 | 10202 |
| 10211 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeaders) { | 10203 TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeaders) { |
| 10204 // SPDY/3.1 is not supported. |
| 10205 if (GetProtocol() != kProtoHTTP2) { |
| 10206 return; |
| 10207 } |
| 10208 |
| 10212 MockRead data_reads[] = { | 10209 MockRead data_reads[] = { |
| 10213 MockRead("HTTP/1.1 200 OK\r\n"), | 10210 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10214 MockRead("Alt-Svc: "), | 10211 MockRead("Alt-Svc: h2=\"www.example.com:443\","), |
| 10215 MockRead(GetAlternateProtocolFromParam()), | 10212 MockRead("h2=\":1234\"\r\n\r\n"), |
| 10216 MockRead("=\"www.example.com:443\","), | |
| 10217 MockRead(GetAlternateProtocolFromParam()), | |
| 10218 MockRead("=\":1234\"\r\n\r\n"), | |
| 10219 MockRead("hello world"), | 10213 MockRead("hello world"), |
| 10220 MockRead(SYNCHRONOUS, OK), | 10214 MockRead(SYNCHRONOUS, OK), |
| 10221 }; | 10215 }; |
| 10222 | 10216 |
| 10223 HttpRequestInfo request; | 10217 HttpRequestInfo request; |
| 10224 request.method = "GET"; | 10218 request.method = "GET"; |
| 10225 request.url = GURL("https://www.example.org/"); | 10219 request.url = GURL("https://www.example.org/"); |
| 10226 request.load_flags = 0; | 10220 request.load_flags = 0; |
| 10227 | 10221 |
| 10228 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 10222 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10782 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 10776 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 10783 EXPECT_EQ("hello world", response_data); | 10777 EXPECT_EQ("hello world", response_data); |
| 10784 } | 10778 } |
| 10785 | 10779 |
| 10786 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { | 10780 TEST_P(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { |
| 10787 HttpRequestInfo request; | 10781 HttpRequestInfo request; |
| 10788 request.method = "GET"; | 10782 request.method = "GET"; |
| 10789 request.url = GURL("https://www.example.org/"); | 10783 request.url = GURL("https://www.example.org/"); |
| 10790 request.load_flags = 0; | 10784 request.load_flags = 0; |
| 10791 | 10785 |
| 10792 std::string alternative_service_http_header = | |
| 10793 GetAlternativeServiceHttpHeader(); | |
| 10794 | |
| 10795 MockRead data_reads[] = { | 10786 MockRead data_reads[] = { |
| 10796 MockRead("HTTP/1.1 200 OK\r\n"), | 10787 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10797 MockRead(alternative_service_http_header.c_str()), | 10788 MockRead(kAlternativeServiceHttpHeader), |
| 10798 MockRead("\r\n"), | 10789 MockRead("\r\n"), |
| 10799 MockRead("hello world"), | 10790 MockRead("hello world"), |
| 10800 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10791 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10801 MockRead(ASYNC, OK)}; | 10792 MockRead(ASYNC, OK)}; |
| 10802 | 10793 |
| 10803 StaticSocketDataProvider first_transaction( | 10794 StaticSocketDataProvider first_transaction( |
| 10804 data_reads, arraysize(data_reads), NULL, 0); | 10795 data_reads, arraysize(data_reads), NULL, 0); |
| 10805 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10796 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 10806 SSLSocketDataProvider ssl_http11(ASYNC, OK); | 10797 SSLSocketDataProvider ssl_http11(ASYNC, OK); |
| 10807 ssl_http11.SetNextProto(kProtoHTTP11); | 10798 ssl_http11.SetNextProto(kProtoHTTP11); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10868 ASSERT_TRUE(response->headers); | 10859 ASSERT_TRUE(response->headers); |
| 10869 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10860 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10870 EXPECT_TRUE(response->was_fetched_via_spdy); | 10861 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10871 EXPECT_TRUE(response->was_npn_negotiated); | 10862 EXPECT_TRUE(response->was_npn_negotiated); |
| 10872 | 10863 |
| 10873 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); | 10864 ASSERT_THAT(ReadTransaction(trans.get(), &response_data), IsOk()); |
| 10874 EXPECT_EQ("hello!", response_data); | 10865 EXPECT_EQ("hello!", response_data); |
| 10875 } | 10866 } |
| 10876 | 10867 |
| 10877 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { | 10868 TEST_P(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { |
| 10869 // SPDY/3.1 is not supported. |
| 10870 if (GetProtocol() != kProtoHTTP2) { |
| 10871 return; |
| 10872 } |
| 10873 |
| 10878 HttpRequestInfo request; | 10874 HttpRequestInfo request; |
| 10879 request.method = "GET"; | 10875 request.method = "GET"; |
| 10880 request.url = GURL("https://www.example.org/"); | 10876 request.url = GURL("https://www.example.org/"); |
| 10881 request.load_flags = 0; | 10877 request.load_flags = 0; |
| 10882 | 10878 |
| 10883 // First transaction receives Alt-Svc header over HTTP/1.1. | 10879 // First transaction receives Alt-Svc header over HTTP/1.1. |
| 10884 std::string alternative_service_http_header = | |
| 10885 GetAlternativeServiceHttpHeader(); | |
| 10886 | |
| 10887 MockRead data_reads[] = { | 10880 MockRead data_reads[] = { |
| 10888 MockRead("HTTP/1.1 200 OK\r\n"), | 10881 MockRead("HTTP/1.1 200 OK\r\n"), |
| 10889 MockRead(alternative_service_http_header.c_str()), | 10882 MockRead(kAlternativeServiceHttpHeader), |
| 10890 MockRead("\r\n"), | 10883 MockRead("\r\n"), |
| 10891 MockRead("hello world"), | 10884 MockRead("hello world"), |
| 10892 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10885 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10893 MockRead(ASYNC, OK), | 10886 MockRead(ASYNC, OK), |
| 10894 }; | 10887 }; |
| 10895 | 10888 |
| 10896 StaticSocketDataProvider http11_data(data_reads, arraysize(data_reads), NULL, | 10889 StaticSocketDataProvider http11_data(data_reads, arraysize(data_reads), NULL, |
| 10897 0); | 10890 0); |
| 10898 session_deps_.socket_factory->AddSocketDataProvider(&http11_data); | 10891 session_deps_.socket_factory->AddSocketDataProvider(&http11_data); |
| 10899 | 10892 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10995 ASSERT_TRUE(response); | 10988 ASSERT_TRUE(response); |
| 10996 ASSERT_TRUE(response->headers); | 10989 ASSERT_TRUE(response->headers); |
| 10997 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 10990 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
| 10998 EXPECT_TRUE(response->was_fetched_via_spdy); | 10991 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 10999 EXPECT_TRUE(response->was_npn_negotiated); | 10992 EXPECT_TRUE(response->was_npn_negotiated); |
| 11000 ASSERT_THAT(ReadTransaction(&trans3, &response_data), IsOk()); | 10993 ASSERT_THAT(ReadTransaction(&trans3, &response_data), IsOk()); |
| 11001 EXPECT_EQ("hello!", response_data); | 10994 EXPECT_EQ("hello!", response_data); |
| 11002 } | 10995 } |
| 11003 | 10996 |
| 11004 TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { | 10997 TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) { |
| 10998 // SPDY/3.1 is not supported. |
| 10999 if (GetProtocol() != kProtoHTTP2) { |
| 11000 return; |
| 11001 } |
| 11002 |
| 11005 HttpRequestInfo request; | 11003 HttpRequestInfo request; |
| 11006 request.method = "GET"; | 11004 request.method = "GET"; |
| 11007 request.url = GURL("https://www.example.org/"); | 11005 request.url = GURL("https://www.example.org/"); |
| 11008 request.load_flags = 0; | 11006 request.load_flags = 0; |
| 11009 | 11007 |
| 11010 std::string alternative_service_http_header = | |
| 11011 GetAlternativeServiceHttpHeader(); | |
| 11012 | |
| 11013 MockRead data_reads[] = { | 11008 MockRead data_reads[] = { |
| 11014 MockRead("HTTP/1.1 200 OK\r\n"), | 11009 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11015 MockRead(alternative_service_http_header.c_str()), | 11010 MockRead(kAlternativeServiceHttpHeader), |
| 11016 MockRead("\r\n"), | 11011 MockRead("\r\n"), |
| 11017 MockRead("hello world"), | 11012 MockRead("hello world"), |
| 11018 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 11013 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 11019 MockRead(ASYNC, OK), | 11014 MockRead(ASYNC, OK), |
| 11020 }; | 11015 }; |
| 11021 | 11016 |
| 11022 StaticSocketDataProvider first_transaction( | 11017 StaticSocketDataProvider first_transaction( |
| 11023 data_reads, arraysize(data_reads), NULL, 0); | 11018 data_reads, arraysize(data_reads), NULL, 0); |
| 11024 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11019 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11025 | 11020 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11138 new CapturingProxyResolverFactory(&capturing_proxy_resolver)), | 11133 new CapturingProxyResolverFactory(&capturing_proxy_resolver)), |
| 11139 NULL)); | 11134 NULL)); |
| 11140 TestNetLog net_log; | 11135 TestNetLog net_log; |
| 11141 session_deps_.net_log = &net_log; | 11136 session_deps_.net_log = &net_log; |
| 11142 | 11137 |
| 11143 HttpRequestInfo request; | 11138 HttpRequestInfo request; |
| 11144 request.method = "GET"; | 11139 request.method = "GET"; |
| 11145 request.url = GURL("https://www.example.org/"); | 11140 request.url = GURL("https://www.example.org/"); |
| 11146 request.load_flags = 0; | 11141 request.load_flags = 0; |
| 11147 | 11142 |
| 11148 std::string alternative_service_http_header = | |
| 11149 GetAlternativeServiceHttpHeader(); | |
| 11150 | |
| 11151 MockRead data_reads[] = { | 11143 MockRead data_reads[] = { |
| 11152 MockRead("HTTP/1.1 200 OK\r\n"), | 11144 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11153 MockRead(alternative_service_http_header.c_str()), | 11145 MockRead(kAlternativeServiceHttpHeader), |
| 11154 MockRead("\r\n"), | 11146 MockRead("\r\n"), |
| 11155 MockRead("hello world"), | 11147 MockRead("hello world"), |
| 11156 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 11148 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 11157 MockRead(ASYNC, OK), | 11149 MockRead(ASYNC, OK), |
| 11158 }; | 11150 }; |
| 11159 | 11151 |
| 11160 StaticSocketDataProvider first_transaction( | 11152 StaticSocketDataProvider first_transaction( |
| 11161 data_reads, arraysize(data_reads), NULL, 0); | 11153 data_reads, arraysize(data_reads), NULL, 0); |
| 11162 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11154 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11163 SSLSocketDataProvider ssl_http11(ASYNC, OK); | 11155 SSLSocketDataProvider ssl_http11(ASYNC, OK); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11252 CONNECT_TIMING_HAS_SSL_TIMES); | 11244 CONNECT_TIMING_HAS_SSL_TIMES); |
| 11253 } | 11245 } |
| 11254 | 11246 |
| 11255 TEST_P(HttpNetworkTransactionTest, | 11247 TEST_P(HttpNetworkTransactionTest, |
| 11256 UseAlternativeServiceForNpnSpdyWithExistingSpdySession) { | 11248 UseAlternativeServiceForNpnSpdyWithExistingSpdySession) { |
| 11257 HttpRequestInfo request; | 11249 HttpRequestInfo request; |
| 11258 request.method = "GET"; | 11250 request.method = "GET"; |
| 11259 request.url = GURL("https://www.example.org/"); | 11251 request.url = GURL("https://www.example.org/"); |
| 11260 request.load_flags = 0; | 11252 request.load_flags = 0; |
| 11261 | 11253 |
| 11262 std::string alternative_service_http_header = | |
| 11263 GetAlternativeServiceHttpHeader(); | |
| 11264 | |
| 11265 MockRead data_reads[] = { | 11254 MockRead data_reads[] = { |
| 11266 MockRead("HTTP/1.1 200 OK\r\n"), | 11255 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11267 MockRead(alternative_service_http_header.c_str()), | 11256 MockRead(kAlternativeServiceHttpHeader), |
| 11268 MockRead("\r\n"), | 11257 MockRead("\r\n"), |
| 11269 MockRead("hello world"), | 11258 MockRead("hello world"), |
| 11270 MockRead(ASYNC, OK), | 11259 MockRead(ASYNC, OK), |
| 11271 }; | 11260 }; |
| 11272 | 11261 |
| 11273 StaticSocketDataProvider first_transaction( | 11262 StaticSocketDataProvider first_transaction( |
| 11274 data_reads, arraysize(data_reads), NULL, 0); | 11263 data_reads, arraysize(data_reads), NULL, 0); |
| 11275 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11264 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11276 SSLSocketDataProvider ssl_http11(ASYNC, OK); | 11265 SSLSocketDataProvider ssl_http11(ASYNC, OK); |
| 11277 ssl_http11.SetNextProto(kProtoHTTP11); | 11266 ssl_http11.SetNextProto(kProtoHTTP11); |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11963 request.url = GURL("https://www.example.org/"); | 11952 request.url = GURL("https://www.example.org/"); |
| 11964 request.load_flags = 0; | 11953 request.load_flags = 0; |
| 11965 | 11954 |
| 11966 MockWrite data_writes[] = { | 11955 MockWrite data_writes[] = { |
| 11967 MockWrite( | 11956 MockWrite( |
| 11968 "GET / HTTP/1.1\r\n" | 11957 "GET / HTTP/1.1\r\n" |
| 11969 "Host: www.example.org\r\n" | 11958 "Host: www.example.org\r\n" |
| 11970 "Connection: keep-alive\r\n\r\n"), | 11959 "Connection: keep-alive\r\n\r\n"), |
| 11971 }; | 11960 }; |
| 11972 | 11961 |
| 11973 std::string alternative_service_http_header = | |
| 11974 GetAlternativeServiceHttpHeader(); | |
| 11975 | |
| 11976 MockRead data_reads[] = { | 11962 MockRead data_reads[] = { |
| 11977 MockRead("HTTP/1.1 200 OK\r\n"), | 11963 MockRead("HTTP/1.1 200 OK\r\n"), |
| 11978 MockRead(alternative_service_http_header.c_str()), | 11964 MockRead(kAlternativeServiceHttpHeader), |
| 11979 MockRead("\r\n"), | 11965 MockRead("\r\n"), |
| 11980 MockRead("hello world"), | 11966 MockRead("hello world"), |
| 11981 MockRead(SYNCHRONOUS, OK), | 11967 MockRead(SYNCHRONOUS, OK), |
| 11982 }; | 11968 }; |
| 11983 | 11969 |
| 11984 SSLSocketDataProvider ssl(ASYNC, OK); | 11970 SSLSocketDataProvider ssl(ASYNC, OK); |
| 11985 ssl.SetNextProto(kProtoHTTP11); | 11971 ssl.SetNextProto(kProtoHTTP11); |
| 11986 | 11972 |
| 11987 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 11973 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 11988 | 11974 |
| (...skipping 3908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15897 base::RunLoop().RunUntilIdle(); | 15883 base::RunLoop().RunUntilIdle(); |
| 15898 | 15884 |
| 15899 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15885 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15900 HttpRequestHeaders headers; | 15886 HttpRequestHeaders headers; |
| 15901 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15887 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15902 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15888 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15903 } | 15889 } |
| 15904 #endif // !defined(OS_IOS) | 15890 #endif // !defined(OS_IOS) |
| 15905 | 15891 |
| 15906 } // namespace net | 15892 } // namespace net |
| OLD | NEW |