summaryrefslogtreecommitdiffstats
path: root/net/http/http_network_transaction_unittest.cc
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-13 04:52:01 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-13 04:52:01 +0000
commitdb8f44cb41f402a9145bace60f6097410f46881d (patch)
treee1a403ae9c38a7b5671133185ddc1ac936a89edf /net/http/http_network_transaction_unittest.cc
parentd49801990067e7fe9a3caf141f31c6e6ba58fcfc (diff)
downloadchromium_src-db8f44cb41f402a9145bace60f6097410f46881d.zip
chromium_src-db8f44cb41f402a9145bace60f6097410f46881d.tar.gz
chromium_src-db8f44cb41f402a9145bace60f6097410f46881d.tar.bz2
Reverting 6966.
this failed UI tests catastrophically Review URL: http://codereview.chromium.org/14103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6968 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r--net/http/http_network_transaction_unittest.cc63
1 files changed, 43 insertions, 20 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 7393a191..903f6d9 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -12,6 +12,7 @@
#include "net/http/http_network_transaction.h"
#include "net/http/http_transaction_unittest.h"
#include "net/proxy/proxy_resolver_fixed.h"
+#include "net/proxy/proxy_resolver_null.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -199,15 +200,13 @@ class MockClientSocketFactory : public net::ClientSocketFactory {
MockClientSocketFactory mock_socket_factory;
-net::HttpNetworkSession* CreateSessionWithProxy(const std::string& proxy) {
- net::ProxyInfo proxy_info;
- proxy_info.UseNamedProxy(proxy);
- return new net::HttpNetworkSession(
- new net::ProxyService(new net::ProxyResolverFixed(proxy_info)));
+// Create a proxy service which fails on all requests (falls back to direct).
+net::ProxyService* CreateNullProxyService() {
+ return new net::ProxyService(new net::ProxyResolverNull);
}
-net::HttpNetworkSession* CreateSession() {
- return new net::HttpNetworkSession(net::ProxyService::CreateNull());
+net::HttpNetworkSession* CreateSession(net::ProxyService* proxy_service) {
+ return new net::HttpNetworkSession(proxy_service);
}
class HttpNetworkTransactionTest : public PlatformTest {
@@ -237,8 +236,9 @@ struct SimpleGetHelperResult {
SimpleGetHelperResult SimpleGetHelper(MockRead data_reads[]) {
SimpleGetHelperResult out;
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(), &mock_socket_factory));
+ CreateSession(proxy_service.get()), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -289,8 +289,9 @@ void FillLargeHeadersString(std::string* str, int size) {
//-----------------------------------------------------------------------------
TEST_F(HttpNetworkTransactionTest, Basic) {
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(), &mock_socket_factory));
+ CreateSession(proxy_service.get()), &mock_socket_factory));
}
TEST_F(HttpNetworkTransactionTest, SimpleGET) {
@@ -397,7 +398,9 @@ TEST_F(HttpNetworkTransactionTest, StopsReading204) {
}
TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
- scoped_refptr<net::HttpNetworkSession> session = CreateSession();
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
+ scoped_refptr<net::HttpNetworkSession> session =
+ CreateSession(proxy_service.get());
MockRead data_reads[] = {
MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
@@ -446,8 +449,9 @@ TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
}
TEST_F(HttpNetworkTransactionTest, Ignores100) {
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(), &mock_socket_factory));
+ CreateSession(proxy_service.get()), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "POST";
@@ -491,7 +495,9 @@ TEST_F(HttpNetworkTransactionTest, Ignores100) {
// transaction to resend the request.
void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest(
const MockRead& read_failure) {
- scoped_refptr<net::HttpNetworkSession> session = CreateSession();
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
+ scoped_refptr<net::HttpNetworkSession> session =
+ CreateSession(proxy_service.get());
net::HttpRequestInfo request;
request.method = "GET";
@@ -556,8 +562,9 @@ TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) {
}
TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) {
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(), &mock_socket_factory));
+ CreateSession(proxy_service.get()), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -610,8 +617,9 @@ TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionEOF) {
// Test the request-challenge-retry sequence for basic auth.
// (basic auth is the easiest to mock, because it has no randomness).
TEST_F(HttpNetworkTransactionTest, BasicAuth) {
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(), &mock_socket_factory));
+ CreateSession(proxy_service.get()), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -701,9 +709,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuth) {
// authentication. Again, this uses basic auth for both since that is
// the simplest to mock.
TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) {
+ net::ProxyInfo proxy_info;
+ proxy_info.UseNamedProxy("myproxy:70");
+ net::ProxyService proxy_service(new net::ProxyResolverFixed(proxy_info));
+
// Configure against proxy server "myproxy:70".
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSessionWithProxy("myproxy:70"), &mock_socket_factory));
+ CreateSession(&proxy_service),
+ &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -835,8 +848,9 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) {
// After some maximum number of bytes is consumed, the transaction should
// fail with ERR_RESPONSE_HEADERS_TOO_BIG.
TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) {
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(), &mock_socket_factory));
+ CreateSession(proxy_service.get()), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -875,8 +889,12 @@ TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) {
// http://code.google.com/p/chromium/issues/detail?id=3772
TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) {
// Configure against proxy server "myproxy:70".
+ net::ProxyInfo proxy_info;
+ proxy_info.UseNamedProxy("myproxy:70");
+ net::ProxyService proxy_service(new net::ProxyResolverFixed(proxy_info));
+
scoped_refptr<net::HttpNetworkSession> session(
- CreateSessionWithProxy("myproxy:70"));
+ CreateSession(&proxy_service));
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -953,7 +971,9 @@ TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) {
request[1].upload_data->AppendBytes("foo", 3);
request[1].load_flags = 0;
- scoped_refptr<net::HttpNetworkSession> session = CreateSession();
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
+ scoped_refptr<net::HttpNetworkSession> session =
+ CreateSession(proxy_service.get());
// The first socket is used for transaction 1 and the first attempt of
// transaction 2.
@@ -1029,8 +1049,9 @@ TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) {
// an identity in the URL. The request should be sent as normal, but when
// it fails the identity from the URL is used to answer the challenge.
TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) {
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(), &mock_socket_factory));
+ CreateSession(proxy_service.get()), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -1098,7 +1119,9 @@ TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) {
// Test that previously tried username/passwords for a realm get re-used.
TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) {
- scoped_refptr<net::HttpNetworkSession> session = CreateSession();
+ scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
+ scoped_refptr<net::HttpNetworkSession> session =
+ CreateSession(proxy_service.get());
// Transaction 1: authenticate (foo, bar) on MyRealm1
{