--------------------- PatchSet 11546 Date: 2007/07/21 21:03:35 Author: hno Branch: HEAD Tag: (none) Log: Bug #2017: Fails to work around broken servers sending just the HTTP headers There is many broken servers around sending redirects etc containing just the HTTP headers and not the requiring terminating blank line. Squid tries to work around such servers, but that workaround accidently got disabled in the parser changes for 2.6. This patch makes Squid reach the workaround again, and also fixes up the slightly malformed response into a valid HTTP response. Members: src/http.c:1.430->1.431 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid/squid/src/http.c,v retrieving revision 1.430 retrieving revision 1.431 diff -u -r1.430 -r1.431 --- squid/src/http.c 15 Jul 2007 06:16:42 -0000 1.430 +++ squid/src/http.c 21 Jul 2007 21:03:35 -0000 1.431 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.430 2007/07/15 06:16:42 hno Exp $ + * $Id: http.c,v 1.431 2007/07/21 21:03:35 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -891,21 +891,23 @@ fwdFail(httpState->fwd, err); comm_close(fd); } - } else if (len == 0 && entry->mem_obj->inmem_hi == 0) { + } else if (len == 0 && entry->mem_obj->inmem_hi == 0 && !httpState->reply_hdr.size) { fwdFail(httpState->fwd, errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_BAD_GATEWAY, httpState->fwd->request)); httpState->eof = 1; comm_close(fd); } else if (len == 0) { /* Connection closed; retrieval done. */ httpState->eof = 1; - if (httpState->reply_hdr_state < 2) + if (httpState->reply_hdr_state < 2) { /* * 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. */ - httpProcessReplyHeader(httpState, buf, len); + /* Fake an "end-of-headers" to work around such broken servers */ + httpProcessReplyHeader(httpState, "\r\n", 2); + } if (entry->mem_obj->reply->sline.status == HTTP_HEADER_TOO_LARGE) { storeEntryReset(entry); fwdFail(httpState->fwd, errorCon(ERR_TOO_BIG, HTTP_BAD_GATEWAY, httpState->fwd->request));