]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Unknown
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 22 Apr 2010 12:22:17 +0000 (00:22 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 22 Apr 2010 12:22:17 +0000 (00:22 +1200)
Bug 2879: 3.0 regression in headers end finding

Ported from Squid-2.

src/http.cc

index 4bbe5aa43ef87df9e1890cd1fd8ffbe98e0e2954..a52cb5be37ccef9e9fcc0971976abe90f1a0dcc8 100644 (file)
@@ -1125,6 +1125,23 @@ HttpStateData::readReply(const CommIoCbParams &io)
     if (len == 0) { // reached EOF?
         eof = 1;
         flags.do_next_read = 0;
+
+        /* Bug 2789: 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.
+         */
+        if (!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);
+            len = 2;
+        }
     }
 
     if (!flags.headers_parsed) { // have not parsed headers yet?