diff options
author | Justin Erenkrantz <jerenkrantz@apache.org> | 2002-06-28 10:40:25 +0200 |
---|---|---|
committer | Justin Erenkrantz <jerenkrantz@apache.org> | 2002-06-28 10:40:25 +0200 |
commit | 798c1dae4342323d1abc8c8b7ac1c42c8d441100 (patch) | |
tree | 6f2526d6cfafe0ad8f5becd8116bf856bc34ec6f /include | |
parent | :( (diff) | |
download | apache2-798c1dae4342323d1abc8c8b7ac1c42c8d441100.tar.xz apache2-798c1dae4342323d1abc8c8b7ac1c42c8d441100.zip |
Add a filter_init function to the filters so that a filter can execute
arbitrary code before the handlers are invoked.
This resolves an issue with incorrect 304s on If-Modified-Since mod_include
requests since ap_meets_conditions() is not aware that this is a dynamic
request and it is not possible to satisfy 304 for these requests (unless
xbithack full is on, of course). When mod_include runs as a filter, it is
too late to set any flag since the handler is responsible for calling
ap_meets_conditions(), which it should do before generating any data.
If a module doesn't need to run such arbitrary code, it can just pass NULL
as the argument and all is well.
PR: 9673
Reviewed by: Ryan Bloom and others
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95906 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r-- | include/ap_mmn.h | 3 | ||||
-rw-r--r-- | include/util_filter.h | 18 |
2 files changed, 17 insertions, 4 deletions
diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 58b7a7fc43..35b3438940 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -109,12 +109,13 @@ * 20020602 (2.0.37-dev) Bucket API change (metadata buckets) * 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time * 20020625 (2.0.40-dev) Changed conn_rec->keepalive to an enumeration + * 20020628 (2.0.40-dev) Added filter_init to filter registration functions */ #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR -#define MODULE_MAGIC_NUMBER_MAJOR 20020625 +#define MODULE_MAGIC_NUMBER_MAJOR 20020628 #endif #define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ diff --git a/include/util_filter.h b/include/util_filter.h index 88f0587947..0a9954e04a 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -153,12 +153,19 @@ typedef struct ap_filter_t ap_filter_t; * for setting the association between a name for a filter and its * associated callback (and other information). * + * If the initialization function argument passed to the registration + * functions is non-NULL, it will be called iff the filter is in the input + * or output filter chains and before any data is generated to allow the + * filter to prepare for processing. + * * The *bucket structure (and all those referenced by ->next and ->prev) * should be considered "const". The filter is allowed to modify the * next/prev to insert/remove/replace elements in the bucket list, but * the types and values of the individual buckets should not be altered. * - * The return value of a filter should be an APR status value. + * For the input and output filters, the return value of a filter should be + * an APR status value. For the init function, the return value should + * be an HTTP error code or OK if it was successful. * * @ingroup filter * @{ @@ -170,6 +177,7 @@ typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes); +typedef int (*ap_init_filter_func)(ap_filter_t *f); typedef union ap_filter_func { ap_out_filter_func out_func; @@ -242,6 +250,8 @@ struct ap_filter_rec_t { const char *name; /** The function to call when this filter is invoked. */ ap_filter_func filter_func; + /** The function to call before the handlers are invoked. */ + ap_init_filter_func filter_init_func; /** The type of filter, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION. * An AP_FTYPE_CONTENT filter modifies the data based on information * found in the content. An AP_FTYPE_CONNECTION filter modifies the @@ -259,8 +269,8 @@ struct ap_filter_rec_t { * requests get an exact copy of the main requests filter chain. */ struct ap_filter_t { - /** The internal representation of this filter. This includes - * the filter's name, type, and the actual function pointer. + /** The internal representation of this filter. This includes + * the filter's name, type, and the actual function pointer. */ ap_filter_rec_t *frec; @@ -324,6 +334,7 @@ AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter, */ AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name, ap_in_filter_func filter_func, + ap_init_filter_func filter_init, ap_filter_type ftype); /** * This function is used to register an output filter with the system. @@ -339,6 +350,7 @@ AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name, */ AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter(const char *name, ap_out_filter_func filter_func, + ap_init_filter_func filter_init, ap_filter_type ftype); /** |