]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Unknown
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 26 May 2010 04:47:58 +0000 (16:47 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 26 May 2010 04:47:58 +0000 (16:47 +1200)
Bug 2879: 3.0 regression in headers end finding

Ported from Squid-2.

Also, updates from Alex Rousskov for 3.x.

src/http.cc

index 278786c22491857406e583be55266140e7f9314d..ae167c49d51ec9b3665128df401ae4a61e87136b 100644 (file)
@@ -706,6 +706,9 @@ HttpStateData::processReplyHeader()
 
     assert(!flags.headers_parsed);
 
+    if (!readBuf->hasContent())
+        return;
+
     http_status error = HTTP_STATUS_NONE;
 
     HttpReply *newrep = new HttpReply;
@@ -1062,6 +1065,21 @@ HttpStateData::readReply (size_t len, comm_err_t flag, int xerrno)
     if (len == 0) { // reached EOF?
         eof = 1;
         flags.do_next_read = 0;
+
+        /* 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: Add eof parameter to headersEnd() and move this hack there.
+         */
+        if (readBuf->contentSize() && !flags.headers_parsed) {
+            /*
+             * Yes Henrik, there is a point to doing this.  When we
+             * called httpProcessReplyHeader() before, we didn't find
+             * the end of headers, but now we are definately at EOF, so
+             * we want to process the reply headers.
+             */
+            /* Fake an "end-of-headers" to work around such broken servers */
+            readBuf->append("\r\n", 2);
+        }
     }
 
     if (!flags.headers_parsed) { // have not parsed headers yet?