From apache-cvs-return-6748-apmail-apache-cvs-archive=apache.org@apache.org Tue Jul 24 17:26:49 2001 Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 70040 invoked by uid 500); 24 Jul 2001 17:26:48 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 70029 invoked by uid 500); 24 Jul 2001 17:26:48 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 24 Jul 2001 17:24:05 -0000 Message-ID: <20010724172405.6772.qmail@icarus.apache.org> From: stoddard@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/http http_protocol.c X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N stoddard 01/07/24 10:24:05 Modified: modules/http http_protocol.c Log: Fix problem with the previous patch to handle HEAD requests. Now, the header_filter will stay installed in the filter chain when processing HEAD requests to intercept and discard content bodys sent by poorly written handlers. This work also points out the need for an optimization in the content_length filter to not split the brigade if the next bucket in the brigade is an EOS. Revision Changes Path 1.331 +21 -1 httpd-2.0/modules/http/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v retrieving revision 1.330 retrieving revision 1.331 diff -u -r1.330 -r1.331 --- http_protocol.c 2001/07/24 14:36:29 1.330 +++ http_protocol.c 2001/07/24 17:24:05 1.331 @@ -1064,6 +1064,10 @@ } } +typedef struct header_filter_ctx { + int headers_sent; +} header_filter_ctx; + AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter( ap_filter_t *f, apr_bucket_brigade *b) @@ -1076,9 +1080,25 @@ apr_bucket *e; apr_bucket_brigade *b2; header_struct h; + header_filter_ctx *ctx = f->ctx; AP_DEBUG_ASSERT(!r->main); + /* Handlers -should- be smart enough not to send content on HEAD requests. + * To guard against poorly written handlers, leave the header_filter + * installed (but only for HEAD requests) to intercept and discard content + * after the headers have been sent. + */ + if (r->header_only) { + if (!ctx) { + ctx = f->ctx = apr_pcalloc(r->pool, sizeof(header_filter_ctx)); + } + else if (ctx->headers_sent) { + apr_brigade_destroy(b); + return OK; + } + } + APR_BRIGADE_FOREACH(e, b) { if (e->type == &ap_bucket_type_error) { ap_bucket_error *eb = e->data; @@ -1212,7 +1232,7 @@ if (r->header_only) { apr_brigade_destroy(b); - ap_remove_output_filter(f); + ctx->headers_sent = 1; return OK; }