diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 11:09:24 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 11:09:24 +0000 |
commit | fa82f93da256dede111ee4143c340e55a195d7e3 (patch) | |
tree | 36082a958021799fd1de1e5e30d4a861cda4bba6 /net/socket_stream | |
parent | 6278df2e8f1e77409e499addf16fa4679f3dca0b (diff) | |
download | chromium_src-fa82f93da256dede111ee4143c340e55a195d7e3.zip chromium_src-fa82f93da256dede111ee4143c340e55a195d7e3.tar.gz chromium_src-fa82f93da256dede111ee4143c340e55a195d7e3.tar.bz2 |
Remove handler from HttpAuthCache.
This is part of a refactoring meant to simplify the connection phase of HttpNetworkTransaction.
BUG=None
TEST=net_unittests (which already includes unit tests for preemptive auth, as well as using values from cache).
Review URL: http://codereview.chromium.org/2056003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47786 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket_stream')
-rw-r--r-- | net/socket_stream/socket_stream.cc | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc index 68fbbf3..b2f7a2c 100644 --- a/net/socket_stream/socket_stream.cc +++ b/net/socket_stream/socket_stream.cc @@ -18,6 +18,7 @@ #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" +#include "net/http/http_auth_handler_factory.h" #include "net/http/http_response_headers.h" #include "net/http/http_util.h" #include "net/socket/client_socket_factory.h" @@ -540,15 +541,23 @@ int SocketStream::DoWriteTunnelHeaders() { std::string authorization_headers; if (!auth_handler_.get()) { - // First attempt. Find auth from the proxy address. + // Do preemptive authentication. HttpAuthCache::Entry* entry = auth_cache_.LookupByPath( ProxyAuthOrigin(), std::string()); - if (entry && !entry->handler()->is_connection_based()) { - auth_identity_.source = HttpAuth::IDENT_SRC_PATH_LOOKUP; - auth_identity_.invalid = false; - auth_identity_.username = entry->username(); - auth_identity_.password = entry->password(); - auth_handler_ = entry->handler(); + if (entry) { + scoped_refptr<HttpAuthHandler> handler_preemptive; + int rv_create = http_auth_handler_factory_-> + CreatePreemptiveAuthHandlerFromString( + entry->auth_challenge(), HttpAuth::AUTH_PROXY, + ProxyAuthOrigin(), entry->IncrementNonceCount(), + &handler_preemptive); + if (rv_create == OK) { + auth_identity_.source = HttpAuth::IDENT_SRC_PATH_LOOKUP; + auth_identity_.invalid = false; + auth_identity_.username = entry->username(); + auth_identity_.password = entry->password(); + auth_handler_ = handler_preemptive; + } } } @@ -881,7 +890,7 @@ int SocketStream::HandleAuthChallenge(const HttpResponseHeaders* headers) { // We only support basic authentication scheme now. // TODO(ukai): Support other authentication scheme. HttpAuthCache::Entry* entry = - auth_cache_.Lookup(auth_origin, auth_handler_->realm(), "basic"); + auth_cache_.Lookup(auth_origin, auth_handler_->realm(), "basic"); if (entry) { auth_identity_.source = HttpAuth::IDENT_SRC_REALM_LOOKUP; auth_identity_.invalid = false; @@ -905,8 +914,12 @@ void SocketStream::DoAuthRequired() { void SocketStream::DoRestartWithAuth() { DCHECK_EQ(next_state_, STATE_AUTH_REQUIRED); - auth_cache_.Add(ProxyAuthOrigin(), auth_handler_, - auth_identity_.username, auth_identity_.password, + auth_cache_.Add(ProxyAuthOrigin(), + auth_handler_->realm(), + auth_handler_->scheme(), + auth_handler_->challenge(), + auth_identity_.username, + auth_identity_.password, std::string()); tunnel_request_headers_ = NULL; |