diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 20:12:45 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 20:12:45 +0000 |
commit | e44de5df0a30d8071e2b7d098c78a3de82ebfbf4 (patch) | |
tree | f612ced0d7686b83af3a049d11f0d8813ea6b909 /net | |
parent | 9c9811cc39df633c38c01ff1eb99532a3dbed7ba (diff) | |
download | chromium_src-e44de5df0a30d8071e2b7d098c78a3de82ebfbf4.zip chromium_src-e44de5df0a30d8071e2b7d098c78a3de82ebfbf4.tar.gz chromium_src-e44de5df0a30d8071e2b7d098c78a3de82ebfbf4.tar.bz2 |
Send the "Proxy-Connection: keep-alive" header with HTTP CONNECT
requests for compatibility with HTTP/1.0 proxies such as Squid.
This is required for NTLM authentication.
Fix some cpplint.py nits in http_network_transaction_unittest.cc.
R=eroman
BUG=http://crbug.com/8771
TEST=net_unittests passes all tests
Review URL: http://codereview.chromium.org/118316
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_network_transaction.cc | 6 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 27 |
2 files changed, 21 insertions, 12 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 1ce3da4..f65cabc 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -104,8 +104,10 @@ void BuildTunnelRequest(const HttpRequestInfo* request_info, const std::string& authorization_headers, std::string* request_headers) { // RFC 2616 Section 9 says the Host request-header field MUST accompany all - // HTTP/1.1 requests. - *request_headers = StringPrintf("CONNECT %s HTTP/1.1\r\nHost: %s\r\n", + // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with + // HTTP/1.0 proxies such as Squid (required for NTLM authentication). + *request_headers = StringPrintf( + "CONNECT %s HTTP/1.1\r\nHost: %s\r\nProxy-Connection: keep-alive\r\n", GetHostAndPort(request_info->url).c_str(), GetHostAndOptionalPort(request_info->url).c_str()); diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index a8de962..ae39b51 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -29,14 +29,15 @@ ProxyService* CreateNullProxyService() { return ProxyService::CreateNull(); } -// Helper to manage the lifetimes of the dependencies for a HttpNetworkTransaction. +// Helper to manage the lifetimes of the dependencies for a +// HttpNetworkTransaction. class SessionDependencies { public: // Default set of dependencies -- "null" proxy service. SessionDependencies() : proxy_service(CreateNullProxyService()) {} // Custom proxy service dependency. - SessionDependencies(ProxyService* proxy_service) + explicit SessionDependencies(ProxyService* proxy_service) : proxy_service(proxy_service) {} scoped_ptr<ProxyService> proxy_service; @@ -115,7 +116,6 @@ class HttpNetworkTransactionTest : public PlatformTest { int expected_status); void ConnectStatusHelper(const MockRead& status); - }; // Fill |str| with a long header list that consumes >= |size| bytes. @@ -953,12 +953,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) { // Since we have proxy, should try to establish tunnel. MockWrite data_writes1[] = { MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" - "Host: www.google.com\r\n\r\n"), + "Host: www.google.com\r\n" + "Proxy-Connection: keep-alive\r\n\r\n"), // After calling trans->RestartWithAuth(), this is the request we should // be issuing -- the final header line contains the credentials. MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" "Host: www.google.com\r\n" + "Proxy-Connection: keep-alive\r\n" "Proxy-Authorization: Basic Zm9vOmJheg==\r\n\r\n"), }; @@ -1038,7 +1040,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { // Configure against proxy server "myproxy:70". SessionDependencies session_deps(CreateFixedProxyService("myproxy:70")); - scoped_refptr<HttpNetworkSession> session( CreateSession(&session_deps)); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( session.get(), &session_deps.socket_factory)); @@ -1051,7 +1053,8 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { // Since we have proxy, should try to establish tunnel. MockWrite data_writes[] = { MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" - "Host: www.google.com\r\n\r\n"), + "Host: www.google.com\r\n" + "Proxy-Connection: keep-alive\r\n\r\n"), }; // The proxy responds to the connect with a 407. @@ -1106,7 +1109,8 @@ void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( // Since we have proxy, should try to establish tunnel. MockWrite data_writes[] = { MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" - "Host: www.google.com\r\n\r\n"), + "Host: www.google.com\r\n" + "Proxy-Connection: keep-alive\r\n\r\n"), }; MockRead data_reads[] = { @@ -1834,7 +1838,8 @@ TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) { // Since we have proxy, should try to establish tunnel. MockWrite data_writes1[] = { MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" - "Host: www.google.com\r\n\r\n"), + "Host: www.google.com\r\n" + "Proxy-Connection: keep-alive\r\n\r\n"), }; // The proxy responds to the connect with a 404, using a persistent @@ -2696,7 +2701,8 @@ TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) { MockWrite proxy_writes[] = { MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" - "Host: www.google.com\r\n\r\n"), + "Host: www.google.com\r\n" + "Proxy-Connection: keep-alive\r\n\r\n"), }; MockRead proxy_reads[] = { @@ -2706,7 +2712,8 @@ TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) { MockWrite data_writes[] = { MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" - "Host: www.google.com\r\n\r\n"), + "Host: www.google.com\r\n" + "Proxy-Connection: keep-alive\r\n\r\n"), MockWrite("GET / HTTP/1.1\r\n" "Host: www.google.com\r\n" "Connection: keep-alive\r\n\r\n"), |