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

Unified Diff: net/http/http_network_transaction.cc

Issue 4264: If we read nothing (EOF) after sending a request on a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 2611)
+++ net/http/http_network_transaction.cc (working copy)
@@ -576,6 +576,9 @@
if (result < 0)
return HandleIOError(result);
+ if (result == 0 && ShouldResendRequest())
+ return result;
+
// Record our best estimate of the 'response time' as the time when we read
// the first bytes of the response headers.
if (header_buf_len_ == 0)
@@ -848,21 +851,30 @@
case ERR_CONNECTION_RESET:
case ERR_CONNECTION_CLOSED:
case ERR_CONNECTION_ABORTED:
- if (!establishing_tunnel_ &&
- reused_socket_ && // We reused a keep-alive connection.
- !header_buf_len_) { // We haven't received any response header yet.
- connection_.set_socket(NULL);
- connection_.Reset();
- request_headers_bytes_sent_ = 0;
- if (request_body_stream_.get())
- request_body_stream_->Reset();
- next_state_ = STATE_INIT_CONNECTION; // Resend the request.
+ if (ShouldResendRequest())
error = OK;
- }
break;
}
return error;
}
+bool HttpNetworkTransaction::ShouldResendRequest() {
+ // NOTE: we resend a request only if we reused a keep-alive connection.
+ // This automatically prevents an infinite resend loop because we'll run
+ // out of the cached keep-alive connections eventually.
+ if (establishing_tunnel_ ||
+ !reused_socket_ || // We didn't reuse a keep-alive connection.
+ header_buf_len_) { // We have received some response headers.
+ return false;
+ }
+ connection_.set_socket(NULL);
+ connection_.Reset();
+ request_headers_bytes_sent_ = 0;
+ if (request_body_stream_.get())
+ request_body_stream_->Reset();
+ next_state_ = STATE_INIT_CONNECTION; // Resend the request.
+ return true;
+}
+
} // namespace net
« 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