diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-17 03:58:29 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-17 03:58:29 +0000 |
commit | 511f6f525dacf2512439b12784186074a0f6cd5c (patch) | |
tree | 5fa90bbe0fa255de3d78d00dcffd333830e13aea /net/http/http_proxy_client_socket.cc | |
parent | 8aad42dcc8d683242c730901c51061de710046b9 (diff) | |
download | chromium_src-511f6f525dacf2512439b12784186074a0f6cd5c.zip chromium_src-511f6f525dacf2512439b12784186074a0f6cd5c.tar.gz chromium_src-511f6f525dacf2512439b12784186074a0f6cd5c.tar.bz2 |
Allow a non-200 (or non-407) response for a CONNECT request from an HTTPS proxy
to be consumed by chrome. Among other things, this will allow the proxy to
inform the user that the hostname could not be resolved or similar conditions.
This adds a new OnHttpsProxyTunnelConnectionResponse method to
StreamRequest::Delegate which is invoked when an HTTPS proxy returns a non-200,
non-407 response. The method is called with an HttpResponseInfor argument to
access the request headers, and an HttpStream argument to access the response body.
BUG=none
TEST=HttpNetworkTransactionTest
Review URL: http://codereview.chromium.org/4935001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69513 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_proxy_client_socket.cc')
-rw-r--r-- | net/http/http_proxy_client_socket.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc index c2c2899..2f44428 100644 --- a/net/http/http_proxy_client_socket.cc +++ b/net/http/http_proxy_client_socket.cc @@ -12,6 +12,7 @@ #include "net/base/io_buffer.h" #include "net/base/net_log.h" #include "net/base/net_util.h" +#include "net/http/http_basic_stream.h" #include "net/http/http_net_log_params.h" #include "net/http/http_network_session.h" #include "net/http/http_proxy_utils.h" @@ -31,7 +32,8 @@ HttpProxyClientSocket::HttpProxyClientSocket( HttpAuthCache* http_auth_cache, HttpAuthHandlerFactory* http_auth_handler_factory, bool tunnel, - bool using_spdy) + bool using_spdy, + bool is_https_proxy) : ALLOW_THIS_IN_INITIALIZER_LIST( io_callback_(this, &HttpProxyClientSocket::OnIOComplete)), next_state_(STATE_NONE), @@ -46,6 +48,7 @@ HttpProxyClientSocket::HttpProxyClientSocket( : NULL), tunnel_(tunnel), using_spdy_(using_spdy), + is_https_proxy_(is_https_proxy), net_log_(transport_socket->socket()->NetLog()) { // Synthesize the bits of a request that we actually use. request_.url = request_url; @@ -59,6 +62,12 @@ HttpProxyClientSocket::~HttpProxyClientSocket() { Disconnect(); } +HttpStream* HttpProxyClientSocket::CreateConnectResponseStream() { + return new HttpBasicStream(transport_.release(), + http_stream_parser_.release(), false); +} + + int HttpProxyClientSocket::Connect(CompletionCallback* callback) { DCHECK(transport_.get()); DCHECK(transport_->socket()); @@ -145,7 +154,8 @@ void HttpProxyClientSocket::LogBlockedTunnelResponse(int response_code) const { } void HttpProxyClientSocket::Disconnect() { - transport_->socket()->Disconnect(); + if (transport_.get()) + transport_->socket()->Disconnect(); // Reset other states to make sure they aren't mistakenly used later. // These are the states initialized by Connect(). @@ -409,6 +419,8 @@ int HttpProxyClientSocket::DoReadHeadersComplete(int result) { return HandleAuthChallenge(); default: + if (is_https_proxy_) + return ERR_HTTPS_PROXY_TUNNEL_RESPONSE; // For all other status codes, we conservatively fail the CONNECT // request. // We lose something by doing this. We have seen proxy 403, 404, and |