| OLD | NEW |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 ProxyService* CreateFixedProxyService(const std::string& proxy) { | 99 ProxyService* CreateFixedProxyService(const std::string& proxy) { |
| 100 net::ProxyConfig proxy_config; | 100 net::ProxyConfig proxy_config; |
| 101 proxy_config.proxy_rules().ParseFromString(proxy); | 101 proxy_config.proxy_rules().ParseFromString(proxy); |
| 102 return ProxyService::CreateFixed(proxy_config); | 102 return ProxyService::CreateFixed(proxy_config); |
| 103 } | 103 } |
| 104 | 104 |
| 105 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | 105 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { |
| 106 return new HttpNetworkSession(session_deps->host_resolver.get(), | 106 return new HttpNetworkSession(session_deps->host_resolver.get(), |
| 107 NULL /* dnsrr_resolver */, | 107 NULL /* dnsrr_resolver */, |
| 108 NULL /* ssl_host_info_factory */, |
| 108 session_deps->proxy_service, | 109 session_deps->proxy_service, |
| 109 &session_deps->socket_factory, | 110 &session_deps->socket_factory, |
| 110 session_deps->ssl_config_service, | 111 session_deps->ssl_config_service, |
| 111 new SpdySessionPool(NULL), | 112 new SpdySessionPool(NULL), |
| 112 session_deps->http_auth_handler_factory.get(), | 113 session_deps->http_auth_handler_factory.get(), |
| 113 NULL, | 114 NULL, |
| 114 session_deps->net_log); | 115 session_deps->net_log); |
| 115 } | 116 } |
| 116 | 117 |
| 117 class HttpNetworkTransactionTest : public PlatformTest { | 118 class HttpNetworkTransactionTest : public PlatformTest { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 template<> | 299 template<> |
| 299 CaptureGroupNameHttpProxySocketPool::CaptureGroupNameSocketPool( | 300 CaptureGroupNameHttpProxySocketPool::CaptureGroupNameSocketPool( |
| 300 HttpNetworkSession* session) | 301 HttpNetworkSession* session) |
| 301 : HttpProxyClientSocketPool(0, 0, NULL, session->host_resolver(), NULL, | 302 : HttpProxyClientSocketPool(0, 0, NULL, session->host_resolver(), NULL, |
| 302 NULL, NULL) {} | 303 NULL, NULL) {} |
| 303 | 304 |
| 304 template<> | 305 template<> |
| 305 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( | 306 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( |
| 306 HttpNetworkSession* session) | 307 HttpNetworkSession* session) |
| 307 : SSLClientSocketPool(0, 0, NULL, session->host_resolver(), NULL, NULL, | 308 : SSLClientSocketPool(0, 0, NULL, session->host_resolver(), NULL, NULL, |
| 308 NULL, NULL, NULL, NULL, NULL) {} | 309 NULL, NULL, NULL, NULL, NULL, NULL) {} |
| 309 | 310 |
| 310 //----------------------------------------------------------------------------- | 311 //----------------------------------------------------------------------------- |
| 311 | 312 |
| 312 // This is the expected list of advertised protocols from the browser's NPN | 313 // This is the expected list of advertised protocols from the browser's NPN |
| 313 // list. | 314 // list. |
| 314 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; | 315 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; |
| 315 | 316 |
| 316 // This is the expected return from a current server advertising SPDY. | 317 // This is the expected return from a current server advertising SPDY. |
| 317 static const char kAlternateProtocolHttpHeader[] = | 318 static const char kAlternateProtocolHttpHeader[] = |
| 318 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; | 319 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; |
| (...skipping 6105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6424 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 6425 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
| 6425 EXPECT_EQ(ERR_IO_PENDING, | 6426 EXPECT_EQ(ERR_IO_PENDING, |
| 6426 connection->Init(host_port_pair.ToString(),tcp_params, LOWEST, | 6427 connection->Init(host_port_pair.ToString(),tcp_params, LOWEST, |
| 6427 &callback, session->tcp_socket_pool(), | 6428 &callback, session->tcp_socket_pool(), |
| 6428 BoundNetLog())); | 6429 BoundNetLog())); |
| 6429 EXPECT_EQ(OK, callback.WaitForResult()); | 6430 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6430 | 6431 |
| 6431 SSLConfig ssl_config; | 6432 SSLConfig ssl_config; |
| 6432 session->ssl_config_service()->GetSSLConfig(&ssl_config); | 6433 session->ssl_config_service()->GetSSLConfig(&ssl_config); |
| 6433 ClientSocket* socket = connection->release_socket(); | 6434 ClientSocket* socket = connection->release_socket(); |
| 6434 socket = session->socket_factory()->CreateSSLClientSocket(socket, "" , | 6435 socket = session->socket_factory()->CreateSSLClientSocket( |
| 6435 ssl_config); | 6436 socket, "" , ssl_config, NULL /* ssl_host_info */); |
| 6436 connection->set_socket(socket); | 6437 connection->set_socket(socket); |
| 6437 EXPECT_EQ(ERR_IO_PENDING, socket->Connect(&callback)); | 6438 EXPECT_EQ(ERR_IO_PENDING, socket->Connect(&callback)); |
| 6438 EXPECT_EQ(OK, callback.WaitForResult()); | 6439 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6439 | 6440 |
| 6440 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(connection.release(), | 6441 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(connection.release(), |
| 6441 true, OK)); | 6442 true, OK)); |
| 6442 | 6443 |
| 6443 trans.reset(new HttpNetworkTransaction(session)); | 6444 trans.reset(new HttpNetworkTransaction(session)); |
| 6444 | 6445 |
| 6445 rv = trans->Start(&request, &callback, BoundNetLog()); | 6446 rv = trans->Start(&request, &callback, BoundNetLog()); |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7667 std::string response_data; | 7668 std::string response_data; |
| 7668 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7669 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 7669 EXPECT_EQ("hello world", response_data); | 7670 EXPECT_EQ("hello world", response_data); |
| 7670 | 7671 |
| 7671 HttpStreamFactory::set_next_protos(""); | 7672 HttpStreamFactory::set_next_protos(""); |
| 7672 HttpStreamFactory::set_use_alternate_protocols(false); | 7673 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7673 HttpStreamFactory::set_create_new_spdy_session_for_http(true); | 7674 HttpStreamFactory::set_create_new_spdy_session_for_http(true); |
| 7674 } | 7675 } |
| 7675 | 7676 |
| 7676 } // namespace net | 7677 } // namespace net |
| OLD | NEW |