Index: net/http/http_transaction_test_util.cc |
diff --git a/net/http/http_transaction_test_util.cc b/net/http/http_transaction_test_util.cc |
index 7d031d8023886c53ef20d3853676abe35bc140a6..dbbca6c3d9e9bff6c2c8cc8f808154bfe2df88c2 100644 |
--- a/net/http/http_transaction_test_util.cc |
+++ b/net/http/http_transaction_test_util.cc |
@@ -277,8 +277,13 @@ bool MockNetworkTransaction::IsReadyToRestartForAuth() { |
if (!request_) |
return false; |
- // Only mock auth when the test asks for it. |
- return request_->extra_headers.HasHeader("X-Require-Mock-Auth"); |
+ if (!request_->extra_headers.HasHeader("X-Require-Mock-Auth")) |
+ return false; |
+ |
+ // Allow the mock server to decide whether authentication is required or not. |
+ std::string status_line = response_.headers->GetStatusLine(); |
+ return status_line.find(" 401 ") != std::string::npos || |
+ status_line.find(" 407 ") != std::string::npos; |
} |
int MockNetworkTransaction::Read(net::IOBuffer* buf, int buf_len, |