From: Paul J. Reder Date: Wed, 7 Jan 2004 02:49:46 +0000 (+0000) Subject: Backporting the following from Apache 2.1-dev to 2.0.49-dev: X-Git-Tag: 2.0.49~244 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5254a96731bf9f22fd4371bef206fa33f2c9df0;p=thirdparty%2Fapache%2Fhttpd.git Backporting the following from Apache 2.1-dev to 2.0.49-dev: *) 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. Reviewed by: trawick, stoddard git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@102210 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 74b09289c95..509e3e4262a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ Changes with Apache 2.0.49 + *) 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] + *) Add Polish translation of error messages. PR 25101. [Tomasz Kepczynski ] diff --git a/STATUS b/STATUS index f58ecfc8f60..03055913844 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2004/01/04 15:07:04 $] +Last modified at [$Date: 2004/01/07 02:49:45 $] Release: @@ -87,18 +87,7 @@ PATCHES TO BACKPORT FROM 2.1 * Fix segfault in mod_mem_cache cache_insert() due to cache size becoming negative. PR: 21285, 21287 http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/experimental/mod_mem_cache.c?r1=1.99&r2=1.100 - +1: stoddard - - * 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. - PR: 19794, 24884, and 25123. - http://cvs.apache.org/viewcvs.cgi/httpd-2.0/include/http_protocol.h?r1=1.84&r2=1.85 - http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/http/http_protocol.c?r1=1.473&r2=1.474 - http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/metadata/mod_expires.c?r1=1.48&r2=1.49 - nd: yes, it's a minor bump - +1: rederpj, trawick (requires minor MMN bump I believe), stoddard + +1: stoddard, rederpj * Replace some of the mutex locking in the worker MPM with atomic operations for higher concurrency. diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 1e45dcadae7..7d614e55472 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -115,6 +115,7 @@ * 20020903.3 (2.0.46-dev) allow_encoded_slashes added to core_dir_config * 20020903.4 (2.0.47-dev) add ap_is_recursion_limit_exceeded() * 20020903.5 (2.0.49-dev) add ap_escape_errorlog_item() + * 20020903.6 (2.0.49-dev) add insert_error_filter hook */ #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */ @@ -122,7 +123,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20020903 #endif -#define MODULE_MAGIC_NUMBER_MINOR 5 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 6 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/http_protocol.h b/include/http_protocol.h index 7683a63e259..9e879122a12 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 8ba0d9d99c1..7be48da8600 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. @@ -2325,6 +2330,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 47620898db3..b2d31569bd0 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; @@ -548,6 +549,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); }