diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-29 21:53:54 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-29 21:53:54 +0000 |
commit | 86ec30d6710923cf1c193eb88b1e6251f831e0ef (patch) | |
tree | 5e94a3f1151ad85696e6a6ac4509413c645db148 /net | |
parent | aa4edea0dcdec0733c01e3f2c7487969d17b4a51 (diff) | |
download | chromium_src-86ec30d6710923cf1c193eb88b1e6251f831e0ef.zip chromium_src-86ec30d6710923cf1c193eb88b1e6251f831e0ef.tar.gz chromium_src-86ec30d6710923cf1c193eb88b1e6251f831e0ef.tar.bz2 |
Add code to call ReconsiderProxyAfterError when we encounter a failure to resolve a hostname or a failure to connect a client socket.
BUG=2962
R=wtc
Review URL: http://codereview.chromium.org/5033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_network_transaction.cc | 44 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 8 |
2 files changed, 49 insertions, 3 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index c518f14..6bca966 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -28,8 +28,6 @@ // - authentication // + pre-emptive authorization // + use the username/password encoded in the URL. -// - proxies (need to call ReconsiderProxyAfterError and handle SSL tunnel) -// - ssl namespace net { @@ -467,8 +465,11 @@ int HttpNetworkTransaction::DoResolveHost() { } int HttpNetworkTransaction::DoResolveHostComplete(int result) { - if (result == OK) + if (result == OK) { next_state_ = STATE_CONNECT; + } else { + result = ReconsiderProxyAfterError(result); + } return result; } @@ -495,6 +496,8 @@ int HttpNetworkTransaction::DoConnectComplete(int result) { establishing_tunnel_ = true; } else if (IsCertificateError(result)) { result = HandleCertificateError(result); + } else { + result = ReconsiderProxyAfterError(result); } return result; } @@ -502,6 +505,7 @@ int HttpNetworkTransaction::DoConnectComplete(int result) { int HttpNetworkTransaction::DoSSLConnectOverTunnel() { next_state_ = STATE_SSL_CONNECT_OVER_TUNNEL_COMPLETE; + // Add a SSL socket on top of our existing transport socket. ClientSocket* s = connection_.release_socket(); s = socket_factory_->CreateSSLClientSocket(s, request_->url.host()); connection_.set_socket(s); @@ -922,6 +926,40 @@ bool HttpNetworkTransaction::ShouldResendRequest() { return true; } +int HttpNetworkTransaction::ReconsiderProxyAfterError(int error) { + DCHECK(!pac_request_); + + // A failure to resolve the hostname or any error related to establishing a + // TCP connection could be grounds for trying a new proxy configuration. + switch (error) { + case ERR_NAME_NOT_RESOLVED: + case ERR_INTERNET_DISCONNECTED: + case ERR_ADDRESS_UNREACHABLE: + case ERR_CONNECTION_CLOSED: + case ERR_CONNECTION_RESET: + case ERR_CONNECTION_REFUSED: + case ERR_CONNECTION_ABORTED: + case ERR_TIMED_OUT: + case ERR_TUNNEL_CONNECTION_FAILED: + break; + default: + return error; + } + + int rv = session_->proxy_service()->ReconsiderProxyAfterError( + request_->url, &proxy_info_, &io_callback_, &pac_request_); + if (rv == OK || rv == ERR_IO_PENDING) { + connection_.set_socket(NULL); + connection_.Reset(); + DCHECK(!request_headers_bytes_sent_); + next_state_ = STATE_RESOLVE_PROXY_COMPLETE; + } else { + rv = error; + } + + return rv; +} + void HttpNetworkTransaction::AddAuthorizationHeader(HttpAuth::Target target) { DCHECK(HaveAuth(target)); DCHECK(!auth_cache_key_[target].empty()); diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 533d4a2..2414050 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -94,6 +94,14 @@ class HttpNetworkTransaction : public HttpTransaction { // returns false. bool ShouldResendRequest(); + // Called when we encounter a network error that could be resolved by trying + // a new proxy configuration. If there is another proxy configuration to try + // then this method sets next_state_ appropriately and returns either OK or + // ERR_IO_PENDING depending on whether or not the new proxy configuration is + // available synchronously or asynchronously. Otherwise, the given error + // code is simply returned. + int ReconsiderProxyAfterError(int error); + // Return true if based on the bytes read so far, the start of the // status line is known. This is used to distingish between HTTP/0.9 // responses (which have no status line) and HTTP/1.x responses. |