OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 | 1074 |
1075 void HttpStreamParser::SetConnectionReused() { | 1075 void HttpStreamParser::SetConnectionReused() { |
1076 connection_->set_reuse_type(ClientSocketHandle::REUSED_IDLE); | 1076 connection_->set_reuse_type(ClientSocketHandle::REUSED_IDLE); |
1077 } | 1077 } |
1078 | 1078 |
1079 bool HttpStreamParser::CanReuseConnection() const { | 1079 bool HttpStreamParser::CanReuseConnection() const { |
1080 if (!CanFindEndOfResponse()) | 1080 if (!CanFindEndOfResponse()) |
1081 return false; | 1081 return false; |
1082 if (!response_->headers || !response_->headers->IsKeepAlive()) | 1082 if (!response_->headers || !response_->headers->IsKeepAlive()) |
1083 return false; | 1083 return false; |
| 1084 |
| 1085 // Check if extra data was received after reading the entire response body. If |
| 1086 // extra data was received reusing the socket is not a great idea. This does |
| 1087 // have the down side of papering over certain server bugs, but seems to be |
| 1088 // the best option here. |
| 1089 // |
| 1090 // TODO(mmenke): Consider logging this - hard to decipher socket reuse |
| 1091 // behavior makes NetLogs harder to read. |
| 1092 if (IsResponseBodyComplete() && read_buf_->offset() > 0) |
| 1093 return false; |
| 1094 |
1084 return connection_->socket() && connection_->socket()->IsConnected(); | 1095 return connection_->socket() && connection_->socket()->IsConnected(); |
1085 } | 1096 } |
1086 | 1097 |
1087 void HttpStreamParser::GetSSLInfo(SSLInfo* ssl_info) { | 1098 void HttpStreamParser::GetSSLInfo(SSLInfo* ssl_info) { |
1088 if (request_->url.SchemeIsCryptographic() && connection_->socket()) { | 1099 if (request_->url.SchemeIsCryptographic() && connection_->socket()) { |
1089 SSLClientSocket* ssl_socket = | 1100 SSLClientSocket* ssl_socket = |
1090 static_cast<SSLClientSocket*>(connection_->socket()); | 1101 static_cast<SSLClientSocket*>(connection_->socket()); |
1091 ssl_socket->GetSSLInfo(ssl_info); | 1102 ssl_socket->GetSSLInfo(ssl_info); |
1092 } | 1103 } |
1093 } | 1104 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 } | 1163 } |
1153 | 1164 |
1154 void HttpStreamParser::ValidateStatusLine(const std::string& status_line) { | 1165 void HttpStreamParser::ValidateStatusLine(const std::string& status_line) { |
1155 HttpStatusLineValidator::StatusLineStatus status = | 1166 HttpStatusLineValidator::StatusLineStatus status = |
1156 HttpStatusLineValidator::ValidateStatusLine(status_line); | 1167 HttpStatusLineValidator::ValidateStatusLine(status_line); |
1157 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, | 1168 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, |
1158 HttpStatusLineValidator::STATUS_LINE_MAX); | 1169 HttpStatusLineValidator::STATUS_LINE_MAX); |
1159 } | 1170 } |
1160 | 1171 |
1161 } // namespace net | 1172 } // namespace net |
OLD | NEW |