--------------------- PatchSet 11547 Date: 2007/07/21 21:05:55 Author: hno Branch: SQUID_2_6 Tag: (none) Log: MFC: 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. Merged changes: 2007/07/21 21:03:35 hno +6 -4 Bug #2017: Fails to work around broken servers sending just the HTTP headers Members: src/http.c:1.419.2.7->1.419.2.8 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid/squid/src/http.c,v retrieving revision 1.419.2.7 retrieving revision 1.419.2.8 diff -u -r1.419.2.7 -r1.419.2.8 --- squid/src/http.c 26 Mar 2007 23:08:00 -0000 1.419.2.7 +++ squid/src/http.c 21 Jul 2007 21:05:55 -0000 1.419.2.8 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.419.2.7 2007/03/26 23:08:00 hno Exp $ + * $Id: http.c,v 1.419.2.8 2007/07/21 21:05:55 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));