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

Unified Diff: net/http/http_stream_parser.cc

Issue 1884943003: HttpStreamParser: Don't reuse sockets which receive unparsed data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix drainer test ('True' means closed...) Created 4 years, 8 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 bc7746dad32f733e60dc27cf64bc316d5f27ddaf..9324e9ecd5eef8314b9327d3783932a70c8cab5c 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -1081,6 +1081,17 @@ bool HttpStreamParser::CanReuseConnection() const {
return false;
if (!response_->headers || !response_->headers->IsKeepAlive())
return false;
+
+ // Check if extra data was received after reading the entire response body. If
+ // extra data was received reusing the socket is not a great idea. This does
+ // have the down side of papering over certain server bugs, but seems to be
+ // the best option here.
+ //
+ // TODO(mmenke): Consider logging this - hard to decipher socket reuse
+ // behavior makes NetLogs harder to read.
+ if (IsResponseBodyComplete() && read_buf_->offset() > 0)
+ return false;
+
return connection_->socket() && connection_->socket()->IsConnected();
}

Powered by Google App Engine
This is Rietveld 408576698