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(); |
} |