summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 19:22:04 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 19:22:04 +0000
commitca9fee9cdc7af6d3ef042d6e9a22a987c0f5d9e6 (patch)
treea6c28887d1a5435618f947405a3c876111d16b1f /net
parent307f93b1bde1ccb3ff3206a597416f6924d9273d (diff)
downloadchromium_src-ca9fee9cdc7af6d3ef042d6e9a22a987c0f5d9e6.zip
chromium_src-ca9fee9cdc7af6d3ef042d6e9a22a987c0f5d9e6.tar.gz
chromium_src-ca9fee9cdc7af6d3ef042d6e9a22a987c0f5d9e6.tar.bz2
Fix --host-rules command switch.
BUG=78233 TEST=HostRulesTest.TestMap Review URL: http://codereview.chromium.org/7024017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88568 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_stream_factory_impl_job.cc52
-rw-r--r--net/http/http_stream_factory_impl_job.h4
-rw-r--r--net/socket/client_socket_pool_manager.cc94
-rw-r--r--net/socket/client_socket_pool_manager.h16
4 files changed, 121 insertions, 45 deletions
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index 1efd1cc..254792f 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -30,9 +30,32 @@
namespace net {
-namespace {
+// Parameters associated with the start of a HTTP stream job.
+class HttpStreamJobParameters : public NetLog::EventParameters {
+ public:
+ static scoped_refptr<HttpStreamJobParameters> Create(
+ const GURL& original_url,
+ const GURL& url) {
+ return make_scoped_refptr(new HttpStreamJobParameters(original_url, url));
+ }
+
+ virtual Value* ToValue() const;
+
+ private:
+ HttpStreamJobParameters(const GURL& original_url, const GURL& url)
+ : original_url_(original_url.GetOrigin().spec()),
+ url_(url.GetOrigin().spec()) {}
-} // namespace
+ const std::string original_url_;
+ const std::string url_;
+};
+
+Value* HttpStreamJobParameters::ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetString("original_url", original_url_);
+ dict->SetString("url", url_);
+ return dict;
+}
HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory,
HttpNetworkSession* session,
@@ -440,9 +463,15 @@ int HttpStreamFactoryImpl::Job::DoLoop(int result) {
int HttpStreamFactoryImpl::Job::StartInternal() {
CHECK_EQ(STATE_NONE, next_state_);
+
+ origin_ = HostPortPair(request_info_.url.HostNoBrackets(),
+ request_info_.url.EffectiveIntPort());
+ origin_url_ = HttpStreamFactory::ApplyHostMappingRules(
+ request_info_.url, &origin_);
+
net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB,
- make_scoped_refptr(new NetLogStringParameter(
- "url", request_info_.url.GetOrigin().spec())));
+ HttpStreamJobParameters::Create(request_info_.url,
+ origin_url_));
next_state_ = STATE_RESOLVE_PROXY;
int rv = RunLoop(OK);
DCHECK_EQ(ERR_IO_PENDING, rv);
@@ -454,9 +483,6 @@ int HttpStreamFactoryImpl::Job::DoResolveProxy() {
next_state_ = STATE_RESOLVE_PROXY_COMPLETE;
- origin_ = HostPortPair(request_info_.url.HostNoBrackets(),
- request_info_.url.EffectiveIntPort());
-
if (request_info_.load_flags & LOAD_BYPASS_PROXY) {
proxy_info_.UseDirect();
return OK;
@@ -576,7 +602,11 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
if (IsPreconnecting()) {
return ClientSocketPoolManager::PreconnectSocketsForHttpRequest(
- request_info_,
+ origin_url_,
+ request_info_.referrer,
+ request_info_.extra_headers,
+ request_info_.load_flags,
+ request_info_.priority,
session_,
proxy_info_,
ShouldForceSpdySSL(),
@@ -587,7 +617,11 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
num_streams_);
} else {
return ClientSocketPoolManager::InitSocketHandleForHttpRequest(
- request_info_,
+ origin_url_,
+ request_info_.referrer,
+ request_info_.extra_headers,
+ request_info_.load_flags,
+ request_info_.priority,
session_,
proxy_info_,
ShouldForceSpdySSL(),
diff --git a/net/http/http_stream_factory_impl_job.h b/net/http/http_stream_factory_impl_job.h
index a12d108..8b2ba95 100644
--- a/net/http/http_stream_factory_impl_job.h
+++ b/net/http/http_stream_factory_impl_job.h
@@ -217,6 +217,10 @@ class HttpStreamFactoryImpl::Job {
// The origin server we're trying to reach.
HostPortPair origin_;
+ // The origin url we're trying to reach. This url may be different from the
+ // original request when host mapping rules are set-up.
+ GURL origin_url_;
+
// If this is a Job for an "Alternate-Protocol", then this will be non-NULL
// and will specify the original URL.
scoped_ptr<GURL> original_url_;
diff --git a/net/socket/client_socket_pool_manager.cc b/net/socket/client_socket_pool_manager.cc
index 7277b37..357d6c5 100644
--- a/net/socket/client_socket_pool_manager.cc
+++ b/net/socket/client_socket_pool_manager.cc
@@ -58,7 +58,11 @@ static void AddSocketPoolsToList(ListValue* list,
// The meat of the implementation for the InitSocketHandleForHttpRequest,
// InitSocketHandleForRawConnect and PreconnectSocketsForHttpRequest methods.
-int InitSocketPoolHelper(const HttpRequestInfo& request_info,
+int InitSocketPoolHelper(const GURL& request_url,
+ const GURL& request_referrer,
+ const HttpRequestHeaders& request_extra_headers,
+ int request_load_flags,
+ RequestPriority request_priority,
HttpNetworkSession* session,
const ProxyInfo& proxy_info,
bool force_spdy_over_ssl,
@@ -75,18 +79,18 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
scoped_refptr<SOCKSSocketParams> socks_params;
scoped_ptr<HostPortPair> proxy_host_port;
- bool using_ssl = request_info.url.SchemeIs("https") || force_spdy_over_ssl;
+ bool using_ssl = request_url.SchemeIs("https") || force_spdy_over_ssl;
HostPortPair origin_host_port =
- HostPortPair(request_info.url.HostNoBrackets(),
- request_info.url.EffectiveIntPort());
+ HostPortPair(request_url.HostNoBrackets(),
+ request_url.EffectiveIntPort());
bool disable_resolver_cache =
- request_info.load_flags & LOAD_BYPASS_CACHE ||
- request_info.load_flags & LOAD_VALIDATE_CACHE ||
- request_info.load_flags & LOAD_DISABLE_CACHE;
+ request_load_flags & LOAD_BYPASS_CACHE ||
+ request_load_flags & LOAD_VALIDATE_CACHE ||
+ request_load_flags & LOAD_DISABLE_CACHE;
- int load_flags = request_info.load_flags;
+ int load_flags = request_load_flags;
if (HttpStreamFactory::ignore_certificate_errors())
load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS;
@@ -97,27 +101,27 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
if (using_ssl)
connection_group = base::StringPrintf("ssl/%s", connection_group.c_str());
- bool ignore_limits = (request_info.load_flags & LOAD_IGNORE_LIMITS) != 0;
+ bool ignore_limits = (request_load_flags & LOAD_IGNORE_LIMITS) != 0;
if (proxy_info.is_direct()) {
tcp_params = new TransportSocketParams(origin_host_port,
- request_info.priority,
- request_info.referrer,
- disable_resolver_cache,
- ignore_limits);
+ request_priority,
+ request_referrer,
+ disable_resolver_cache,
+ ignore_limits);
} else {
ProxyServer proxy_server = proxy_info.proxy_server();
proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair()));
scoped_refptr<TransportSocketParams> proxy_tcp_params(
new TransportSocketParams(*proxy_host_port,
- request_info.priority,
- request_info.referrer,
- disable_resolver_cache,
- ignore_limits));
+ request_priority,
+ request_referrer,
+ disable_resolver_cache,
+ ignore_limits));
if (proxy_info.is_http() || proxy_info.is_https()) {
std::string user_agent;
- request_info.extra_headers.GetHeader(HttpRequestHeaders::kUserAgent,
- &user_agent);
+ request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent,
+ &user_agent);
scoped_refptr<SSLSocketParams> ssl_params;
if (proxy_info.is_https()) {
// Set ssl_params, and unset proxy_tcp_params
@@ -136,7 +140,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
http_proxy_params =
new HttpProxySocketParams(proxy_tcp_params,
ssl_params,
- request_info.url,
+ request_url,
user_agent,
origin_host_port,
session->http_auth_cache(),
@@ -156,8 +160,8 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
socks_params = new SOCKSSocketParams(proxy_tcp_params,
socks_version == '5',
origin_host_port,
- request_info.priority,
- request_info.referrer);
+ request_priority,
+ request_referrer);
}
}
@@ -186,7 +190,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
}
return socket_handle->Init(connection_group, ssl_params,
- request_info.priority, callback, ssl_pool,
+ request_priority, callback, ssl_pool,
net_log);
}
@@ -201,7 +205,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
}
return socket_handle->Init(connection_group, http_proxy_params,
- request_info.priority, callback,
+ request_priority, callback,
pool, net_log);
}
@@ -215,7 +219,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
}
return socket_handle->Init(connection_group, socks_params,
- request_info.priority, callback, pool,
+ request_priority, callback, pool,
net_log);
}
@@ -229,7 +233,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info,
}
return socket_handle->Init(connection_group, tcp_params,
- request_info.priority, callback,
+ request_priority, callback,
pool, net_log);
}
@@ -601,7 +605,11 @@ void ClientSocketPoolManager::OnCertTrustChanged(const X509Certificate* cert) {
// static
int ClientSocketPoolManager::InitSocketHandleForHttpRequest(
- const HttpRequestInfo& request_info,
+ const GURL& request_url,
+ const GURL& request_referrer,
+ const HttpRequestHeaders& request_extra_headers,
+ int request_load_flags,
+ RequestPriority request_priority,
HttpNetworkSession* session,
const ProxyInfo& proxy_info,
bool force_spdy_over_ssl,
@@ -612,7 +620,11 @@ int ClientSocketPoolManager::InitSocketHandleForHttpRequest(
ClientSocketHandle* socket_handle,
CompletionCallback* callback) {
DCHECK(socket_handle);
- return InitSocketPoolHelper(request_info,
+ return InitSocketPoolHelper(request_url,
+ request_referrer,
+ request_extra_headers,
+ request_load_flags,
+ request_priority,
session,
proxy_info,
force_spdy_over_ssl,
@@ -638,9 +650,17 @@ int ClientSocketPoolManager::InitSocketHandleForRawConnect(
CompletionCallback* callback) {
DCHECK(socket_handle);
// Synthesize an HttpRequestInfo.
- HttpRequestInfo request_info;
- request_info.url = GURL("http://" + host_port_pair.ToString());
- return InitSocketPoolHelper(request_info,
+ GURL request_url = GURL("http://" + host_port_pair.ToString());
+ GURL request_referrer;
+ HttpRequestHeaders request_extra_headers;
+ int request_load_flags = 0;
+ RequestPriority request_priority = MEDIUM;
+
+ return InitSocketPoolHelper(request_url,
+ request_referrer,
+ request_extra_headers,
+ request_load_flags,
+ request_priority,
session,
proxy_info,
false,
@@ -656,7 +676,11 @@ int ClientSocketPoolManager::InitSocketHandleForRawConnect(
// static
int ClientSocketPoolManager::PreconnectSocketsForHttpRequest(
- const HttpRequestInfo& request_info,
+ const GURL& request_url,
+ const GURL& request_referrer,
+ const HttpRequestHeaders& request_extra_headers,
+ int request_load_flags,
+ RequestPriority request_priority,
HttpNetworkSession* session,
const ProxyInfo& proxy_info,
bool force_spdy_over_ssl,
@@ -665,7 +689,11 @@ int ClientSocketPoolManager::PreconnectSocketsForHttpRequest(
const SSLConfig& ssl_config_for_proxy,
const BoundNetLog& net_log,
int num_preconnect_streams) {
- return InitSocketPoolHelper(request_info,
+ return InitSocketPoolHelper(request_url,
+ request_referrer,
+ request_extra_headers,
+ request_load_flags,
+ request_priority,
session,
proxy_info,
force_spdy_over_ssl,
diff --git a/net/socket/client_socket_pool_manager.h b/net/socket/client_socket_pool_manager.h
index 74118d88..9d42672 100644
--- a/net/socket/client_socket_pool_manager.h
+++ b/net/socket/client_socket_pool_manager.h
@@ -20,8 +20,10 @@
#include "net/base/cert_database.h"
#include "net/base/completion_callback.h"
#include "net/base/net_api.h"
+#include "net/base/request_priority.h"
#include "net/socket/client_socket_pool_histograms.h"
+class GURL;
class Value;
namespace net {
@@ -34,6 +36,7 @@ class ClientSocketPoolHistograms;
class DnsCertProvenanceChecker;
class DnsRRResolver;
class HttpNetworkSession;
+class HttpRequestHeaders;
class HostPortPair;
class HttpProxyClientSocketPool;
class HostResolver;
@@ -46,7 +49,6 @@ class SSLConfigService;
class SSLHostInfoFactory;
class TransportClientSocketPool;
-struct HttpRequestInfo;
struct SSLConfig;
namespace internal {
@@ -108,7 +110,11 @@ class ClientSocketPoolManager : public base::NonThreadSafe,
// HTTP/HTTPS requests. |ssl_config_for_origin| is only used if the request
// uses SSL and |ssl_config_for_proxy| is used if the proxy server is HTTPS.
static int InitSocketHandleForHttpRequest(
- const HttpRequestInfo& request_info,
+ const GURL& request_url,
+ const GURL& request_referrer,
+ const HttpRequestHeaders& request_extra_headers,
+ int request_load_flags,
+ RequestPriority request_priority,
HttpNetworkSession* session,
const ProxyInfo& proxy_info,
bool force_spdy_over_ssl,
@@ -136,7 +142,11 @@ class ClientSocketPoolManager : public base::NonThreadSafe,
// Similar to InitSocketHandleForHttpRequest except that it initiates the
// desired number of preconnect streams from the relevant socket pool.
static int PreconnectSocketsForHttpRequest(
- const HttpRequestInfo& request_info,
+ const GURL& request_url,
+ const GURL& request_referrer,
+ const HttpRequestHeaders& request_extra_headers,
+ int request_load_flags,
+ RequestPriority request_priority,
HttpNetworkSession* session,
const ProxyInfo& proxy_info,
bool force_spdy_over_ssl,