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

Unified Diff: net/http/http_stream_parser.cc

Issue 8863002: Revert 110505 - Report ERR_CONTENT_LENGTH_MISMATCH when the count of bytes received doesn't match... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_parser.cc
===================================================================
--- net/http/http_stream_parser.cc (revision 113482)
+++ net/http/http_stream_parser.cc (working copy)
@@ -530,38 +530,12 @@
}
int HttpStreamParser::DoReadBodyComplete(int result) {
- // When the connection is closed, there are numerous ways to interpret it.
- //
- // - If a Content-Length header is present and the body contains exactly that
- // number of bytes at connection close, the response is successful.
- //
- // - If a Content-Length header is present and the body contains fewer bytes
- // than promised by the header at connection close, it may indicate that
- // the connection was closed prematurely, or it may indicate that the
- // server sent an invalid Content-Length header. Unfortunately, the invalid
- // Content-Length header case does occur in practice and other browsers are
- // tolerant of it, so this is reported as an ERR_CONTENT_LENGTH_MISMATCH
- // rather than an ERR_CONNECTION_CLOSE.
- //
- // - If chunked encoding is used and the terminating chunk has been processed
- // when the connection is closed, the response is successful.
- //
- // - If chunked encoding is used and the terminating chunk has not been
- // processed when the connection is closed, it may indicate that the
- // connection was closed prematurely or it may indicate that the server
- // sent an invalid chunked encoding. We choose to treat it as
- // an invalid chunked encoding.
- //
- // - If a Content-Length is not present and chunked encoding is not used,
- // connection close is the only way to signal that the response is
- // complete. Unfortunately, this also means that there is no way to detect
- // early close of a connection. No error is returned.
- if (result == 0 && !IsResponseBodyComplete() && CanFindEndOfResponse()) {
- if (chunked_decoder_.get())
- result = ERR_INVALID_CHUNKED_ENCODING;
- else
- result = ERR_CONTENT_LENGTH_MISMATCH;
- }
+ // If we didn't get a Content-Length and aren't using a chunked encoding,
+ // the only way to signal the end of a stream is to close the connection,
+ // so we don't treat that as an error, though in some cases we may not
+ // have completely received the resource.
+ if (result == 0 && !IsResponseBodyComplete() && CanFindEndOfResponse())
+ result = ERR_CONNECTION_CLOSED;
// Filter incoming data if appropriate. FilterBuf may return an error.
if (result > 0 && chunked_decoder_.get()) {
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698