]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 22 May 2010 03:55:41 +0000 (15:55 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 22 May 2010 03:55:41 +0000 (15:55 +1200)
Bug 2879: pt2: 3.0 regression in headers end finding

Consider the case when we received an empty (zero bytes) response.

The committed hack (bzr r9935) makes the "Invalid Response" warning misleading
because it adds CRLF to the empty response. The same hack makes the correct
error determination even more broken than it was (because the rest of the code
now sees content when none exited). It also mentions the wrong bug number.

The attached patch fixes the above and attempts to route empty response
processing to the right error (ERR_ZERO_SIZE_OBJECT).

TODO: Reconsider polluting cache.log with unlimited Invalid Response warnings,
at least in a forward proxy environment where the admin has no control over
responses.

src/http.cc

index 7a017326be7b49180f90b348bc09ef1cbbd3c8ed..c14060cb1bc2fe27ba14cd1aa24df35c20aa5151 100644 (file)
@@ -672,6 +672,9 @@ HttpStateData::processReplyHeader()
 
     assert(!flags.headers_parsed);
 
+    if (!readBuf->hasContent())
+        return;
+
     http_status error = HTTP_STATUS_NONE;
 
     HttpReply *newrep = new HttpReply;
@@ -1123,12 +1126,11 @@ HttpStateData::readReply(const CommIoCbParams &io)
         eof = 1;
         flags.do_next_read = 0;
 
-        /* Bug 2789: Replies may terminate with \r\n then EOF instead of \r\n\r\n
+        /* Bug 2879: Replies may terminate with \r\n then EOF instead of \r\n\r\n
          * Ensure here that we have at minimum two \r\n when EOF is seen.
-         * TODO: When headersEnd() is cleaned up to only be called once we can merge
-         * this as a special case there where it belongs.
+         * TODO: Add eof parameter to headersEnd() and move this hack there.
          */
-        if (!flags.headers_parsed) {
+        if (readBuf->contentSize() && !flags.headers_parsed) {
             /*
              * Yes Henrik, there is a point to doing this.  When we
              * called httpProcessReplyHeader() before, we didn't find
@@ -1137,7 +1139,6 @@ HttpStateData::readReply(const CommIoCbParams &io)
              */
             /* Fake an "end-of-headers" to work around such broken servers */
             readBuf->append("\r\n", 2);
-            len = 2;
         }
     }