From b31bf6e631b8d7a5090db1460e348a8e14f9af4f Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Tue, 14 Nov 2000 06:07:40 +0000 Subject: [PATCH] Make the header filter decide if a body should be sent. This gives us a chance to compute the proper content-length before we try to send a set of headers. If a handler wants to ignore the HEAD method, then it can either just return from the handler function or pass an EOS bucket down the filter stack. Either method will still get the headers sent to the client. This change allows handlers to actually run the request like it is a GET request. The core itself will then ensure that no body is sent. This allows us to get more information about the request before sending out the headers for the HEAD request. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86954 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_protocol.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index e7a90b2341..d770dee0d3 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -2410,6 +2410,9 @@ static int ap_set_byterange(request_rec *r) return num_ranges; } +typedef struct header_filter_cts { + int headers_sent; +} header_filter_ctx; AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, ap_bucket_brigade *b) { int i; @@ -2420,9 +2423,19 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, ap_bu ap_bucket_brigade *b2; apr_size_t len = 0; header_struct h; + header_filter_ctx *ctx = f->ctx; AP_DEBUG_ASSERT(!r->main); + if (!ctx) { + ctx = apr_pcalloc(r->pool, sizeof(*ctx)); + } + + if (ctx->headers_sent) { + ap_brigade_destroy(b); + return AP_REQUEST_DONE; + } + if (r->assbackwards) { r->bytes_sent = 0; r->sent_bodyct = 1; @@ -2520,6 +2533,11 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, ap_bu AP_BRIGADE_INSERT_HEAD(b2, e); ap_pass_brigade(f->next, b2); + if (r->header_only) { + ap_brigade_destroy(b); + return AP_REQUEST_DONE; + } + if (r->chunked) { /* The coalesce filter is useful to coalesce content from the ap_r* * routines. Removing this filter should not break the server. -- 2.40.0