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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_response_headers_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 // Reading should give EOF right away, since there is no message body 598 // Reading should give EOF right away, since there is no message body
599 // (despite non-zero content-length). 599 // (despite non-zero content-length).
600 std::string response_data; 600 std::string response_data;
601 rv = ReadTransaction(trans.get(), &response_data); 601 rv = ReadTransaction(trans.get(), &response_data);
602 EXPECT_EQ(OK, rv); 602 EXPECT_EQ(OK, rv);
603 EXPECT_EQ("", response_data); 603 EXPECT_EQ("", response_data);
604 } 604 }
605 605
606 TEST_F(HttpNetworkTransactionTest, ReuseConnection) { 606 TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
607 SessionDependencies session_deps; 607 SessionDependencies session_deps;
608 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 608 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
609 609
610 MockRead data_reads[] = { 610 MockRead data_reads[] = {
611 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 611 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
612 MockRead("hello"), 612 MockRead("hello"),
613 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 613 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
614 MockRead("world"), 614 MockRead("world"),
615 MockRead(false, OK), 615 MockRead(false, OK),
616 }; 616 };
617 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); 617 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
618 session_deps.socket_factory.AddSocketDataProvider(&data); 618 session_deps.socket_factory.AddSocketDataProvider(&data);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 787
788 rv = callback.WaitForResult(); 788 rv = callback.WaitForResult();
789 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); 789 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv);
790 } 790 }
791 791
792 // read_failure specifies a read failure that should cause the network 792 // read_failure specifies a read failure that should cause the network
793 // transaction to resend the request. 793 // transaction to resend the request.
794 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( 794 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest(
795 const MockRead& read_failure) { 795 const MockRead& read_failure) {
796 SessionDependencies session_deps; 796 SessionDependencies session_deps;
797 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 797 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
798 798
799 HttpRequestInfo request; 799 HttpRequestInfo request;
800 request.method = "GET"; 800 request.method = "GET";
801 request.url = GURL("http://www.foo.com/"); 801 request.url = GURL("http://www.foo.com/");
802 request.load_flags = 0; 802 request.load_flags = 0;
803 803
804 MockRead data1_reads[] = { 804 MockRead data1_reads[] = {
805 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 805 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
806 MockRead("hello"), 806 MockRead("hello"),
807 read_failure, // Now, we reuse the connection and fail the first read. 807 read_failure, // Now, we reuse the connection and fail the first read.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 }; 904 };
905 SimpleGetHelperResult out = SimpleGetHelper(data_reads, 905 SimpleGetHelperResult out = SimpleGetHelper(data_reads,
906 arraysize(data_reads)); 906 arraysize(data_reads));
907 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv); 907 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv);
908 } 908 }
909 909
910 // Test that we correctly reuse a keep-alive connection after not explicitly 910 // Test that we correctly reuse a keep-alive connection after not explicitly
911 // reading the body. 911 // reading the body.
912 TEST_F(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) { 912 TEST_F(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) {
913 SessionDependencies session_deps; 913 SessionDependencies session_deps;
914 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 914 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
915 915
916 HttpRequestInfo request; 916 HttpRequestInfo request;
917 request.method = "GET"; 917 request.method = "GET";
918 request.url = GURL("http://www.foo.com/"); 918 request.url = GURL("http://www.foo.com/");
919 request.load_flags = 0; 919 request.load_flags = 0;
920 920
921 // Note that because all these reads happen in the same 921 // Note that because all these reads happen in the same
922 // StaticSocketDataProvider, it shows that the same socket is being reused for 922 // StaticSocketDataProvider, it shows that the same socket is being reused for
923 // all transactions. 923 // all transactions.
924 MockRead data1_reads[] = { 924 MockRead data1_reads[] = {
(...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3243 // transaction 1. The first attempts fails when writing the POST data. 3243 // transaction 1. The first attempts fails when writing the POST data.
3244 // This causes the transaction to retry with a new socket. The second 3244 // This causes the transaction to retry with a new socket. The second
3245 // attempt succeeds. 3245 // attempt succeeds.
3246 request[1].method = "POST"; 3246 request[1].method = "POST";
3247 request[1].url = GURL("http://www.google.com/login.cgi"); 3247 request[1].url = GURL("http://www.google.com/login.cgi");
3248 request[1].upload_data = new UploadData; 3248 request[1].upload_data = new UploadData;
3249 request[1].upload_data->AppendBytes("foo", 3); 3249 request[1].upload_data->AppendBytes("foo", 3);
3250 request[1].load_flags = 0; 3250 request[1].load_flags = 0;
3251 3251
3252 SessionDependencies session_deps; 3252 SessionDependencies session_deps;
3253 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 3253 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
3254 3254
3255 // The first socket is used for transaction 1 and the first attempt of 3255 // The first socket is used for transaction 1 and the first attempt of
3256 // transaction 2. 3256 // transaction 2.
3257 3257
3258 // The response of transaction 1. 3258 // The response of transaction 1.
3259 MockRead data_reads1[] = { 3259 MockRead data_reads1[] = {
3260 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"), 3260 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"),
3261 MockRead("hello world"), 3261 MockRead("hello world"),
3262 MockRead(false, OK), 3262 MockRead(false, OK),
3263 }; 3263 };
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 3511
3512 EXPECT_EQ(100, response->headers->GetContentLength()); 3512 EXPECT_EQ(100, response->headers->GetContentLength());
3513 3513
3514 // Empty the current queue. 3514 // Empty the current queue.
3515 MessageLoop::current()->RunAllPending(); 3515 MessageLoop::current()->RunAllPending();
3516 } 3516 }
3517 3517
3518 // Test that previously tried username/passwords for a realm get re-used. 3518 // Test that previously tried username/passwords for a realm get re-used.
3519 TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { 3519 TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) {
3520 SessionDependencies session_deps; 3520 SessionDependencies session_deps;
3521 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 3521 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
3522 3522
3523 // Transaction 1: authenticate (foo, bar) on MyRealm1 3523 // Transaction 1: authenticate (foo, bar) on MyRealm1
3524 { 3524 {
3525 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 3525 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
3526 3526
3527 HttpRequestInfo request; 3527 HttpRequestInfo request;
3528 request.method = "GET"; 3528 request.method = "GET";
3529 request.url = GURL("http://www.google.com/x/y/z"); 3529 request.url = GURL("http://www.google.com/x/y/z");
3530 request.load_flags = 0; 3530 request.load_flags = 0;
3531 3531
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 EXPECT_FALSE(response == NULL); 3904 EXPECT_FALSE(response == NULL);
3905 EXPECT_TRUE(response->auth_challenge.get() == NULL); 3905 EXPECT_TRUE(response->auth_challenge.get() == NULL);
3906 EXPECT_EQ(100, response->headers->GetContentLength()); 3906 EXPECT_EQ(100, response->headers->GetContentLength());
3907 } 3907 }
3908 } 3908 }
3909 3909
3910 // Tests that nonce count increments when multiple auth attempts 3910 // Tests that nonce count increments when multiple auth attempts
3911 // are started with the same nonce. 3911 // are started with the same nonce.
3912 TEST_F(HttpNetworkTransactionTest, DigestPreAuthNonceCount) { 3912 TEST_F(HttpNetworkTransactionTest, DigestPreAuthNonceCount) {
3913 SessionDependencies session_deps; 3913 SessionDependencies session_deps;
3914 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 3914 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
3915 HttpAuthHandlerDigest::SetFixedCnonce(true); 3915 HttpAuthHandlerDigest::SetFixedCnonce(true);
3916 3916
3917 // Transaction 1: authenticate (foo, bar) on MyRealm1 3917 // Transaction 1: authenticate (foo, bar) on MyRealm1
3918 { 3918 {
3919 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 3919 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
3920 3920
3921 HttpRequestInfo request; 3921 HttpRequestInfo request;
3922 request.method = "GET"; 3922 request.method = "GET";
3923 request.url = GURL("http://www.google.com/x/y/z"); 3923 request.url = GURL("http://www.google.com/x/y/z");
3924 request.load_flags = 0; 3924 request.load_flags = 0;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4058 HttpResponseInfo* response = &trans->response_; 4058 HttpResponseInfo* response = &trans->response_;
4059 response->auth_challenge = new AuthChallengeInfo(); 4059 response->auth_challenge = new AuthChallengeInfo();
4060 response->ssl_info.cert_status = -15; 4060 response->ssl_info.cert_status = -15;
4061 response->response_time = base::Time::Now(); 4061 response->response_time = base::Time::Now();
4062 response->was_cached = true; // (Wouldn't ever actually be true...) 4062 response->was_cached = true; // (Wouldn't ever actually be true...)
4063 4063
4064 { // Setup state for response_.vary_data 4064 { // Setup state for response_.vary_data
4065 HttpRequestInfo request; 4065 HttpRequestInfo request;
4066 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); 4066 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n");
4067 std::replace(temp.begin(), temp.end(), '\n', '\0'); 4067 std::replace(temp.begin(), temp.end(), '\n', '\0');
4068 scoped_refptr<HttpResponseHeaders> headers = new HttpResponseHeaders(temp); 4068 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp));
4069 request.extra_headers.SetHeader("Foo", "1"); 4069 request.extra_headers.SetHeader("Foo", "1");
4070 request.extra_headers.SetHeader("bar", "23"); 4070 request.extra_headers.SetHeader("bar", "23");
4071 EXPECT_TRUE(response->vary_data.Init(request, *headers)); 4071 EXPECT_TRUE(response->vary_data.Init(request, *headers));
4072 } 4072 }
4073 4073
4074 // Cause the above state to be reset. 4074 // Cause the above state to be reset.
4075 trans->ResetStateForRestart(); 4075 trans->ResetStateForRestart();
4076 4076
4077 // Verify that the state that needed to be reset, has been reset. 4077 // Verify that the state that needed to be reset, has been reset.
4078 EXPECT_TRUE(trans->read_buf_.get() == NULL); 4078 EXPECT_TRUE(trans->read_buf_.get() == NULL);
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
5371 BypassHostCacheOnRefreshHelper(LOAD_VALIDATE_CACHE); 5371 BypassHostCacheOnRefreshHelper(LOAD_VALIDATE_CACHE);
5372 } 5372 }
5373 5373
5374 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh3) { 5374 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh3) {
5375 BypassHostCacheOnRefreshHelper(LOAD_DISABLE_CACHE); 5375 BypassHostCacheOnRefreshHelper(LOAD_DISABLE_CACHE);
5376 } 5376 }
5377 5377
5378 // Make sure we can handle an error when writing the request. 5378 // Make sure we can handle an error when writing the request.
5379 TEST_F(HttpNetworkTransactionTest, RequestWriteError) { 5379 TEST_F(HttpNetworkTransactionTest, RequestWriteError) {
5380 SessionDependencies session_deps; 5380 SessionDependencies session_deps;
5381 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 5381 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
5382 5382
5383 HttpRequestInfo request; 5383 HttpRequestInfo request;
5384 request.method = "GET"; 5384 request.method = "GET";
5385 request.url = GURL("http://www.foo.com/"); 5385 request.url = GURL("http://www.foo.com/");
5386 request.load_flags = 0; 5386 request.load_flags = 0;
5387 5387
5388 MockWrite write_failure[] = { 5388 MockWrite write_failure[] = {
5389 MockWrite(true, ERR_CONNECTION_RESET), 5389 MockWrite(true, ERR_CONNECTION_RESET),
5390 }; 5390 };
5391 StaticSocketDataProvider data(NULL, 0, 5391 StaticSocketDataProvider data(NULL, 0,
5392 write_failure, arraysize(write_failure)); 5392 write_failure, arraysize(write_failure));
5393 session_deps.socket_factory.AddSocketDataProvider(&data); 5393 session_deps.socket_factory.AddSocketDataProvider(&data);
5394 5394
5395 TestCompletionCallback callback; 5395 TestCompletionCallback callback;
5396 5396
5397 scoped_ptr<HttpTransaction> trans( 5397 scoped_ptr<HttpTransaction> trans(
5398 new HttpNetworkTransaction(CreateSession(&session_deps))); 5398 new HttpNetworkTransaction(CreateSession(&session_deps)));
5399 5399
5400 int rv = trans->Start(&request, &callback, BoundNetLog()); 5400 int rv = trans->Start(&request, &callback, BoundNetLog());
5401 EXPECT_EQ(ERR_IO_PENDING, rv); 5401 EXPECT_EQ(ERR_IO_PENDING, rv);
5402 5402
5403 rv = callback.WaitForResult(); 5403 rv = callback.WaitForResult();
5404 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 5404 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
5405 } 5405 }
5406 5406
5407 // Check that a connection closed after the start of the headers finishes ok. 5407 // Check that a connection closed after the start of the headers finishes ok.
5408 TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { 5408 TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) {
5409 SessionDependencies session_deps; 5409 SessionDependencies session_deps;
5410 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 5410 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
5411 5411
5412 HttpRequestInfo request; 5412 HttpRequestInfo request;
5413 request.method = "GET"; 5413 request.method = "GET";
5414 request.url = GURL("http://www.foo.com/"); 5414 request.url = GURL("http://www.foo.com/");
5415 request.load_flags = 0; 5415 request.load_flags = 0;
5416 5416
5417 MockRead data_reads[] = { 5417 MockRead data_reads[] = {
5418 MockRead("HTTP/1."), 5418 MockRead("HTTP/1."),
5419 MockRead(false, OK), 5419 MockRead(false, OK),
5420 }; 5420 };
(...skipping 21 matching lines...) Expand all
5442 std::string response_data; 5442 std::string response_data;
5443 rv = ReadTransaction(trans.get(), &response_data); 5443 rv = ReadTransaction(trans.get(), &response_data);
5444 EXPECT_EQ(OK, rv); 5444 EXPECT_EQ(OK, rv);
5445 EXPECT_EQ("", response_data); 5445 EXPECT_EQ("", response_data);
5446 } 5446 }
5447 5447
5448 // Make sure that a dropped connection while draining the body for auth 5448 // Make sure that a dropped connection while draining the body for auth
5449 // restart does the right thing. 5449 // restart does the right thing.
5450 TEST_F(HttpNetworkTransactionTest, DrainResetOK) { 5450 TEST_F(HttpNetworkTransactionTest, DrainResetOK) {
5451 SessionDependencies session_deps; 5451 SessionDependencies session_deps;
5452 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 5452 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
5453 5453
5454 HttpRequestInfo request; 5454 HttpRequestInfo request;
5455 request.method = "GET"; 5455 request.method = "GET";
5456 request.url = GURL("http://www.google.com/"); 5456 request.url = GURL("http://www.google.com/");
5457 request.load_flags = 0; 5457 request.load_flags = 0;
5458 5458
5459 MockWrite data_writes1[] = { 5459 MockWrite data_writes1[] = {
5460 MockWrite("GET / HTTP/1.1\r\n" 5460 MockWrite("GET / HTTP/1.1\r\n"
5461 "Host: www.google.com\r\n" 5461 "Host: www.google.com\r\n"
5462 "Connection: keep-alive\r\n\r\n"), 5462 "Connection: keep-alive\r\n\r\n"),
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
6466 std::string response_data; 6466 std::string response_data;
6467 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 6467 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
6468 EXPECT_EQ("hello world", response_data); 6468 EXPECT_EQ("hello world", response_data);
6469 6469
6470 // Set up an initial SpdySession in the pool to reuse. 6470 // Set up an initial SpdySession in the pool to reuse.
6471 HostPortPair host_port_pair("www.google.com", 443); 6471 HostPortPair host_port_pair("www.google.com", 443);
6472 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); 6472 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
6473 scoped_refptr<SpdySession> spdy_session = 6473 scoped_refptr<SpdySession> spdy_session =
6474 session->spdy_session_pool()->Get(pair, session->mutable_spdy_settings(), 6474 session->spdy_session_pool()->Get(pair, session->mutable_spdy_settings(),
6475 BoundNetLog()); 6475 BoundNetLog());
6476 scoped_refptr<TCPSocketParams> tcp_params = 6476 scoped_refptr<TCPSocketParams> tcp_params(
6477 new TCPSocketParams("www.google.com", 443, MEDIUM, GURL(), false); 6477 new TCPSocketParams("www.google.com", 443, MEDIUM, GURL(), false));
6478 6478
6479 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 6479 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
6480 EXPECT_EQ(ERR_IO_PENDING, 6480 EXPECT_EQ(ERR_IO_PENDING,
6481 connection->Init(host_port_pair.ToString(),tcp_params, LOWEST, 6481 connection->Init(host_port_pair.ToString(),tcp_params, LOWEST,
6482 &callback, session->tcp_socket_pool(), 6482 &callback, session->tcp_socket_pool(),
6483 BoundNetLog())); 6483 BoundNetLog()));
6484 EXPECT_EQ(OK, callback.WaitForResult()); 6484 EXPECT_EQ(OK, callback.WaitForResult());
6485 6485
6486 SSLConfig ssl_config; 6486 SSLConfig ssl_config;
6487 session->ssl_config_service()->GetSSLConfig(&ssl_config); 6487 session->ssl_config_service()->GetSSLConfig(&ssl_config);
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
6941 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); 6941 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock());
6942 auth_handler->set_connection_based(true); 6942 auth_handler->set_connection_based(true);
6943 std::string auth_challenge = "Mock realm=server"; 6943 std::string auth_challenge = "Mock realm=server";
6944 GURL origin("http://www.example.com"); 6944 GURL origin("http://www.example.com");
6945 HttpAuth::ChallengeTokenizer tokenizer(auth_challenge.begin(), 6945 HttpAuth::ChallengeTokenizer tokenizer(auth_challenge.begin(),
6946 auth_challenge.end()); 6946 auth_challenge.end());
6947 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, 6947 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER,
6948 origin, BoundNetLog()); 6948 origin, BoundNetLog());
6949 auth_factory->set_mock_handler(auth_handler, HttpAuth::AUTH_SERVER); 6949 auth_factory->set_mock_handler(auth_handler, HttpAuth::AUTH_SERVER);
6950 6950
6951 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 6951 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
6952 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 6952 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
6953 6953
6954 int rv = OK; 6954 int rv = OK;
6955 const HttpResponseInfo* response = NULL; 6955 const HttpResponseInfo* response = NULL;
6956 HttpRequestInfo request; 6956 HttpRequestInfo request;
6957 request.method = "GET"; 6957 request.method = "GET";
6958 request.url = origin; 6958 request.url = origin;
6959 request.load_flags = 0; 6959 request.load_flags = 0;
6960 TestCompletionCallback callback; 6960 TestCompletionCallback callback;
6961 6961
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
7642 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); 7642 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
7643 7643
7644 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); 7644 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
7645 7645
7646 // Set up an initial SpdySession in the pool to reuse. 7646 // Set up an initial SpdySession in the pool to reuse.
7647 HostPortPair host_port_pair("www.google.com", 443); 7647 HostPortPair host_port_pair("www.google.com", 443);
7648 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); 7648 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
7649 scoped_refptr<SpdySession> spdy_session = 7649 scoped_refptr<SpdySession> spdy_session =
7650 session->spdy_session_pool()->Get(pair, session->mutable_spdy_settings(), 7650 session->spdy_session_pool()->Get(pair, session->mutable_spdy_settings(),
7651 BoundNetLog()); 7651 BoundNetLog());
7652 scoped_refptr<TCPSocketParams> tcp_params = 7652 scoped_refptr<TCPSocketParams> tcp_params(
7653 new TCPSocketParams("www.google.com", 443, MEDIUM, GURL(), false); 7653 new TCPSocketParams("www.google.com", 443, MEDIUM, GURL(), false));
7654 TestCompletionCallback callback; 7654 TestCompletionCallback callback;
7655 7655
7656 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 7656 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
7657 EXPECT_EQ(ERR_IO_PENDING, 7657 EXPECT_EQ(ERR_IO_PENDING,
7658 connection->Init(host_port_pair.ToString(), tcp_params, LOWEST, 7658 connection->Init(host_port_pair.ToString(), tcp_params, LOWEST,
7659 &callback, session->tcp_socket_pool(), 7659 &callback, session->tcp_socket_pool(),
7660 BoundNetLog())); 7660 BoundNetLog()));
7661 EXPECT_EQ(OK, callback.WaitForResult()); 7661 EXPECT_EQ(OK, callback.WaitForResult());
7662 spdy_session->InitializeWithSocket(connection.release(), false, OK); 7662 spdy_session->InitializeWithSocket(connection.release(), false, OK);
7663 7663
7664 HttpRequestInfo request; 7664 HttpRequestInfo request;
7665 request.method = "GET"; 7665 request.method = "GET";
7666 request.url = GURL("https://www.google.com/"); 7666 request.url = GURL("https://www.google.com/");
7667 request.load_flags = 0; 7667 request.load_flags = 0;
7668 7668
7669 // This is the important line that marks this as a preconnect. 7669 // This is the important line that marks this as a preconnect.
7670 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; 7670 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED;
7671 7671
7672 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); 7672 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session));
7673 7673
7674 int rv = trans->Start(&request, &callback, BoundNetLog()); 7674 int rv = trans->Start(&request, &callback, BoundNetLog());
7675 EXPECT_EQ(ERR_IO_PENDING, rv); 7675 EXPECT_EQ(ERR_IO_PENDING, rv);
7676 EXPECT_EQ(OK, callback.WaitForResult()); 7676 EXPECT_EQ(OK, callback.WaitForResult());
7677 } 7677 }
7678 7678
7679 } // namespace net 7679 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_response_headers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698