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

Unified Diff: net/http/http_network_transaction.cc

Issue 2771263002: Retry upon 421 status code without IP pooling. (Closed)
Patch Set: Rebase. Created 3 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
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index a5395d758bcc4c9d26ef115ca43da28ce9424a0c..e0105c60396fe3f891916b12114cff7c14da899b 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -100,9 +100,9 @@ HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority,
total_sent_bytes_(0),
next_state_(STATE_NONE),
establishing_tunnel_(false),
+ enable_ip_based_pooling_(true),
websocket_handshake_stream_base_create_helper_(NULL),
- net_error_details_() {
-}
+ net_error_details_() {}
HttpNetworkTransaction::~HttpNetworkTransaction() {
if (stream_.get()) {
@@ -847,22 +847,13 @@ int HttpNetworkTransaction::DoCreateStream() {
stream_request_.reset(
session_->http_stream_factory_for_websocket()
->RequestWebSocketHandshakeStream(
- *request_,
- priority_,
- server_ssl_config_,
- proxy_ssl_config_,
- this,
- websocket_handshake_stream_base_create_helper_,
- net_log_));
+ *request_, priority_, server_ssl_config_, proxy_ssl_config_,
+ this, websocket_handshake_stream_base_create_helper_,
+ enable_ip_based_pooling_, net_log_));
} else {
- stream_request_.reset(
- session_->http_stream_factory()->RequestStream(
- *request_,
- priority_,
- server_ssl_config_,
- proxy_ssl_config_,
- this,
- net_log_));
+ stream_request_.reset(session_->http_stream_factory()->RequestStream(
+ *request_, priority_, server_ssl_config_, proxy_ssl_config_, this,
+ enable_ip_based_pooling_, net_log_));
}
DCHECK(stream_request_.get());
return ERR_IO_PENDING;
@@ -1292,6 +1283,10 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) {
return OK;
}
+ if (response_.headers->response_code() == 421) {
+ return HandleIOError(ERR_MISDIRECTED_REQUEST);
+ }
+
if (IsSecureRequest()) {
session_->http_stream_factory()->ProcessAlternativeServices(
session_, response_.headers.get(), url::SchemeHostPort(request_->url));
@@ -1546,6 +1541,18 @@ int HttpNetworkTransaction::HandleIOError(int error) {
ResetConnectionAndRequestForResend();
error = OK;
break;
+ case ERR_MISDIRECTED_REQUEST:
Ryan Hamilton 2017/03/30 23:51:07 It's a bit weird that ERR_MISDIRECTED_REQUEST is a
Bence 2017/03/31 00:09:33 Yes, I absolutely agree with you. I was thinking
+ // If this is the second try, just give up.
+ if (!enable_ip_based_pooling_)
+ return OK;
+ // Otherwise, since the response status was 421 Misdirected Request,
+ // retry the request with IP based pooling disabled.
+ enable_ip_based_pooling_ = false;
+ net_log_.AddEventWithNetErrorCode(
+ NetLogEventType::HTTP_TRANSACTION_RESTART_AFTER_ERROR, error);
+ ResetConnectionAndRequestForResend();
+ error = OK;
+ break;
}
return error;
}
« 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