diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 20:03:05 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 20:03:05 +0000 |
commit | 9faeded93d44c81c50c3d4ebfa3009c60f08a4c4 (patch) | |
tree | 8cd8f6756d8af0a9c538fc1599744affa53b4fe9 /net/http | |
parent | 9f8980986fed2a3dbd518728153fce41ed4b18a7 (diff) | |
download | chromium_src-9faeded93d44c81c50c3d4ebfa3009c60f08a4c4.zip chromium_src-9faeded93d44c81c50c3d4ebfa3009c60f08a4c4.tar.gz chromium_src-9faeded93d44c81c50c3d4ebfa3009c60f08a4c4.tar.bz2 |
Fix Alternate-Protocol to work with proxies.
Does not yet handle rewriting the URL for the PAC resolver.
BUG=42666
Review URL: http://codereview.chromium.org/1699023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_network_transaction.cc | 33 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 22 |
2 files changed, 26 insertions, 29 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index f10a852..1514dc3 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -127,13 +127,14 @@ void BuildRequestHeaders(const HttpRequestInfo* request_info, // 5.3. void BuildTunnelRequest(const HttpRequestInfo* request_info, const HttpRequestHeaders& authorization_headers, + const HostPortPair& endpoint, std::string* request_line, HttpRequestHeaders* request_headers) { // RFC 2616 Section 9 says the Host request-header field MUST accompany all // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with // HTTP/1.0 proxies such as Squid (required for NTLM authentication). *request_line = StringPrintf( - "CONNECT %s HTTP/1.1\r\n", GetHostAndPort(request_info->url).c_str()); + "CONNECT %s HTTP/1.1\r\n", endpoint.ToString().c_str()); request_headers->SetHeader(HttpRequestHeaders::kHost, GetHostAndOptionalPort(request_info->url)); request_headers->SetHeader(HttpRequestHeaders::kProxyConnection, @@ -705,20 +706,18 @@ int HttpNetworkTransaction::DoInitConnection() { endpoint_ = HostPortPair(request_->url.HostNoBrackets(), request_->url.EffectiveIntPort()); - if (proxy_info_.is_direct()) { - if (alternate_protocol_mode_ == kUnspecified) { - const HttpAlternateProtocols& alternate_protocols = - session_->alternate_protocols(); - if (alternate_protocols.HasAlternateProtocolFor(endpoint_)) { - HttpAlternateProtocols::PortProtocolPair alternate = - alternate_protocols.GetAlternateProtocolFor(endpoint_); - if (alternate.protocol != HttpAlternateProtocols::BROKEN) { - DCHECK_EQ(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol); - endpoint_.port = alternate.port; - using_ssl_ = true; - alternate_protocol_ = HttpAlternateProtocols::NPN_SPDY_1; - alternate_protocol_mode_ = kUsingAlternateProtocol; - } + if (alternate_protocol_mode_ == kUnspecified) { + const HttpAlternateProtocols& alternate_protocols = + session_->alternate_protocols(); + if (alternate_protocols.HasAlternateProtocolFor(endpoint_)) { + HttpAlternateProtocols::PortProtocolPair alternate = + alternate_protocols.GetAlternateProtocolFor(endpoint_); + if (alternate.protocol != HttpAlternateProtocols::BROKEN) { + DCHECK_EQ(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol); + endpoint_.port = alternate.port; + using_ssl_ = true; + alternate_protocol_ = HttpAlternateProtocols::NPN_SPDY_1; + alternate_protocol_mode_ = kUsingAlternateProtocol; } } } @@ -961,8 +960,8 @@ int HttpNetworkTransaction::DoSendRequest() { AddAuthorizationHeader(HttpAuth::AUTH_SERVER, &authorization_headers); if (establishing_tunnel_) { - BuildTunnelRequest(request_, authorization_headers, &request_line, - &request_headers); + BuildTunnelRequest(request_, authorization_headers, endpoint_, + &request_line, &request_headers); } else { BuildRequestHeaders(request_, authorization_headers, request_body, !using_ssl_ && proxy_info_.is_http(), &request_line, diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 7d6db6f..1e01294 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -3805,12 +3805,11 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForHTTPProxyConnections) { "www.google.com:443", }, -// TODO(willchan): Uncomment these tests when they work. -// { -// "http_proxy", -// "http://host.with.alternate/direct", -// "proxy/http_proxy:80/host.with.alternate:443", -// }, + { + "http_proxy", + "http://host.with.alternate/direct", + "host.with.alternate:443", + }, }; HttpNetworkTransaction::SetUseAlternateProtocols(true); @@ -3860,12 +3859,11 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForSOCKSConnections) { "socks5/www.google.com:443", }, -// TODO(willchan): Uncomment these tests when they work. -// { -// "socks4://socks_proxy:1080", -// "http://host.with.alternate/direct", -// "proxy/socks4://socks_proxy:1080/host.with.alternate:443", -// }, + { + "socks4://socks_proxy:1080", + "http://host.with.alternate/direct", + "socks4/host.with.alternate:443", + }, }; HttpNetworkTransaction::SetUseAlternateProtocols(true); |