Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: net/http/http_network_transaction.cc

Issue 51004: Respect cookies set in a 401 responses when restarting the http transaction.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address rest of wtc's comments (had missed some in previous patchset) Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction.cc
===================================================================
--- net/http/http_network_transaction.cc (revision 12402)
+++ net/http/http_network_transaction.cc (working copy)
@@ -35,7 +35,8 @@
HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session,
ClientSocketFactory* csf)
- : ALLOW_THIS_IN_INITIALIZER_LIST(
+ : pending_auth_target_(HttpAuth::AUTH_NONE),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
io_callback_(this, &HttpNetworkTransaction::OnIOComplete)),
user_callback_(NULL),
session_(session),
@@ -92,20 +93,24 @@
const std::wstring& username,
const std::wstring& password,
CompletionCallback* callback) {
+ HttpAuth::Target target = pending_auth_target_;
+ if (target == HttpAuth::AUTH_NONE) {
+ NOTREACHED();
+ return ERR_UNEXPECTED;
+ }
- DCHECK(NeedAuth(HttpAuth::AUTH_PROXY) ||
- NeedAuth(HttpAuth::AUTH_SERVER));
+ pending_auth_target_ = HttpAuth::AUTH_NONE;
- // Figure out whether this username password is for proxy or server.
- // Proxy gets set first, then server.
- HttpAuth::Target target = NeedAuth(HttpAuth::AUTH_PROXY) ?
- HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER;
+ DCHECK(auth_identity_[target].invalid ||
+ (username.empty() && password.empty()));
- // Update the username/password.
- auth_identity_[target].source = HttpAuth::IDENT_SRC_EXTERNAL;
- auth_identity_[target].invalid = false;
- auth_identity_[target].username = username;
- auth_identity_[target].password = password;
+ if (auth_identity_[target].invalid) {
+ // Update the username/password.
+ auth_identity_[target].source = HttpAuth::IDENT_SRC_EXTERNAL;
+ auth_identity_[target].invalid = false;
+ auth_identity_[target].username = username;
+ auth_identity_[target].password = password;
+ }
PrepareForAuthRestart(target);
@@ -1094,8 +1099,6 @@
}
int rv = HandleAuthChallenge();
- if (rv == WILL_RESTART_TRANSACTION)
- return OK;
if (rv != OK)
return rv;
@@ -1179,6 +1182,7 @@
}
void HttpNetworkTransaction::ResetStateForRestart() {
+ pending_auth_target_ = HttpAuth::AUTH_NONE;
header_buf_.reset();
header_buf_capacity_ = 0;
header_buf_len_ = 0;
@@ -1470,11 +1474,10 @@
return OK;
}
- bool has_identity_to_try;
if (auth_handler_[target]->NeedsIdentity()) {
// Pick a new auth identity to try, by looking to the URL and auth cache.
// If an identity to try is found, it is saved to auth_identity_[target].
- has_identity_to_try = SelectNextAuthIdentityToTry(target);
+ SelectNextAuthIdentityToTry(target);
} else {
// Proceed with a null identity.
//
@@ -1484,19 +1487,17 @@
auth_identity_[target].invalid = false;
auth_identity_[target].username.clear();
auth_identity_[target].password.clear();
- has_identity_to_try = true;
}
- DCHECK(has_identity_to_try == !auth_identity_[target].invalid);
- if (has_identity_to_try) {
- DCHECK(user_callback_);
- PrepareForAuthRestart(target);
- return WILL_RESTART_TRANSACTION;
+ // Make a note that we are waiting for auth. This variable is inspected
+ // when the client calls RestartWithAuth() to pick up where we left off.
+ pending_auth_target_ = target;
+
+ if (auth_identity_[target].invalid) {
+ // We have exhausted all identity possibilities, all we can do now is
+ // pass the challenge information back to the client.
+ PopulateAuthChallenge(target);
}
-
- // We have exhausted all identity possibilities, all we can do now is
- // pass the challenge information back to the client.
- PopulateAuthChallenge(target);
return OK;
}
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698