Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: net/spdy/spdy_session_pool_unittest.cc

Issue 2771263002: Retry upon 421 status code without IP pooling. (Closed)
Patch Set: Rebase. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/spdy/spdy_session_pool.h" 5 #include "net/spdy/spdy_session_pool.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 // Flush the SpdySession::OnReadComplete() task. 387 // Flush the SpdySession::OnReadComplete() task.
388 base::RunLoop().RunUntilIdle(); 388 base::RunLoop().RunUntilIdle();
389 389
390 // The third host has no overlap with the first, so it can't pool IPs. 390 // The third host has no overlap with the first, so it can't pool IPs.
391 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, test_hosts[2].key)); 391 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, test_hosts[2].key));
392 392
393 // The second host overlaps with the first, and should IP pool. 393 // The second host overlaps with the first, and should IP pool.
394 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[1].key)); 394 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[1].key));
395 395
396 // However, if IP pooling is disabled, FindAvailableSession() should not find
397 // |session| for the second host.
398 base::WeakPtr<SpdySession> session1 =
399 spdy_session_pool_->FindAvailableSession(
400 test_hosts[1].key, GURL(test_hosts[1].url),
401 /* enable_ip_based_pooling = */ false, NetLogWithSource());
402 EXPECT_FALSE(session1);
403
396 // Verify that the second host, through a proxy, won't share the IP. 404 // Verify that the second host, through a proxy, won't share the IP.
397 SpdySessionKey proxy_key(test_hosts[1].key.host_port_pair(), 405 SpdySessionKey proxy_key(test_hosts[1].key.host_port_pair(),
398 ProxyServer::FromPacString("HTTP http://proxy.foo.com/"), 406 ProxyServer::FromPacString("HTTP http://proxy.foo.com/"),
399 PRIVACY_MODE_DISABLED); 407 PRIVACY_MODE_DISABLED);
400 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, proxy_key)); 408 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, proxy_key));
401 409
402 // Overlap between 2 and 3 does is not transitive to 1. 410 // Overlap between 2 and 3 does is not transitive to 1.
403 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, test_hosts[2].key)); 411 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, test_hosts[2].key));
404 412
405 // Create a new session to host 2. 413 // Create a new session to host 2.
406 StaticSocketDataProvider data2(reads, arraysize(reads), NULL, 0); 414 StaticSocketDataProvider data2(reads, arraysize(reads), NULL, 0);
407 data2.set_connect_data(connect_data); 415 data2.set_connect_data(connect_data);
408 session_deps_.socket_factory->AddSocketDataProvider(&data2); 416 session_deps_.socket_factory->AddSocketDataProvider(&data2);
409 417
410 AddSSLSocketData(); 418 AddSSLSocketData();
411 419
412 base::WeakPtr<SpdySession> session2 = CreateSecureSpdySession( 420 base::WeakPtr<SpdySession> session2 = CreateSecureSpdySession(
413 http_session_.get(), test_hosts[2].key, NetLogWithSource()); 421 http_session_.get(), test_hosts[2].key, NetLogWithSource());
414 422
415 // Verify that we have sessions for everything. 423 // Verify that we have sessions for everything.
416 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[0].key)); 424 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[0].key));
417 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[1].key)); 425 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[1].key));
418 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[2].key)); 426 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[2].key));
419 427
420 // Grab the session to host 1 and verify that it is the same session 428 // Grab the session to host 1 and verify that it is the same session
421 // we got with host 0, and that is a different from host 2's session. 429 // we got with host 0, and that is a different from host 2's session.
422 base::WeakPtr<SpdySession> session1 = 430 session1 = spdy_session_pool_->FindAvailableSession(
423 spdy_session_pool_->FindAvailableSession( 431 test_hosts[1].key, GURL(test_hosts[1].url),
424 test_hosts[1].key, GURL(test_hosts[1].url), 432 /* enable_ip_based_pooling = */ true, NetLogWithSource());
425 /* enable_ip_based_pooling = */ true, NetLogWithSource());
426 EXPECT_EQ(session.get(), session1.get()); 433 EXPECT_EQ(session.get(), session1.get());
427 EXPECT_NE(session2.get(), session1.get()); 434 EXPECT_NE(session2.get(), session1.get());
428 435
429 // Remove the aliases and observe that we still have a session for host1. 436 // Remove the aliases and observe that we still have a session for host1.
430 SpdySessionPoolPeer pool_peer(spdy_session_pool_); 437 SpdySessionPoolPeer pool_peer(spdy_session_pool_);
431 pool_peer.RemoveAliases(test_hosts[0].key); 438 pool_peer.RemoveAliases(test_hosts[0].key);
432 pool_peer.RemoveAliases(test_hosts[1].key); 439 pool_peer.RemoveAliases(test_hosts[1].key);
433 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[1].key)); 440 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[1].key));
434 441
435 // Expire the host cache 442 // Expire the host cache
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 active_session_count_attr->GetString("value", &active_session_count)); 901 active_session_count_attr->GetString("value", &active_session_count));
895 // No created stream so the session should be idle. 902 // No created stream so the session should be idle.
896 ASSERT_EQ("0", active_session_count); 903 ASSERT_EQ("0", active_session_count);
897 did_dump = true; 904 did_dump = true;
898 } 905 }
899 EXPECT_TRUE(did_dump); 906 EXPECT_TRUE(did_dump);
900 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED); 907 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED);
901 } 908 }
902 909
903 } // namespace net 910 } // namespace net
OLDNEW
« net/http/http_network_transaction.cc ('K') | « net/http/http_stream_factory_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698