From 3e85c7882d0de67ca85ecf53a469e390376fa921 Mon Sep 17 00:00:00 2001 From: "Paul J. Reder" Date: Fri, 12 Dec 2003 17:03:59 +0000 Subject: [PATCH] *) Add a hook (insert_error_filter) to allow filters to re-insert themselves during processing of error responses. Enable mod_expires to use the new hook to include Expires headers in valid error responses. This addresses an RFC violation. It fixes PRs 19794, 24884, and 25123. [Paul J. Reder] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102038 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 6 ++++++ include/http_protocol.h | 7 +++++++ modules/http/http_protocol.c | 7 +++++++ modules/metadata/mod_expires.c | 2 ++ 4 files changed, 22 insertions(+) diff --git a/CHANGES b/CHANGES index cb3ca0556d..3899cd0c73 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,12 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) Add a hook (insert_error_filter) to allow filters to re-insert + themselves during processing of error responses. Enable mod_expires + to use the new hook to include Expires headers in valid error + responses. This addresses an RFC violation. It fixes PRs 19794, + 24884, and 25123. [Paul J. Reder] + *) Fix and parsing to require a closing '>' in the initial container. PR 25414. [Geoffrey Young ] diff --git a/include/http_protocol.h b/include/http_protocol.h index 32c2c64ccf..1a7c78df05 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -74,6 +74,13 @@ extern "C" { * @package HTTP protocol handling */ +/** + * This hook allows modules to insert filters for the current error response + * @param r the current request + * @ingroup hooks + */ +AP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r)) + /* This is an optimization. We keep a record of the filter_rec that * stores the old_write filter, so that we can avoid strcmp's later. */ diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index ce7c60a195..2623d25d4c 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -182,6 +182,11 @@ static const char * const status_lines[RESPONSE_CODES] = "510 Not Extended" }; +APR_HOOK_STRUCT( + APR_HOOK_LINK(insert_error_filter) +) + +AP_IMPLEMENT_HOOK_VOID(insert_error_filter, (request_rec *r), (r)) /* The index of the first bit field that is used to index into a limit * bitmask. M_INVALID + 1 to METHOD_NUMBER_LAST. @@ -2342,6 +2347,8 @@ AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error) r->output_filters = r->proto_output_filters; + ap_run_insert_error_filter(r); + /* * It's possible that the Location field might be in r->err_headers_out * instead of r->headers_out; use the latter if possible, else the diff --git a/modules/metadata/mod_expires.c b/modules/metadata/mod_expires.c index 44a63d56d7..3025e3318e 100644 --- a/modules/metadata/mod_expires.c +++ b/modules/metadata/mod_expires.c @@ -205,6 +205,7 @@ #include "http_config.h" #include "http_log.h" #include "http_request.h" +#include "http_protocol.h" typedef struct { int active; @@ -585,6 +586,7 @@ static void register_hooks(apr_pool_t *p) { ap_register_output_filter("MOD_EXPIRES", expires_filter, NULL, AP_FTYPE_CONTENT_SET); + ap_hook_insert_error_filter(expires_insert_filter, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_insert_filter(expires_insert_filter, NULL, NULL, APR_HOOK_MIDDLE); } -- 2.50.1