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

Unified Diff: net/http/http_stream_parser.cc

Issue 15688012: net: don't process truncated headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only enforce this for HTTPS URLs. Created 7 years, 7 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 3c64ee67bf636834e857495bc7a215d8483285d4..7b195e7f698f11abb120c7c93642bed5871935cb 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -541,26 +541,31 @@ int HttpStreamParser::DoReadHeadersComplete(int result) {
if (result == ERR_CONNECTION_CLOSED) {
// The connection closed before we detected the end of the headers.
- // parse things as well as we can and let the caller decide what to do.
if (read_buf_->offset() == 0) {
// The connection was closed before any data was sent. Likely an error
// rather than empty HTTP/0.9 response.
io_state_ = STATE_DONE;
return ERR_EMPTY_RESPONSE;
+ } else if (request_->url.SchemeIs("https")) {
Ryan Sleevi 2013/05/29 19:59:33 Seems like we should be looking at SchemeIsSecure
wtc 2013/05/30 00:38:30 Yes, this sounds like a good idea. In fact, I am w
agl 2013/06/03 18:18:29 After discussions with Darin, I only did this for
wtc 2013/06/03 18:36:47 It occurred to me that this file, http_stream_pars
+ // The connection was closed in the middle of the headers. For HTTPS we
+ // don't parse partial headers. Return a different error code so that we
wtc 2013/05/30 00:38:30 By "a different error code", do you mean an error
agl 2013/06/03 18:18:29 Yes, will clarify.
+ // know that we shouldn't attempt to retry the request.
+ io_state_ = STATE_DONE;
+ return ERR_HEADERS_TRUNCATED;
+ }
+ // Parse things as well as we can and let the caller decide what to do.
+ int end_offset;
+ if (response_header_start_offset_ >= 0) {
+ io_state_ = STATE_READ_BODY_COMPLETE;
+ end_offset = read_buf_->offset();
} else {
- int end_offset;
- if (response_header_start_offset_ >= 0) {
- io_state_ = STATE_READ_BODY_COMPLETE;
- end_offset = read_buf_->offset();
- } else {
- io_state_ = STATE_BODY_PENDING;
- end_offset = 0;
- }
- int rv = DoParseResponseHeaders(end_offset);
- if (rv < 0)
- return rv;
- return result;
+ io_state_ = STATE_BODY_PENDING;
+ end_offset = 0;
}
+ int rv = DoParseResponseHeaders(end_offset);
+ if (rv < 0)
+ return rv;
+ return result;
}
read_buf_->set_offset(read_buf_->offset() + result);

Powered by Google App Engine
This is Rietveld 408576698