diff options
author | Adam Rice <ricea@chromium.org> | 2015-01-19 15:18:24 +0900 |
---|---|---|
committer | Adam Rice <ricea@chromium.org> | 2015-01-19 06:19:09 +0000 |
commit | 425cf12869fd826d1fceeb5071d3747e88406e6b (patch) | |
tree | e2b5714e6a13c8c21e3f8adc31f4ad96f76a6307 /net/http/http_network_transaction.cc | |
parent | ab3090304649f96826175fc6a553fd0b6793bd5d (diff) | |
download | chromium_src-425cf12869fd826d1fceeb5071d3747e88406e6b.zip chromium_src-425cf12869fd826d1fceeb5071d3747e88406e6b.tar.gz chromium_src-425cf12869fd826d1fceeb5071d3747e88406e6b.tar.bz2 |
Fix the logic for using an HTTP proxy without a tunnel
The logic for determining whether HttpNetworkTransaction was using an HTTP proxy but not tunneled was incorrect for the case of WebSockets. Fix it.
BUG=446459
TEST=net_unittests
R=mmenke@chromium.org, tyoshino@chromium.org
Review URL: https://codereview.chromium.org/836993002
Cr-Commit-Position: refs/heads/master@{#312073}
Diffstat (limited to 'net/http/http_network_transaction.cc')
-rw-r--r-- | net/http/http_network_transaction.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 97fc7db..8f33e20 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -570,6 +570,11 @@ bool HttpNetworkTransaction::is_https_request() const { return request_->url.SchemeIs("https"); } +bool HttpNetworkTransaction::UsingHttpProxyWithoutTunnel() const { + return (proxy_info_.is_http() || proxy_info_.is_https()) && + !(request_->url.SchemeIs("https") || request_->url.SchemeIsWSOrWSS()); +} + void HttpNetworkTransaction::DoCallback(int rv) { DCHECK_NE(rv, ERR_IO_PENDING); DCHECK(!callback_.is_null()); @@ -834,12 +839,13 @@ int HttpNetworkTransaction::DoGenerateServerAuthTokenComplete(int rv) { return rv; } -void HttpNetworkTransaction::BuildRequestHeaders(bool using_proxy) { +void HttpNetworkTransaction::BuildRequestHeaders( + bool using_http_proxy_without_tunnel) { request_headers_.SetHeader(HttpRequestHeaders::kHost, GetHostAndOptionalPort(request_->url)); // For compat with HTTP/1.0 servers and proxies: - if (using_proxy) { + if (using_http_proxy_without_tunnel) { request_headers_.SetHeader(HttpRequestHeaders::kProxyConnection, "keep-alive"); } else { @@ -882,7 +888,8 @@ void HttpNetworkTransaction::BuildRequestHeaders(bool using_proxy) { request_headers_.MergeFrom(request_->extra_headers); - if (using_proxy && !before_proxy_headers_sent_callback_.is_null()) + if (using_http_proxy_without_tunnel && + !before_proxy_headers_sent_callback_.is_null()) before_proxy_headers_sent_callback_.Run(proxy_info_, &request_headers_); response_.did_use_http_auth = @@ -911,9 +918,8 @@ int HttpNetworkTransaction::DoBuildRequest() { // This is constructed lazily (instead of within our Start method), so that // we have proxy info available. if (request_headers_.IsEmpty()) { - bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && - !is_https_request(); - BuildRequestHeaders(using_proxy); + bool using_http_proxy_without_tunnel = UsingHttpProxyWithoutTunnel(); + BuildRequestHeaders(using_http_proxy_without_tunnel); } return OK; @@ -1417,8 +1423,7 @@ void HttpNetworkTransaction::ResetConnectionAndRequestForResend() { } bool HttpNetworkTransaction::ShouldApplyProxyAuth() const { - return !is_https_request() && - (proxy_info_.is_https() || proxy_info_.is_http()); + return UsingHttpProxyWithoutTunnel(); } bool HttpNetworkTransaction::ShouldApplyServerAuth() const { |