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

Unified Diff: net/http/http_stream_parser.cc

Issue 1320683003: Move logic to figure out if a socket can be reused into HttpStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 5 years, 4 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
Index: net/http/http_stream_parser.cc
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 58bbf9271f99af8dbfd9cb1fd2f3b7a3f336a076..953635b308f947eba80b8fff6fdabd0336546f65 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -202,15 +202,16 @@ HttpStreamParser::HttpStreamParser(ClientSocketHandle* connection,
const BoundNetLog& net_log)
: io_state_(STATE_NONE),
request_(request),
- request_headers_(NULL),
+ request_headers_(nullptr),
request_headers_length_(0),
read_buf_(read_buffer),
read_buf_unused_offset_(0),
response_header_start_offset_(-1),
received_bytes_(0),
+ response_(nullptr),
response_body_length_(-1),
response_body_read_(0),
- user_read_buf_(NULL),
+ user_read_buf_(nullptr),
user_read_buf_len_(0),
connection_(connection),
net_log_(net_log),
@@ -1069,7 +1070,11 @@ void HttpStreamParser::SetConnectionReused() {
connection_->set_reuse_type(ClientSocketHandle::REUSED_IDLE);
}
-bool HttpStreamParser::IsConnectionReusable() const {
+bool HttpStreamParser::CanReuseConnection() const {
+ if (!CanFindEndOfResponse())
+ return false;
+ if (!response_->headers || !response_->headers->IsKeepAlive())
+ return false;
return connection_->socket() && connection_->socket()->IsConnectedAndIdle();
}

Powered by Google App Engine
This is Rietveld 408576698