diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 06:46:23 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 06:46:23 +0000 |
commit | f9ee6b5a5925d8496f05309963c42bfdd3ec1a8b (patch) | |
tree | 7867cc64559bf86408da5a744e918d2861bf3889 /net/url_request/url_request_ftp_job.cc | |
parent | f6028ee8661996ba41763a6601469ebd599480f5 (diff) | |
download | chromium_src-f9ee6b5a5925d8496f05309963c42bfdd3ec1a8b.zip chromium_src-f9ee6b5a5925d8496f05309963c42bfdd3ec1a8b.tar.gz chromium_src-f9ee6b5a5925d8496f05309963c42bfdd3ec1a8b.tar.bz2 |
- Add preemptive authorization (new http stack only)
- Check for auth identity in URL (new http stack only)
- Move auth cache logic out of url request job, and hide it in the url request ftp job and http transaction classes.
Note: Somehow the original codereview thread got corrupted so it was recreated.
The real review comments should be under (http://codereview.chromium.org/6481)
Review URL: http://codereview.chromium.org/8231
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_ftp_job.cc')
-rw-r--r-- | net/url_request/url_request_ftp_job.cc | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc index fab4ff3..9cd7ca9 100644 --- a/net/url_request/url_request_ftp_job.cc +++ b/net/url_request/url_request_ftp_job.cc @@ -167,19 +167,32 @@ void URLRequestFtpJob::OnIOComplete(const AsyncResult& result) { // fall through case ERROR_INTERNET_INCORRECT_USER_NAME: // fall through - case ERROR_INTERNET_INCORRECT_PASSWORD: + case ERROR_INTERNET_INCORRECT_PASSWORD: { + // TODO(eroman): shouldn't the port be part of the key? + std::string cache_key = request_->url().host(); if (server_auth_ != NULL && server_auth_->state == net::AUTH_STATE_HAVE_AUTH) { - request_->context()->ftp_auth_cache()->Remove(request_->url().host()); + request_->context()->ftp_auth_cache()->Remove(cache_key); } else { server_auth_ = new net::AuthData(); } - // Try again, prompting for authentication. server_auth_->state = net::AUTH_STATE_NEED_AUTH; - // The io completed fine, the error was due to invalid auth. - SetStatus(URLRequestStatus()); - NotifyHeadersComplete(); + + scoped_refptr<net::AuthData> cached_auth = + request_->context()->ftp_auth_cache()->Lookup(cache_key); + + if (cached_auth) { + // Retry using cached auth data. + SetAuth(cached_auth->username, cached_auth->password); + } else { + // The io completed fine, the error was due to invalid auth. + SetStatus(URLRequestStatus()); + + // Prompt for a username/password. + NotifyHeadersComplete(); + } return; + } case ERROR_SUCCESS: connection_handle_ = (HINTERNET)result.dwResult; OnConnect(); @@ -261,13 +274,6 @@ void URLRequestFtpJob::GetAuthChallengeInfo( result->swap(auth_info); } -void URLRequestFtpJob::GetCachedAuthData( - const net::AuthChallengeInfo& auth_info, - scoped_refptr<net::AuthData>* auth_data) { - *auth_data = request_->context()->ftp_auth_cache()-> - Lookup(WideToUTF8(auth_info.host)); -} - void URLRequestFtpJob::OnConnect() { DCHECK_EQ(state_, CONNECTING); |