Index: net/http/http_cache_transaction.cc |
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc |
index 32386f06a4b5be24d60e67b72abf64a1e8ee5147..4ee0af1162ff7c126717330e6f5720acfc99e3f1 100644 |
--- a/net/http/http_cache_transaction.cc |
+++ b/net/http/http_cache_transaction.cc |
@@ -18,11 +18,14 @@ |
#include "base/ref_counted.h" |
#include "base/string_util.h" |
#include "base/time.h" |
+#include "base/utf_string_conversions.h" |
+#include "net/base/auth.h" |
#include "net/base/cert_status_flags.h" |
#include "net/base/io_buffer.h" |
#include "net/base/load_flags.h" |
#include "net/base/net_errors.h" |
#include "net/base/net_log.h" |
+#include "net/base/net_util.h" |
#include "net/base/ssl_cert_request_info.h" |
#include "net/base/ssl_config_service.h" |
#include "net/disk_cache/disk_cache.h" |
@@ -105,6 +108,7 @@ HttpCache::Transaction::Transaction(HttpCache* cache) |
new_entry_(NULL), |
network_trans_(NULL), |
callback_(NULL), |
+ tls_login_auth_data_(NULL), |
new_response_(NULL), |
mode_(NONE), |
target_state_(STATE_NONE), |
@@ -293,6 +297,37 @@ int HttpCache::Transaction::RestartWithCertificate( |
return rv; |
} |
+void HttpCache::Transaction::SetTLSLoginAuthData(AuthData* auth_data) { |
+ if (network_trans_.get()) |
+ network_trans_->SetTLSLoginAuthData(auth_data); |
+ tls_login_auth_data_ = auth_data; |
+} |
+ |
+int HttpCache::Transaction::RestartWithTLSLogin(CompletionCallback *callback) { |
+ DCHECK(callback); |
+ |
+ // Ensure that we only have one asynchronous call at a time. |
+ DCHECK(!callback_); |
+ |
+ if (!cache_) |
+ return ERR_UNEXPECTED; |
+ |
+ int rv; |
+ |
+ if (network_trans_.get()) { |
+ rv = RestartNetworkRequestWithTLSLogin(); |
+ } else { |
+ // Start the transaction. |
+ next_state_ = STATE_SEND_REQUEST; |
+ rv = DoLoop(OK); |
+ } |
+ |
+ if (rv == ERR_IO_PENDING) |
+ callback_ = callback; |
+ |
+ return rv; |
+} |
+ |
int HttpCache::Transaction::RestartWithAuth( |
const string16& username, |
const string16& password, |
@@ -382,7 +417,9 @@ const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { |
if (auth_response_.headers) |
return &auth_response_; |
return (response_.headers || response_.ssl_info.cert || |
- response_.cert_request_info) ? &response_ : NULL; |
+ !response_.ssl_info.tls_username.empty() || |
+ response_.cert_request_info || response_.login_request_info) ? |
+ &response_ : NULL; |
} |
LoadState HttpCache::Transaction::GetLoadState() const { |
@@ -642,6 +679,11 @@ int HttpCache::Transaction::DoSendRequest() { |
if (rv != OK) |
return rv; |
+ if (tls_login_auth_data_ && |
+ tls_login_auth_data_->state == AUTH_STATE_HAVE_AUTH) { |
+ network_trans_->SetTLSLoginAuthData(tls_login_auth_data_); |
+ } |
+ |
next_state_ = STATE_SEND_REQUEST_COMPLETE; |
rv = network_trans_->Start(request_, &io_callback_, net_log_); |
return rv; |
@@ -666,6 +708,11 @@ int HttpCache::Transaction::DoSendRequestComplete(int result) { |
const HttpResponseInfo* response = network_trans_->GetResponseInfo(); |
DCHECK(response); |
response_.cert_request_info = response->cert_request_info; |
+ } else if (result == ERR_TLS_CLIENT_LOGIN_NEEDED || |
+ result == ERR_TLS_CLIENT_LOGIN_FAILED) { |
+ const HttpResponseInfo* response = network_trans_->GetResponseInfo(); |
+ DCHECK(response); |
+ response_.login_request_info = response->login_request_info; |
} |
return result; |
} |
@@ -1571,6 +1618,18 @@ int HttpCache::Transaction::RestartNetworkRequestWithCertificate( |
return rv; |
} |
+int HttpCache::Transaction::RestartNetworkRequestWithTLSLogin() { |
+ DCHECK(mode_ & WRITE || mode_ == NONE); |
+ DCHECK(network_trans_.get()); |
+ DCHECK_EQ(STATE_NONE, next_state_); |
+ |
+ next_state_ = STATE_SEND_REQUEST_COMPLETE; |
+ int rv = network_trans_->RestartWithTLSLogin(&io_callback_); |
+ if (rv != ERR_IO_PENDING) |
+ return DoLoop(rv); |
+ return rv; |
+} |
+ |
int HttpCache::Transaction::RestartNetworkRequestWithAuth( |
const string16& username, |
const string16& password) { |