OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 5 #include <cmath> |
6 #include <memory> | 6 #include <memory> |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 void VerifyStreamsClosed(const NormalSpdyTransactionHelper& helper) { | 430 void VerifyStreamsClosed(const NormalSpdyTransactionHelper& helper) { |
431 // This lengthy block is reaching into the pool to dig out the active | 431 // This lengthy block is reaching into the pool to dig out the active |
432 // session. Once we have the session, we verify that the streams are | 432 // session. Once we have the session, we verify that the streams are |
433 // all closed and not leaked at this point. | 433 // all closed and not leaked at this point. |
434 const GURL& url = helper.request().url; | 434 const GURL& url = helper.request().url; |
435 SpdySessionKey key(HostPortPair::FromURL(url), ProxyServer::Direct(), | 435 SpdySessionKey key(HostPortPair::FromURL(url), ProxyServer::Direct(), |
436 PRIVACY_MODE_DISABLED); | 436 PRIVACY_MODE_DISABLED); |
437 NetLogWithSource log; | 437 NetLogWithSource log; |
438 HttpNetworkSession* session = helper.session(); | 438 HttpNetworkSession* session = helper.session(); |
439 base::WeakPtr<SpdySession> spdy_session = | 439 base::WeakPtr<SpdySession> spdy_session = |
440 session->spdy_session_pool()->FindAvailableSession(key, url, log); | 440 session->spdy_session_pool()->FindAvailableSession( |
| 441 key, url, |
| 442 /* enable_ip_based_pooling = */ true, log); |
441 ASSERT_TRUE(spdy_session); | 443 ASSERT_TRUE(spdy_session); |
442 EXPECT_EQ(0u, spdy_session->num_active_streams()); | 444 EXPECT_EQ(0u, spdy_session->num_active_streams()); |
443 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams()); | 445 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams()); |
444 } | 446 } |
445 | 447 |
446 void RunServerPushTest(SequencedSocketData* data, | 448 void RunServerPushTest(SequencedSocketData* data, |
447 HttpResponseInfo* response, | 449 HttpResponseInfo* response, |
448 HttpResponseInfo* push_response, | 450 HttpResponseInfo* push_response, |
449 const std::string& expected) { | 451 const std::string& expected) { |
450 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 452 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
(...skipping 3599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4050 EXPECT_THAT(out.rv, IsOk()); | 4052 EXPECT_THAT(out.rv, IsOk()); |
4051 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4053 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
4052 EXPECT_EQ("hello!", out.response_data); | 4054 EXPECT_EQ("hello!", out.response_data); |
4053 | 4055 |
4054 // GOAWAY frame has not yet been received, SpdySession should be available. | 4056 // GOAWAY frame has not yet been received, SpdySession should be available. |
4055 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4057 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
4056 SpdySessionKey key(host_port_pair_, ProxyServer::Direct(), | 4058 SpdySessionKey key(host_port_pair_, ProxyServer::Direct(), |
4057 PRIVACY_MODE_DISABLED); | 4059 PRIVACY_MODE_DISABLED); |
4058 NetLogWithSource log; | 4060 NetLogWithSource log; |
4059 base::WeakPtr<SpdySession> spdy_session = | 4061 base::WeakPtr<SpdySession> spdy_session = |
4060 spdy_session_pool->FindAvailableSession(key, GURL(), log); | 4062 spdy_session_pool->FindAvailableSession( |
| 4063 key, GURL(), |
| 4064 /* enable_ip_based_pooling = */ true, log); |
4061 EXPECT_TRUE(spdy_session); | 4065 EXPECT_TRUE(spdy_session); |
4062 | 4066 |
4063 // Start second transaction. | 4067 // Start second transaction. |
4064 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 4068 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
4065 TestCompletionCallback callback; | 4069 TestCompletionCallback callback; |
4066 HttpRequestInfo request2; | 4070 HttpRequestInfo request2; |
4067 request2.method = "GET"; | 4071 request2.method = "GET"; |
4068 request2.url = GURL("https://www.example.org/foo"); | 4072 request2.url = GURL("https://www.example.org/foo"); |
4069 int rv = trans2.Start(&request2, callback.callback(), log); | 4073 int rv = trans2.Start(&request2, callback.callback(), log); |
4070 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4074 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4071 rv = callback.WaitForResult(); | 4075 rv = callback.WaitForResult(); |
4072 EXPECT_THAT(rv, IsOk()); | 4076 EXPECT_THAT(rv, IsOk()); |
4073 | 4077 |
4074 // Verify second response. | 4078 // Verify second response. |
4075 const HttpResponseInfo* response = trans2.GetResponseInfo(); | 4079 const HttpResponseInfo* response = trans2.GetResponseInfo(); |
4076 ASSERT_TRUE(response); | 4080 ASSERT_TRUE(response); |
4077 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP2, response->connection_info); | 4081 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP2, response->connection_info); |
4078 ASSERT_TRUE(response->headers); | 4082 ASSERT_TRUE(response->headers); |
4079 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 4083 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
4080 EXPECT_TRUE(response->was_fetched_via_spdy); | 4084 EXPECT_TRUE(response->was_fetched_via_spdy); |
4081 EXPECT_TRUE(response->was_alpn_negotiated); | 4085 EXPECT_TRUE(response->was_alpn_negotiated); |
4082 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 4086 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
4083 EXPECT_EQ(443, response->socket_address.port()); | 4087 EXPECT_EQ(443, response->socket_address.port()); |
4084 std::string response_data; | 4088 std::string response_data; |
4085 rv = ReadTransaction(&trans2, &response_data); | 4089 rv = ReadTransaction(&trans2, &response_data); |
4086 EXPECT_THAT(rv, IsOk()); | 4090 EXPECT_THAT(rv, IsOk()); |
4087 EXPECT_EQ("hello!", response_data); | 4091 EXPECT_EQ("hello!", response_data); |
4088 | 4092 |
4089 // Graceful GOAWAY was received, SpdySession should be unavailable. | 4093 // Graceful GOAWAY was received, SpdySession should be unavailable. |
4090 spdy_session = spdy_session_pool->FindAvailableSession(key, GURL(), log); | 4094 spdy_session = spdy_session_pool->FindAvailableSession( |
| 4095 key, GURL(), |
| 4096 /* enable_ip_based_pooling = */ true, log); |
4091 EXPECT_FALSE(spdy_session); | 4097 EXPECT_FALSE(spdy_session); |
4092 | 4098 |
4093 helper.VerifyDataConsumed(); | 4099 helper.VerifyDataConsumed(); |
4094 } | 4100 } |
4095 | 4101 |
4096 TEST_F(SpdyNetworkTransactionTest, CloseWithActiveStream) { | 4102 TEST_F(SpdyNetworkTransactionTest, CloseWithActiveStream) { |
4097 SpdySerializedFrame req( | 4103 SpdySerializedFrame req( |
4098 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4104 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
4099 MockWrite writes[] = {CreateMockWrite(req, 0)}; | 4105 MockWrite writes[] = {CreateMockWrite(req, 0)}; |
4100 | 4106 |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5028 HttpNetworkTransaction* trans0 = helper.trans(); | 5034 HttpNetworkTransaction* trans0 = helper.trans(); |
5029 TestCompletionCallback callback0; | 5035 TestCompletionCallback callback0; |
5030 int rv = trans0->Start(&request, callback0.callback(), log); | 5036 int rv = trans0->Start(&request, callback0.callback(), log); |
5031 rv = callback0.GetResult(rv); | 5037 rv = callback0.GetResult(rv); |
5032 EXPECT_THAT(rv, IsOk()); | 5038 EXPECT_THAT(rv, IsOk()); |
5033 | 5039 |
5034 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 5040 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
5035 SpdySessionKey key(host_port_pair_, ProxyServer::Direct(), | 5041 SpdySessionKey key(host_port_pair_, ProxyServer::Direct(), |
5036 PRIVACY_MODE_DISABLED); | 5042 PRIVACY_MODE_DISABLED); |
5037 base::WeakPtr<SpdySession> spdy_session = | 5043 base::WeakPtr<SpdySession> spdy_session = |
5038 spdy_session_pool->FindAvailableSession(key, GURL(), log); | 5044 spdy_session_pool->FindAvailableSession( |
| 5045 key, GURL(), |
| 5046 /* enable_ip_based_pooling = */ true, log); |
5039 | 5047 |
5040 EXPECT_FALSE(spdy_session->unclaimed_pushed_streams_.empty()); | 5048 EXPECT_FALSE(spdy_session->unclaimed_pushed_streams_.empty()); |
5041 EXPECT_EQ(1u, spdy_session->unclaimed_pushed_streams_.size()); | 5049 EXPECT_EQ(1u, spdy_session->unclaimed_pushed_streams_.size()); |
5042 EXPECT_EQ(1u, | 5050 EXPECT_EQ(1u, |
5043 spdy_session->unclaimed_pushed_streams_.count(GURL(url_to_push))); | 5051 spdy_session->unclaimed_pushed_streams_.count(GURL(url_to_push))); |
5044 | 5052 |
5045 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 5053 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
5046 HttpRequestInfo push_request; | 5054 HttpRequestInfo push_request; |
5047 push_request.method = "GET"; | 5055 push_request.method = "GET"; |
5048 push_request.url = GURL(url_to_push); | 5056 push_request.url = GURL(url_to_push); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5175 TestCompletionCallback callback1; | 5183 TestCompletionCallback callback1; |
5176 rv = trans1.Start(&request1, callback1.callback(), log); | 5184 rv = trans1.Start(&request1, callback1.callback(), log); |
5177 rv = callback1.GetResult(rv); | 5185 rv = callback1.GetResult(rv); |
5178 EXPECT_THAT(rv, IsOk()); | 5186 EXPECT_THAT(rv, IsOk()); |
5179 | 5187 |
5180 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 5188 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
5181 HostPortPair host_port_pair0("mail.example.org", 443); | 5189 HostPortPair host_port_pair0("mail.example.org", 443); |
5182 SpdySessionKey key0(host_port_pair0, ProxyServer::Direct(), | 5190 SpdySessionKey key0(host_port_pair0, ProxyServer::Direct(), |
5183 PRIVACY_MODE_DISABLED); | 5191 PRIVACY_MODE_DISABLED); |
5184 base::WeakPtr<SpdySession> spdy_session0 = | 5192 base::WeakPtr<SpdySession> spdy_session0 = |
5185 spdy_session_pool->FindAvailableSession(key0, GURL(), log); | 5193 spdy_session_pool->FindAvailableSession( |
| 5194 key0, GURL(), |
| 5195 /* enable_ip_based_pooling = */ true, log); |
5186 | 5196 |
5187 EXPECT_TRUE(spdy_session0->unclaimed_pushed_streams_.empty()); | 5197 EXPECT_TRUE(spdy_session0->unclaimed_pushed_streams_.empty()); |
5188 EXPECT_EQ(0u, spdy_session0->unclaimed_pushed_streams_.size()); | 5198 EXPECT_EQ(0u, spdy_session0->unclaimed_pushed_streams_.size()); |
5189 | 5199 |
5190 HostPortPair host_port_pair1("docs.example.org", 443); | 5200 HostPortPair host_port_pair1("docs.example.org", 443); |
5191 SpdySessionKey key1(host_port_pair1, ProxyServer::Direct(), | 5201 SpdySessionKey key1(host_port_pair1, ProxyServer::Direct(), |
5192 PRIVACY_MODE_DISABLED); | 5202 PRIVACY_MODE_DISABLED); |
5193 base::WeakPtr<SpdySession> spdy_session1 = | 5203 base::WeakPtr<SpdySession> spdy_session1 = |
5194 spdy_session_pool->FindAvailableSession(key1, GURL(), log); | 5204 spdy_session_pool->FindAvailableSession( |
| 5205 key1, GURL(), |
| 5206 /* enable_ip_based_pooling = */ true, log); |
5195 | 5207 |
5196 EXPECT_FALSE(spdy_session1->unclaimed_pushed_streams_.empty()); | 5208 EXPECT_FALSE(spdy_session1->unclaimed_pushed_streams_.empty()); |
5197 EXPECT_EQ(1u, spdy_session1->unclaimed_pushed_streams_.size()); | 5209 EXPECT_EQ(1u, spdy_session1->unclaimed_pushed_streams_.size()); |
5198 EXPECT_EQ(1u, | 5210 EXPECT_EQ(1u, |
5199 spdy_session1->unclaimed_pushed_streams_.count(GURL(url_to_push))); | 5211 spdy_session1->unclaimed_pushed_streams_.count(GURL(url_to_push))); |
5200 | 5212 |
5201 // Request |url_to_push|, which should be served from the pushed resource. | 5213 // Request |url_to_push|, which should be served from the pushed resource. |
5202 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 5214 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
5203 HttpRequestInfo push_request; | 5215 HttpRequestInfo push_request; |
5204 push_request.method = "GET"; | 5216 push_request.method = "GET"; |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6539 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6551 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6540 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 6552 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
6541 new SSLSocketDataProvider(ASYNC, OK)); | 6553 new SSLSocketDataProvider(ASYNC, OK)); |
6542 // Set to TLS_RSA_WITH_NULL_MD5 | 6554 // Set to TLS_RSA_WITH_NULL_MD5 |
6543 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6555 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6544 | 6556 |
6545 RunTLSUsageCheckTest(std::move(ssl_provider)); | 6557 RunTLSUsageCheckTest(std::move(ssl_provider)); |
6546 } | 6558 } |
6547 | 6559 |
6548 } // namespace net | 6560 } // namespace net |
OLD | NEW |