summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrch <rch@chromium.org>2015-04-07 13:53:54 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-07 20:54:31 +0000
commitecd3c554712ec96b5cfb3e43c714620b2bb74814 (patch)
tree95cc65eeb086a7e05a20f3b2926c043cf89bf621
parent9244d4429f05c60266d2e527996cde78f90dc0dc (diff)
downloadchromium_src-ecd3c554712ec96b5cfb3e43c714620b2bb74814.zip
chromium_src-ecd3c554712ec96b5cfb3e43c714620b2bb74814.tar.gz
chromium_src-ecd3c554712ec96b5cfb3e43c714620b2bb74814.tar.bz2
Remove the confusing request_url argument from the constructors
of HttpProxyClientSocket and SpdyProxyClientSocket. Instead, contruct a "URL" from the endpoint used in the CONNECT request. Review URL: https://codereview.chromium.org/1060883002 Cr-Commit-Position: refs/heads/master@{#324113}
-rw-r--r--net/http/http_proxy_client_socket.cc5
-rw-r--r--net/http/http_proxy_client_socket.h3
-rw-r--r--net/http/http_proxy_client_socket_pool.cc14
-rw-r--r--net/http/http_proxy_client_socket_pool.h3
-rw-r--r--net/http/http_proxy_client_socket_pool_unittest.cc1
-rw-r--r--net/socket/client_socket_pool_manager.cc1
-rw-r--r--net/socket/ssl_client_socket_pool_unittest.cc1
-rw-r--r--net/spdy/spdy_proxy_client_socket.cc24
-rw-r--r--net/spdy/spdy_proxy_client_socket.h6
-rw-r--r--net/spdy/spdy_proxy_client_socket_unittest.cc10
10 files changed, 18 insertions, 50 deletions
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
index bc970b5..2eec09c 100644
--- a/net/http/http_proxy_client_socket.cc
+++ b/net/http/http_proxy_client_socket.cc
@@ -28,7 +28,6 @@ namespace net {
HttpProxyClientSocket::HttpProxyClientSocket(
ClientSocketHandle* transport_socket,
- const GURL& request_url,
const std::string& user_agent,
const HostPortPair& endpoint,
const HostPortPair& proxy_server,
@@ -60,8 +59,8 @@ HttpProxyClientSocket::HttpProxyClientSocket(
proxy_delegate_(proxy_delegate),
net_log_(transport_socket->socket()->NetLog()) {
// Synthesize the bits of a request that we actually use.
- request_.url = request_url;
- request_.method = "GET";
+ request_.url = GURL("https://" + endpoint.ToString());
+ request_.method = "CONNECT";
if (!user_agent.empty())
request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
user_agent);
diff --git a/net/http/http_proxy_client_socket.h b/net/http/http_proxy_client_socket.h
index bdd79e0..cc82c57 100644
--- a/net/http/http_proxy_client_socket.h
+++ b/net/http/http_proxy_client_socket.h
@@ -20,8 +20,6 @@
#include "net/log/net_log.h"
#include "net/socket/ssl_client_socket.h"
-class GURL;
-
namespace net {
class AddressList;
@@ -39,7 +37,6 @@ class HttpProxyClientSocket : public ProxyClientSocket {
// by the time Connect() is called. If tunnel is true then on Connect()
// this socket will establish an Http tunnel.
HttpProxyClientSocket(ClientSocketHandle* transport_socket,
- const GURL& request_url,
const std::string& user_agent,
const HostPortPair& endpoint,
const HostPortPair& proxy_server,
diff --git a/net/http/http_proxy_client_socket_pool.cc b/net/http/http_proxy_client_socket_pool.cc
index a861ca4..17e9f06 100644
--- a/net/http/http_proxy_client_socket_pool.cc
+++ b/net/http/http_proxy_client_socket_pool.cc
@@ -32,7 +32,6 @@ namespace net {
HttpProxySocketParams::HttpProxySocketParams(
const scoped_refptr<TransportSocketParams>& transport_params,
const scoped_refptr<SSLSocketParams>& ssl_params,
- const GURL& request_url,
const std::string& user_agent,
const HostPortPair& endpoint,
HttpAuthCache* http_auth_cache,
@@ -43,7 +42,6 @@ HttpProxySocketParams::HttpProxySocketParams(
: transport_params_(transport_params),
ssl_params_(ssl_params),
spdy_session_pool_(spdy_session_pool),
- request_url_(request_url),
user_agent_(user_agent),
endpoint_(endpoint),
http_auth_cache_(tunnel ? http_auth_cache : NULL),
@@ -286,7 +284,6 @@ int HttpProxyConnectJob::DoHttpProxyConnect() {
// Add a HttpProxy connection on top of the tcp socket.
transport_socket_.reset(
new HttpProxyClientSocket(transport_socket_handle_.release(),
- params_->request_url(),
params_->user_agent(),
params_->endpoint(),
proxy_server,
@@ -338,12 +335,10 @@ int HttpProxyConnectJob::DoSpdyProxyCreateStream() {
}
next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE;
- return spdy_stream_request_.StartRequest(SPDY_BIDIRECTIONAL_STREAM,
- spdy_session,
- params_->request_url(),
- priority(),
- spdy_session->net_log(),
- callback_);
+ return spdy_stream_request_.StartRequest(
+ SPDY_BIDIRECTIONAL_STREAM, spdy_session,
+ GURL("https://" + params_->endpoint().ToString()), priority(),
+ spdy_session->net_log(), callback_);
}
int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) {
@@ -358,7 +353,6 @@ int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) {
new SpdyProxyClientSocket(stream,
params_->user_agent(),
params_->endpoint(),
- params_->request_url(),
params_->destination().host_port_pair(),
net_log(),
params_->http_auth_cache(),
diff --git a/net/http/http_proxy_client_socket_pool.h b/net/http/http_proxy_client_socket_pool.h
index 824b15f..a0450fb 100644
--- a/net/http/http_proxy_client_socket_pool.h
+++ b/net/http/http_proxy_client_socket_pool.h
@@ -44,7 +44,6 @@ class NET_EXPORT_PRIVATE HttpProxySocketParams
HttpProxySocketParams(
const scoped_refptr<TransportSocketParams>& transport_params,
const scoped_refptr<SSLSocketParams>& ssl_params,
- const GURL& request_url,
const std::string& user_agent,
const HostPortPair& endpoint,
HttpAuthCache* http_auth_cache,
@@ -59,7 +58,6 @@ class NET_EXPORT_PRIVATE HttpProxySocketParams
const scoped_refptr<SSLSocketParams>& ssl_params() const {
return ssl_params_;
}
- const GURL& request_url() const { return request_url_; }
const std::string& user_agent() const { return user_agent_; }
const HostPortPair& endpoint() const { return endpoint_; }
HttpAuthCache* http_auth_cache() const { return http_auth_cache_; }
@@ -84,7 +82,6 @@ class NET_EXPORT_PRIVATE HttpProxySocketParams
const scoped_refptr<TransportSocketParams> transport_params_;
const scoped_refptr<SSLSocketParams> ssl_params_;
SpdySessionPool* spdy_session_pool_;
- const GURL request_url_;
const std::string user_agent_;
const HostPortPair endpoint_;
HttpAuthCache* const http_auth_cache_;
diff --git a/net/http/http_proxy_client_socket_pool_unittest.cc b/net/http/http_proxy_client_socket_pool_unittest.cc
index 7d1e432..c717bc3 100644
--- a/net/http/http_proxy_client_socket_pool_unittest.cc
+++ b/net/http/http_proxy_client_socket_pool_unittest.cc
@@ -237,7 +237,6 @@ class HttpProxyClientSocketPoolTest
return scoped_refptr<HttpProxySocketParams>(new HttpProxySocketParams(
CreateHttpProxyParams(),
CreateHttpsProxyParams(),
- GURL(tunnel ? "https://www.google.com/" : "http://www.google.com"),
std::string(),
HostPortPair("www.google.com", tunnel ? 443 : 80),
session_->http_auth_cache(),
diff --git a/net/socket/client_socket_pool_manager.cc b/net/socket/client_socket_pool_manager.cc
index 0f652d1..94cfad4 100644
--- a/net/socket/client_socket_pool_manager.cc
+++ b/net/socket/client_socket_pool_manager.cc
@@ -202,7 +202,6 @@ int InitSocketPoolHelper(const GURL& request_url,
http_proxy_params =
new HttpProxySocketParams(proxy_tcp_params,
ssl_params,
- request_url,
user_agent,
origin_host_port,
session->http_auth_cache(),
diff --git a/net/socket/ssl_client_socket_pool_unittest.cc b/net/socket/ssl_client_socket_pool_unittest.cc
index e06c3bf..9370352 100644
--- a/net/socket/ssl_client_socket_pool_unittest.cc
+++ b/net/socket/ssl_client_socket_pool_unittest.cc
@@ -109,7 +109,6 @@ class SSLClientSocketPoolTest
http_proxy_socket_params_(
new HttpProxySocketParams(proxy_transport_socket_params_,
NULL,
- GURL("http://host"),
std::string(),
HostPortPair("host", 80),
session_->http_auth_cache(),
diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc
index 9bae609..3e1feab 100644
--- a/net/spdy/spdy_proxy_client_socket.cc
+++ b/net/spdy/spdy_proxy_client_socket.cc
@@ -28,7 +28,6 @@ SpdyProxyClientSocket::SpdyProxyClientSocket(
const base::WeakPtr<SpdyStream>& spdy_stream,
const std::string& user_agent,
const HostPortPair& endpoint,
- const GURL& url,
const HostPortPair& proxy_server,
const BoundNetLog& source_net_log,
HttpAuthCache* auth_cache,
@@ -40,6 +39,7 @@ SpdyProxyClientSocket::SpdyProxyClientSocket(
GURL("https://" + proxy_server.ToString()),
auth_cache,
auth_handler_factory)),
+ user_agent_(user_agent),
user_buffer_len_(0),
write_buffer_len_(0),
was_ever_used_(false),
@@ -49,11 +49,7 @@ SpdyProxyClientSocket::SpdyProxyClientSocket(
weak_factory_(this),
write_callback_weak_factory_(this) {
request_.method = "CONNECT";
- request_.url = url;
- if (!user_agent.empty())
- request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
- user_agent);
-
+ request_.url = GURL("https://" + endpoint.ToString());
net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE,
source_net_log.source().ToEventParametersCallback());
net_log_.AddEvent(
@@ -353,25 +349,17 @@ int SpdyProxyClientSocket::DoSendRequest() {
auth_->AddAuthorizationHeader(&authorization_headers);
}
- std::string user_agent;
- if (!request_.extra_headers.GetHeader(HttpRequestHeaders::kUserAgent,
- &user_agent)) {
- user_agent.clear();
- }
std::string request_line;
- HttpRequestHeaders request_headers;
- BuildTunnelRequest(endpoint_, authorization_headers, user_agent,
- &request_line, &request_headers);
+ BuildTunnelRequest(endpoint_, authorization_headers, user_agent_,
+ &request_line, &request_.extra_headers);
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
base::Bind(&HttpRequestHeaders::NetLogCallback,
- base::Unretained(&request_headers),
- &request_line));
+ base::Unretained(&request_.extra_headers), &request_line));
- request_.extra_headers.MergeFrom(request_headers);
scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock());
- CreateSpdyHeadersFromHttpRequest(request_, request_headers,
+ CreateSpdyHeadersFromHttpRequest(request_, request_.extra_headers,
spdy_stream_->GetProtocolVersion(), true,
headers.get());
// Reset the URL to be the endpoint of the connection
diff --git a/net/spdy/spdy_proxy_client_socket.h b/net/spdy/spdy_proxy_client_socket.h
index 43dd4b3..371182a 100644
--- a/net/spdy/spdy_proxy_client_socket.h
+++ b/net/spdy/spdy_proxy_client_socket.h
@@ -26,9 +26,6 @@
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_stream.h"
-
-class GURL;
-
namespace net {
class AddressList;
@@ -46,7 +43,6 @@ class NET_EXPORT_PRIVATE SpdyProxyClientSocket : public ProxyClientSocket,
SpdyProxyClientSocket(const base::WeakPtr<SpdyStream>& spdy_stream,
const std::string& user_agent,
const HostPortPair& endpoint,
- const GURL& url,
const HostPortPair& proxy_server,
const BoundNetLog& source_net_log,
HttpAuthCache* auth_cache,
@@ -149,6 +145,8 @@ class NET_EXPORT_PRIVATE SpdyProxyClientSocket : public ProxyClientSocket,
const HostPortPair endpoint_;
scoped_refptr<HttpAuthController> auth_;
+ std::string user_agent_;
+
// We buffer the response body as it arrives asynchronously from the stream.
SpdyReadQueue read_buffer_queue_;
diff --git a/net/spdy/spdy_proxy_client_socket_unittest.cc b/net/spdy/spdy_proxy_client_socket_unittest.cc
index 4248f13..c870f18 100644
--- a/net/spdy/spdy_proxy_client_socket_unittest.cc
+++ b/net/spdy/spdy_proxy_client_socket_unittest.cc
@@ -199,12 +199,10 @@ void SpdyProxyClientSocketTest::Initialize(MockRead* reads,
ASSERT_TRUE(spdy_stream.get() != NULL);
// Create the SpdyProxyClientSocket.
- sock_.reset(
- new SpdyProxyClientSocket(spdy_stream, user_agent_,
- endpoint_host_port_pair_, url_,
- proxy_host_port_, net_log_.bound(),
- session_->http_auth_cache(),
- session_->http_auth_handler_factory()));
+ sock_.reset(new SpdyProxyClientSocket(
+ spdy_stream, user_agent_, endpoint_host_port_pair_, proxy_host_port_,
+ net_log_.bound(), session_->http_auth_cache(),
+ session_->http_auth_handler_factory()));
}
scoped_refptr<IOBufferWithSize> SpdyProxyClientSocketTest::CreateBuffer(