| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 // Important to restore the per-pool limit first, since the pool limit must | 264 // Important to restore the per-pool limit first, since the pool limit must |
| 265 // always be greater than group limit, and the tests reduce both limits. | 265 // always be greater than group limit, and the tests reduce both limits. |
| 266 ClientSocketPoolManager::set_max_sockets_per_pool( | 266 ClientSocketPoolManager::set_max_sockets_per_pool( |
| 267 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_); | 267 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_); |
| 268 ClientSocketPoolManager::set_max_sockets_per_group( | 268 ClientSocketPoolManager::set_max_sockets_per_group( |
| 269 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_group_sockets_); | 269 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_group_sockets_); |
| 270 } | 270 } |
| 271 | 271 |
| 272 protected: | 272 protected: |
| 273 HttpNetworkTransactionTest() | 273 HttpNetworkTransactionTest() |
| 274 : old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group( | 274 : ssl_(ASYNC, OK), |
| 275 old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group( |
| 275 HttpNetworkSession::NORMAL_SOCKET_POOL)), | 276 HttpNetworkSession::NORMAL_SOCKET_POOL)), |
| 276 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool( | 277 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool( |
| 277 HttpNetworkSession::NORMAL_SOCKET_POOL)) { | 278 HttpNetworkSession::NORMAL_SOCKET_POOL)) { |
| 278 session_deps_.enable_http2_alternative_service_with_different_host = true; | 279 session_deps_.enable_http2_alternative_service_with_different_host = true; |
| 279 } | 280 } |
| 280 | 281 |
| 281 struct SimpleGetHelperResult { | 282 struct SimpleGetHelperResult { |
| 282 int rv; | 283 int rv; |
| 283 std::string status_line; | 284 std::string status_line; |
| 284 std::string response_data; | 285 std::string response_data; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 StaticSocketDataProvider reads(data_reads, reads_count, data_writes, | 421 StaticSocketDataProvider reads(data_reads, reads_count, data_writes, |
| 421 arraysize(data_writes)); | 422 arraysize(data_writes)); |
| 422 StaticSocketDataProvider* data[] = {&reads}; | 423 StaticSocketDataProvider* data[] = {&reads}; |
| 423 SimpleGetHelperResult out = SimpleGetHelperForData(data, 1); | 424 SimpleGetHelperResult out = SimpleGetHelperForData(data, 1); |
| 424 | 425 |
| 425 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), | 426 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), |
| 426 out.total_sent_bytes); | 427 out.total_sent_bytes); |
| 427 return out; | 428 return out; |
| 428 } | 429 } |
| 429 | 430 |
| 431 void AddSSLSocketData() { |
| 432 ssl_.next_proto = kProtoHTTP2; |
| 433 ssl_.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 434 ASSERT_TRUE(ssl_.cert); |
| 435 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_); |
| 436 } |
| 437 |
| 430 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, | 438 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, |
| 431 int expected_status); | 439 int expected_status); |
| 432 | 440 |
| 433 void ConnectStatusHelper(const MockRead& status); | 441 void ConnectStatusHelper(const MockRead& status); |
| 434 | 442 |
| 435 void BypassHostCacheOnRefreshHelper(int load_flags); | 443 void BypassHostCacheOnRefreshHelper(int load_flags); |
| 436 | 444 |
| 437 void CheckErrorIsPassedBack(int error, IoMode mode); | 445 void CheckErrorIsPassedBack(int error, IoMode mode); |
| 438 | 446 |
| 439 SpdyTestUtil spdy_util_; | 447 SpdyTestUtil spdy_util_; |
| 440 SpdySessionDependencies session_deps_; | 448 SpdySessionDependencies session_deps_; |
| 449 SSLSocketDataProvider ssl_; |
| 441 | 450 |
| 442 // Original socket limits. Some tests set these. Safest to always restore | 451 // Original socket limits. Some tests set these. Safest to always restore |
| 443 // them once each test has been run. | 452 // them once each test has been run. |
| 444 int old_max_group_sockets_; | 453 int old_max_group_sockets_; |
| 445 int old_max_pool_sockets_; | 454 int old_max_pool_sockets_; |
| 446 }; | 455 }; |
| 447 | 456 |
| 448 namespace { | 457 namespace { |
| 449 | 458 |
| 450 class BeforeHeadersSentHandler { | 459 class BeforeHeadersSentHandler { |
| (...skipping 10209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10660 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10669 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10661 MockRead(ASYNC, OK)}; | 10670 MockRead(ASYNC, OK)}; |
| 10662 | 10671 |
| 10663 StaticSocketDataProvider first_transaction( | 10672 StaticSocketDataProvider first_transaction( |
| 10664 data_reads, arraysize(data_reads), NULL, 0); | 10673 data_reads, arraysize(data_reads), NULL, 0); |
| 10665 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 10674 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 10666 SSLSocketDataProvider ssl_http11(ASYNC, OK); | 10675 SSLSocketDataProvider ssl_http11(ASYNC, OK); |
| 10667 ssl_http11.next_proto = kProtoHTTP11; | 10676 ssl_http11.next_proto = kProtoHTTP11; |
| 10668 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | 10677 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); |
| 10669 | 10678 |
| 10670 SSLSocketDataProvider ssl_http2(ASYNC, OK); | 10679 AddSSLSocketData(); |
| 10671 ssl_http2.next_proto = kProtoHTTP2; | |
| 10672 ssl_http2.cert = | |
| 10673 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 10674 ASSERT_TRUE(ssl_http2.cert.get()); | |
| 10675 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 10676 | 10680 |
| 10677 SpdySerializedFrame req( | 10681 SpdySerializedFrame req( |
| 10678 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); | 10682 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 10679 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; | 10683 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; |
| 10680 | 10684 |
| 10681 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 10685 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 10682 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true)); | 10686 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 10683 MockRead spdy_reads[] = { | 10687 MockRead spdy_reads[] = { |
| 10684 CreateMockRead(resp, 1), CreateMockRead(data, 2), MockRead(ASYNC, 0, 3), | 10688 CreateMockRead(resp, 1), CreateMockRead(data, 2), MockRead(ASYNC, 0, 3), |
| 10685 }; | 10689 }; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10783 MockRead spdy_reads[] = { | 10787 MockRead spdy_reads[] = { |
| 10784 CreateMockRead(resp1, 2), CreateMockRead(data1, 3), | 10788 CreateMockRead(resp1, 2), CreateMockRead(data1, 3), |
| 10785 CreateMockRead(resp2, 4), CreateMockRead(data2, 5), | 10789 CreateMockRead(resp2, 4), CreateMockRead(data2, 5), |
| 10786 MockRead(ASYNC, 0, 6), | 10790 MockRead(ASYNC, 0, 6), |
| 10787 }; | 10791 }; |
| 10788 | 10792 |
| 10789 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, | 10793 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes, |
| 10790 arraysize(spdy_writes)); | 10794 arraysize(spdy_writes)); |
| 10791 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); | 10795 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data); |
| 10792 | 10796 |
| 10793 SSLSocketDataProvider ssl_http2(ASYNC, OK); | 10797 AddSSLSocketData(); |
| 10794 ssl_http2.next_proto = kProtoHTTP2; | |
| 10795 ssl_http2.cert = | |
| 10796 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 10797 ASSERT_TRUE(ssl_http2.cert); | |
| 10798 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 10799 | 10798 |
| 10800 StaticSocketDataProvider hanging_socket3(NULL, 0, NULL, 0); | 10799 StaticSocketDataProvider hanging_socket3(NULL, 0, NULL, 0); |
| 10801 hanging_socket3.set_connect_data(never_finishing_connect); | 10800 hanging_socket3.set_connect_data(never_finishing_connect); |
| 10802 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket3); | 10801 session_deps_.socket_factory->AddSocketDataProvider(&hanging_socket3); |
| 10803 | 10802 |
| 10804 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10803 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 10805 TestCompletionCallback callback1; | 10804 TestCompletionCallback callback1; |
| 10806 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 10805 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 10807 | 10806 |
| 10808 int rv = trans1.Start(&request, callback1.callback(), NetLogWithSource()); | 10807 int rv = trans1.Start(&request, callback1.callback(), NetLogWithSource()); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11008 expiration); | 11007 expiration); |
| 11009 | 11008 |
| 11010 // Non-alternative job should hang. | 11009 // Non-alternative job should hang. |
| 11011 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 11010 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 11012 StaticSocketDataProvider hanging_alternate_protocol_socket(nullptr, 0, | 11011 StaticSocketDataProvider hanging_alternate_protocol_socket(nullptr, 0, |
| 11013 nullptr, 0); | 11012 nullptr, 0); |
| 11014 hanging_alternate_protocol_socket.set_connect_data(never_finishing_connect); | 11013 hanging_alternate_protocol_socket.set_connect_data(never_finishing_connect); |
| 11015 session_deps_.socket_factory->AddSocketDataProvider( | 11014 session_deps_.socket_factory->AddSocketDataProvider( |
| 11016 &hanging_alternate_protocol_socket); | 11015 &hanging_alternate_protocol_socket); |
| 11017 | 11016 |
| 11018 SSLSocketDataProvider ssl_http2(ASYNC, OK); | 11017 AddSSLSocketData(); |
| 11019 ssl_http2.next_proto = kProtoHTTP2; | |
| 11020 ssl_http2.cert = | |
| 11021 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 11022 ASSERT_TRUE(ssl_http2.cert); | |
| 11023 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 11024 | 11018 |
| 11025 HttpRequestInfo request; | 11019 HttpRequestInfo request; |
| 11026 request.method = "GET"; | 11020 request.method = "GET"; |
| 11027 request.url = GURL("https://www.example.org/"); | 11021 request.url = GURL("https://www.example.org/"); |
| 11028 request.load_flags = 0; | 11022 request.load_flags = 0; |
| 11029 | 11023 |
| 11030 SpdySerializedFrame req( | 11024 SpdySerializedFrame req( |
| 11031 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); | 11025 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 11032 | 11026 |
| 11033 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; | 11027 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11092 MockRead(ASYNC, OK), | 11086 MockRead(ASYNC, OK), |
| 11093 }; | 11087 }; |
| 11094 | 11088 |
| 11095 StaticSocketDataProvider first_transaction( | 11089 StaticSocketDataProvider first_transaction( |
| 11096 data_reads, arraysize(data_reads), NULL, 0); | 11090 data_reads, arraysize(data_reads), NULL, 0); |
| 11097 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11091 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11098 SSLSocketDataProvider ssl_http11(ASYNC, OK); | 11092 SSLSocketDataProvider ssl_http11(ASYNC, OK); |
| 11099 ssl_http11.next_proto = kProtoHTTP11; | 11093 ssl_http11.next_proto = kProtoHTTP11; |
| 11100 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | 11094 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); |
| 11101 | 11095 |
| 11102 SSLSocketDataProvider ssl_http2(ASYNC, OK); | 11096 AddSSLSocketData(); |
| 11103 ssl_http2.next_proto = kProtoHTTP2; | |
| 11104 ssl_http2.cert = | |
| 11105 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 11106 ASSERT_TRUE(ssl_http2.cert); | |
| 11107 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 11108 | 11097 |
| 11109 SpdySerializedFrame req( | 11098 SpdySerializedFrame req( |
| 11110 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); | 11099 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 11111 MockWrite spdy_writes[] = { | 11100 MockWrite spdy_writes[] = { |
| 11112 MockWrite(ASYNC, 0, | 11101 MockWrite(ASYNC, 0, |
| 11113 "CONNECT www.example.org:443 HTTP/1.1\r\n" | 11102 "CONNECT www.example.org:443 HTTP/1.1\r\n" |
| 11114 "Host: www.example.org:443\r\n" | 11103 "Host: www.example.org:443\r\n" |
| 11115 "Proxy-Connection: keep-alive\r\n\r\n"), | 11104 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 11116 CreateMockWrite(req, 2), | 11105 CreateMockWrite(req, 2), |
| 11117 }; | 11106 }; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11200 MockRead(ASYNC, OK), | 11189 MockRead(ASYNC, OK), |
| 11201 }; | 11190 }; |
| 11202 | 11191 |
| 11203 StaticSocketDataProvider first_transaction( | 11192 StaticSocketDataProvider first_transaction( |
| 11204 data_reads, arraysize(data_reads), NULL, 0); | 11193 data_reads, arraysize(data_reads), NULL, 0); |
| 11205 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); | 11194 session_deps_.socket_factory->AddSocketDataProvider(&first_transaction); |
| 11206 SSLSocketDataProvider ssl_http11(ASYNC, OK); | 11195 SSLSocketDataProvider ssl_http11(ASYNC, OK); |
| 11207 ssl_http11.next_proto = kProtoHTTP11; | 11196 ssl_http11.next_proto = kProtoHTTP11; |
| 11208 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); | 11197 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http11); |
| 11209 | 11198 |
| 11210 SSLSocketDataProvider ssl_http2(ASYNC, OK); | 11199 AddSSLSocketData(); |
| 11211 ssl_http2.next_proto = kProtoHTTP2; | |
| 11212 ssl_http2.cert = | |
| 11213 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 11214 ASSERT_TRUE(ssl_http2.cert); | |
| 11215 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_http2); | |
| 11216 | 11200 |
| 11217 SpdySerializedFrame req( | 11201 SpdySerializedFrame req( |
| 11218 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); | 11202 spdy_util_.ConstructSpdyGet("https://www.example.org/", 1, LOWEST)); |
| 11219 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; | 11203 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; |
| 11220 | 11204 |
| 11221 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 11205 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 11222 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true)); | 11206 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 11223 MockRead spdy_reads[] = { | 11207 MockRead spdy_reads[] = { |
| 11224 CreateMockRead(resp, 1), CreateMockRead(data, 2), MockRead(ASYNC, 0, 3), | 11208 CreateMockRead(resp, 1), CreateMockRead(data, 2), MockRead(ASYNC, 0, 3), |
| 11225 }; | 11209 }; |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12380 ssl.next_proto = kProtoHTTP2; | 12364 ssl.next_proto = kProtoHTTP2; |
| 12381 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | 12365 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 12382 | 12366 |
| 12383 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12367 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12384 | 12368 |
| 12385 // Set up an initial SpdySession in the pool to reuse. | 12369 // Set up an initial SpdySession in the pool to reuse. |
| 12386 HostPortPair host_port_pair("www.example.org", 443); | 12370 HostPortPair host_port_pair("www.example.org", 443); |
| 12387 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 12371 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 12388 PRIVACY_MODE_DISABLED); | 12372 PRIVACY_MODE_DISABLED); |
| 12389 base::WeakPtr<SpdySession> spdy_session = | 12373 base::WeakPtr<SpdySession> spdy_session = |
| 12390 CreateInsecureSpdySession(session.get(), key, NetLogWithSource()); | 12374 CreateSecureSpdySession(session.get(), key, NetLogWithSource()); |
| 12391 | 12375 |
| 12392 HttpRequestInfo request; | 12376 HttpRequestInfo request; |
| 12393 request.method = "GET"; | 12377 request.method = "GET"; |
| 12394 request.url = GURL("https://www.example.org/"); | 12378 request.url = GURL("https://www.example.org/"); |
| 12395 request.load_flags = 0; | 12379 request.load_flags = 0; |
| 12396 | 12380 |
| 12397 // This is the important line that marks this as a preconnect. | 12381 // This is the important line that marks this as a preconnect. |
| 12398 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; | 12382 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; |
| 12399 | 12383 |
| 12400 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 12384 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12762 HostPortPair("www.example.com", 443), &client_cert, | 12746 HostPortPair("www.example.com", 443), &client_cert, |
| 12763 &client_private_key)); | 12747 &client_private_key)); |
| 12764 } | 12748 } |
| 12765 } | 12749 } |
| 12766 | 12750 |
| 12767 TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) { | 12751 TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) { |
| 12768 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 12752 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
| 12769 session_deps_.host_resolver.reset(new MockCachingHostResolver()); | 12753 session_deps_.host_resolver.reset(new MockCachingHostResolver()); |
| 12770 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12754 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12771 | 12755 |
| 12772 SSLSocketDataProvider ssl(ASYNC, OK); | 12756 AddSSLSocketData(); |
| 12773 ssl.next_proto = kProtoHTTP2; | |
| 12774 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 12775 ASSERT_TRUE(ssl.cert); | |
| 12776 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 12777 | 12757 |
| 12778 SpdySerializedFrame host1_req( | 12758 SpdySerializedFrame host1_req( |
| 12779 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); | 12759 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); |
| 12780 spdy_util_.UpdateWithStreamDestruction(1); | 12760 spdy_util_.UpdateWithStreamDestruction(1); |
| 12781 SpdySerializedFrame host2_req( | 12761 SpdySerializedFrame host2_req( |
| 12782 spdy_util_.ConstructSpdyGet("https://mail.example.com", 3, LOWEST)); | 12762 spdy_util_.ConstructSpdyGet("https://mail.example.com", 3, LOWEST)); |
| 12783 MockWrite spdy_writes[] = { | 12763 MockWrite spdy_writes[] = { |
| 12784 CreateMockWrite(host1_req, 0), CreateMockWrite(host2_req, 3), | 12764 CreateMockWrite(host1_req, 0), CreateMockWrite(host2_req, 3), |
| 12785 }; | 12765 }; |
| 12786 SpdySerializedFrame host1_resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 12766 SpdySerializedFrame host1_resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12851 EXPECT_TRUE(response->was_alpn_negotiated); | 12831 EXPECT_TRUE(response->was_alpn_negotiated); |
| 12852 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); | 12832 ASSERT_THAT(ReadTransaction(&trans2, &response_data), IsOk()); |
| 12853 EXPECT_EQ("hello!", response_data); | 12833 EXPECT_EQ("hello!", response_data); |
| 12854 } | 12834 } |
| 12855 | 12835 |
| 12856 TEST_F(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { | 12836 TEST_F(HttpNetworkTransactionTest, UseIPConnectionPoolingAfterResolution) { |
| 12857 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 12837 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
| 12858 session_deps_.host_resolver.reset(new MockCachingHostResolver()); | 12838 session_deps_.host_resolver.reset(new MockCachingHostResolver()); |
| 12859 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12839 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12860 | 12840 |
| 12861 SSLSocketDataProvider ssl(ASYNC, OK); | 12841 AddSSLSocketData(); |
| 12862 ssl.next_proto = kProtoHTTP2; | |
| 12863 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 12864 ASSERT_TRUE(ssl.cert); | |
| 12865 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 12866 | 12842 |
| 12867 SpdySerializedFrame host1_req( | 12843 SpdySerializedFrame host1_req( |
| 12868 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); | 12844 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); |
| 12869 spdy_util_.UpdateWithStreamDestruction(1); | 12845 spdy_util_.UpdateWithStreamDestruction(1); |
| 12870 SpdySerializedFrame host2_req( | 12846 SpdySerializedFrame host2_req( |
| 12871 spdy_util_.ConstructSpdyGet("https://mail.example.com", 3, LOWEST)); | 12847 spdy_util_.ConstructSpdyGet("https://mail.example.com", 3, LOWEST)); |
| 12872 MockWrite spdy_writes[] = { | 12848 MockWrite spdy_writes[] = { |
| 12873 CreateMockWrite(host1_req, 0), CreateMockWrite(host2_req, 3), | 12849 CreateMockWrite(host1_req, 0), CreateMockWrite(host2_req, 3), |
| 12874 }; | 12850 }; |
| 12875 SpdySerializedFrame host1_resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 12851 SpdySerializedFrame host1_resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12970 TEST_F(HttpNetworkTransactionTest, | 12946 TEST_F(HttpNetworkTransactionTest, |
| 12971 UseIPConnectionPoolingWithHostCacheExpiration) { | 12947 UseIPConnectionPoolingWithHostCacheExpiration) { |
| 12972 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. | 12948 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. |
| 12973 OneTimeCachingHostResolver host_resolver( | 12949 OneTimeCachingHostResolver host_resolver( |
| 12974 HostPortPair("mail.example.com", 443)); | 12950 HostPortPair("mail.example.com", 443)); |
| 12975 HttpNetworkSession::Params params = | 12951 HttpNetworkSession::Params params = |
| 12976 SpdySessionDependencies::CreateSessionParams(&session_deps_); | 12952 SpdySessionDependencies::CreateSessionParams(&session_deps_); |
| 12977 params.host_resolver = &host_resolver; | 12953 params.host_resolver = &host_resolver; |
| 12978 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12954 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12979 | 12955 |
| 12980 SSLSocketDataProvider ssl(ASYNC, OK); | 12956 AddSSLSocketData(); |
| 12981 ssl.next_proto = kProtoHTTP2; | |
| 12982 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | |
| 12983 ASSERT_TRUE(ssl.cert); | |
| 12984 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); | |
| 12985 | 12957 |
| 12986 SpdySerializedFrame host1_req( | 12958 SpdySerializedFrame host1_req( |
| 12987 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); | 12959 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); |
| 12988 spdy_util_.UpdateWithStreamDestruction(1); | 12960 spdy_util_.UpdateWithStreamDestruction(1); |
| 12989 SpdySerializedFrame host2_req( | 12961 SpdySerializedFrame host2_req( |
| 12990 spdy_util_.ConstructSpdyGet("https://mail.example.com", 3, LOWEST)); | 12962 spdy_util_.ConstructSpdyGet("https://mail.example.com", 3, LOWEST)); |
| 12991 MockWrite spdy_writes[] = { | 12963 MockWrite spdy_writes[] = { |
| 12992 CreateMockWrite(host1_req, 0), CreateMockWrite(host2_req, 3), | 12964 CreateMockWrite(host1_req, 0), CreateMockWrite(host2_req, 3), |
| 12993 }; | 12965 }; |
| 12994 SpdySerializedFrame host1_resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 12966 SpdySerializedFrame host1_resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| (...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15579 base::RunLoop().RunUntilIdle(); | 15551 base::RunLoop().RunUntilIdle(); |
| 15580 | 15552 |
| 15581 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15553 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15582 HttpRequestHeaders headers; | 15554 HttpRequestHeaders headers; |
| 15583 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15555 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15584 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15556 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15585 } | 15557 } |
| 15586 #endif // !defined(OS_IOS) | 15558 #endif // !defined(OS_IOS) |
| 15587 | 15559 |
| 15588 } // namespace net | 15560 } // namespace net |
| OLD | NEW |