diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-03 19:52:09 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-03 19:52:09 +0000 |
commit | fe3b7dcbf673b546635034947e217011724861be (patch) | |
tree | 5698d44f161e81afe8764272f37c7c7de2bd7a4b /net/http/http_proxy_client_socket_pool.cc | |
parent | 86cd9471cfdcbe7d308630d0a9268108ca545f9d (diff) | |
download | chromium_src-fe3b7dcbf673b546635034947e217011724861be.zip chromium_src-fe3b7dcbf673b546635034947e217011724861be.tar.gz chromium_src-fe3b7dcbf673b546635034947e217011724861be.tar.bz2 |
Revert 118950 - Allow chrome to handle 407 auth challenges to CONNECT requests
through HTTPS Proxies. This also changes the mechanism used
to restart HttpProxyClientSocket requests with auth. Previously
the transport socket would be Disconnected, and then re-Connected
(which was not implemented for SSLClientSockets). However, the
approach was problematic in the face of, for example, ipv6. The
new approach is to close the HttpProxyClientSocket, and request
a new socket from the pool.
Initially was http://codereview.chromium.org/8502024
which turned out to have problems with NTLM auth.
Review URL: http://codereview.chromium.org/9148011
TBR=rch@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9316101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_proxy_client_socket_pool.cc')
-rw-r--r-- | net/http/http_proxy_client_socket_pool.cc | 87 |
1 files changed, 8 insertions, 79 deletions
diff --git a/net/http/http_proxy_client_socket_pool.cc b/net/http/http_proxy_client_socket_pool.cc index 7e2d168..7a51717 100644 --- a/net/http/http_proxy_client_socket_pool.cc +++ b/net/http/http_proxy_client_socket_pool.cc @@ -28,15 +28,6 @@ namespace net { -namespace { - -std::string GetProxyUrl(const scoped_refptr<HttpProxySocketParams>& params) { - return (params->ssl_params() != NULL ? "https://" : "http://") - + params->destination().host_port_pair().ToString(); -} - -} // namespace - HttpProxySocketParams::HttpProxySocketParams( const scoped_refptr<TransportSocketParams>& transport_params, const scoped_refptr<SSLSocketParams>& ssl_params, @@ -46,8 +37,7 @@ HttpProxySocketParams::HttpProxySocketParams( HttpAuthCache* http_auth_cache, HttpAuthHandlerFactory* http_auth_handler_factory, SpdySessionPool* spdy_session_pool, - bool tunnel, - TunnelAuthCallback auth_needed_callback) + bool tunnel) : transport_params_(transport_params), ssl_params_(ssl_params), spdy_session_pool_(spdy_session_pool), @@ -56,8 +46,7 @@ HttpProxySocketParams::HttpProxySocketParams( endpoint_(endpoint), http_auth_cache_(tunnel ? http_auth_cache : NULL), http_auth_handler_factory_(tunnel ? http_auth_handler_factory : NULL), - tunnel_(tunnel), - auth_needed_callback_(auth_needed_callback) { + tunnel_(tunnel) { DCHECK((transport_params == NULL && ssl_params != NULL) || (transport_params != NULL && ssl_params == NULL)); if (transport_params_) @@ -98,14 +87,7 @@ HttpProxyConnectJob::HttpProxyConnectJob( callback_(base::Bind(&HttpProxyConnectJob::OnIOComplete, base::Unretained(this)))), using_spdy_(false), - protocol_negotiated_(SSLClientSocket::kProtoUnknown), - auth_(params->tunnel() ? - new HttpAuthController(HttpAuth::AUTH_PROXY, - GURL(GetProxyUrl(params_)), - params->http_auth_cache(), - params->http_auth_handler_factory()) - : NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) { + protocol_negotiated_(SSLClientSocket::kProtoUnknown) { } HttpProxyConnectJob::~HttpProxyConnectJob() {} @@ -121,8 +103,6 @@ LoadState HttpProxyConnectJob::GetLoadState() const { case STATE_HTTP_PROXY_CONNECT_COMPLETE: case STATE_SPDY_PROXY_CREATE_STREAM: case STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE: - case STATE_RESTART_WITH_AUTH: - case STATE_RESTART_WITH_AUTH_COMPLETE: return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; default: NOTREACHED(); @@ -179,13 +159,6 @@ int HttpProxyConnectJob::DoLoop(int result) { case STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE: rv = DoSpdyProxyCreateStreamComplete(rv); break; - case STATE_RESTART_WITH_AUTH: - DCHECK_EQ(OK, rv); - rv = DoRestartWithAuth(); - break; - case STATE_RESTART_WITH_AUTH_COMPLETE: - rv = DoRestartWithAuthComplete(rv); - break; default: NOTREACHED() << "bad state"; rv = ERR_FAILED; @@ -293,7 +266,8 @@ int HttpProxyConnectJob::DoHttpProxyConnect() { params_->user_agent(), params_->endpoint(), proxy_server, - auth_, + params_->http_auth_cache(), + params_->http_auth_handler_factory(), params_->tunnel(), using_spdy_, protocol_negotiated_, @@ -301,54 +275,8 @@ int HttpProxyConnectJob::DoHttpProxyConnect() { return transport_socket_->Connect(callback_); } -void HttpProxyConnectJob::HandleProxyAuthChallenge() { - next_state_ = STATE_RESTART_WITH_AUTH; - params_->auth_needed_callback().Run( - *transport_socket_->GetConnectResponseInfo(), - transport_socket_->GetAuthController(), - callback_); -} - -int HttpProxyConnectJob::DoRestartWithAuth() { - // If no auth was added to the controller, then we should abort. - next_state_ = STATE_RESTART_WITH_AUTH_COMPLETE; - if (!transport_socket_->GetAuthController()->HaveAuth()) { - return ERR_PROXY_AUTH_REQUESTED; - } - - return transport_socket_->RestartWithAuth(callback_); -} - -int HttpProxyConnectJob::DoRestartWithAuthComplete(int result) { - if (result != OK) { - if (result == ERR_NO_KEEP_ALIVE_ON_AUTH_RESTART) { - next_state_ = params_->transport_params() ? - STATE_TCP_CONNECT : STATE_SSL_CONNECT; - return OK; - } - if (result == ERR_PROXY_AUTH_REQUESTED || - result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { - set_socket(transport_socket_.release()); - } - return result; - } - - next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; - return OK; -} - int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { - // Handle a proxy auth challenge by asynchronously invoking the callback. - // We do this asynchronously so that the caller is notified of job - // completion only via NotifyDelegateOfCompletion. - if (result == ERR_PROXY_AUTH_REQUESTED) { - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&HttpProxyConnectJob::HandleProxyAuthChallenge, - ptr_factory_.GetWeakPtr())); - return ERR_IO_PENDING; - } - if (result == OK || + if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { set_socket(transport_socket_.release()); } @@ -398,7 +326,8 @@ int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { params_->endpoint(), params_->request_url(), params_->destination().host_port_pair(), - auth_)); + params_->http_auth_cache(), + params_->http_auth_handler_factory())); return transport_socket_->Connect(callback_); } |