diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 19:39:56 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 19:39:56 +0000 |
commit | 28ed3b4d95b376634e1ef88a9299f5d2a2a9153a (patch) | |
tree | de2a70356c7455576dd483a9f459ffeb876ff69e /net | |
parent | c34cf767ba59da82ec7b1d377b31b64be4e6bcbd (diff) | |
download | chromium_src-28ed3b4d95b376634e1ef88a9299f5d2a2a9153a.zip chromium_src-28ed3b4d95b376634e1ef88a9299f5d2a2a9153a.tar.gz chromium_src-28ed3b4d95b376634e1ef88a9299f5d2a2a9153a.tar.bz2 |
Fix --host-rules to work properly with proxies.
Review URL: http://codereview.chromium.org/2073004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47178 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_network_transaction.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index c43f110..c58038c 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -739,10 +739,22 @@ int HttpNetworkTransaction::DoResolveProxy() { endpoint_ = HostPortPair(request_->url.HostNoBrackets(), request_->url.EffectiveIntPort()); - if (g_host_mapping_rules) - g_host_mapping_rules->RewriteHost(&endpoint_); + // Extra URL we might be attempting to resolve to. + GURL alternate_endpoint_url; + + // Tracks whether we are using |request_->url| or |alternate_endpoint_url|. + const GURL *curr_endpoint_url = &request_->url; - GURL alternate_endpoint; + if (g_host_mapping_rules && g_host_mapping_rules->RewriteHost(&endpoint_)) { + url_canon::Replacements<char> replacements; + const std::string port_str = IntToString(endpoint_.port); + replacements.SetPort(port_str.c_str(), + url_parse::Component(0, port_str.size())); + replacements.SetHost(endpoint_.host.c_str(), + url_parse::Component(0, endpoint_.host.size())); + alternate_endpoint_url = curr_endpoint_url->ReplaceComponents(replacements); + curr_endpoint_url = &alternate_endpoint_url; + } if (alternate_protocol_mode_ == kUnspecified) { const HttpAlternateProtocols& alternate_protocols = @@ -762,7 +774,9 @@ int HttpNetworkTransaction::DoResolveProxy() { const std::string port_str = IntToString(endpoint_.port); replacements.SetPort(port_str.c_str(), url_parse::Component(0, port_str.size())); - alternate_endpoint = request_->url.ReplaceComponents(replacements); + alternate_endpoint_url = + curr_endpoint_url->ReplaceComponents(replacements); + curr_endpoint_url = &alternate_endpoint_url; } } } @@ -773,9 +787,7 @@ int HttpNetworkTransaction::DoResolveProxy() { } return session_->proxy_service()->ResolveProxy( - alternate_protocol_mode_ == kUsingAlternateProtocol ? - alternate_endpoint : request_->url, - &proxy_info_, &io_callback_, &pac_request_, net_log_); + *curr_endpoint_url, &proxy_info_, &io_callback_, &pac_request_, net_log_); } int HttpNetworkTransaction::DoResolveProxyComplete(int result) { |