From: Amos Jeffries Date: Sat, 22 May 2010 03:55:41 +0000 (+1200) Subject: Author: Alex Rousskov X-Git-Tag: SQUID_3_2_0_1~207 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b73a07d659fb5fb7bb8579888c6eb15f0098059f;p=thirdparty%2Fsquid.git Author: Alex Rousskov 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. --- diff --git a/src/http.cc b/src/http.cc index 7a017326be..c14060cb1b 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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; } }