--------------------- PatchSet 11355 Date: 2007/03/26 23:08:00 Author: hno Branch: SQUID_2_6 Tag: (none) Log: MFC: Make sure reply headers gets sent even if there is no body available yet The change to support chunked encoding reordered where the HTTP headers gets added to the entry and they are now added while the headers are being parsed while ENTRY_HDR_WAIT is still in effect. To counter this temporarily buffer the entry while processing the headers, releasing the buffer once processing is complete (including immediately available body chunk if any) Merged changes: 2007/02/24 09:57:06 hno +8 -1 Make sure reply headers gets sent even if there is no body available yet 2007/02/24 10:58:30 hno +9 -1 Adjust handlign of aborted requests to deal properly with buffered responses Members: src/http.c:1.419.2.6->1.419.2.7 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid/squid/src/http.c,v retrieving revision 1.419.2.6 retrieving revision 1.419.2.7 diff -u -r1.419.2.6 -r1.419.2.7 --- squid/src/http.c 12 Mar 2007 22:27:09 -0000 1.419.2.6 +++ squid/src/http.c 26 Mar 2007 23:08:00 -0000 1.419.2.7 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.419.2.6 2007/03/12 22:27:09 hno Exp $ + * $Id: http.c,v 1.419.2.7 2007/03/26 23:08:00 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -633,6 +633,7 @@ int fd = httpState->fd; int complete = httpState->eof; int keep_alive = !httpState->eof; + storeBuffer(entry); while (len > 0) { if (httpState->chunk_size > 0) { size_t size = len; @@ -707,6 +708,15 @@ return; } } + storeBufferFlush(entry); + if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { + /* + * the above storeBufferFlush() call could ABORT this entry, + * in that case, the server FD should already be closed. + * there's nothing for us to do. + */ + return; + } if (!httpState->chunk_size && !httpState->flags.chunked) complete = 1; if (!complete && len == 0) { @@ -912,6 +922,12 @@ return; } else { if (httpState->reply_hdr_state < 2) { + /* Temporarily buffer the entry. Main purpose is to ensure it gets + * flushed to the client side when the headers is complete as + * ENTRY_HDR_WAIT may delay the callback. It's flushed by + * httpAppendBody(). + */ + storeBuffer(entry); done = httpProcessReplyHeader(httpState, buf, len); if (httpState->reply_hdr_state == 2) { http_status s = entry->mem_obj->reply->sline.status;