From: Ryan Bloom Date: Tue, 19 Sep 2000 20:56:09 +0000 (+0000) Subject: tart getting things setup for input filtering. All this basically does X-Git-Tag: APACHE_2_0_ALPHA_7~141 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96c98ff58b01a8adb368cf916f6676e938e6ab42;p=apache tart getting things setup for input filtering. All this basically does is add part of the infrastructure. Namely: 1) filter list in the conn_rec, which is where the input filter list must live 2) Split the register_filter into multiple functions, one to register input filters the other to register output filters. 3) Modify existing modules so they still work. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86251 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/httpd.h b/include/httpd.h index 73eb089e6a..c422b01da6 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -814,9 +814,6 @@ struct request_rec { /** A flag to determine if the eos bucket has been sent yet * @defvar int eos_sent */ int eos_sent; - /** A list of output filters to be used for this request - * @defvar ap_filter_t *filters */ - struct ap_filter_t *input_filters; /* Things placed at the end of the record to avoid breaking binary * compatibility. It would be nice to remember to reorder the entire @@ -881,6 +878,9 @@ struct conn_rec { /** send note from one module to another, must remain valid for all * requests on this conn */ apr_table_t *notes; + /** A list of input filters to be used for this request + * @defvar ap_filter_t *filters */ + struct ap_filter_t *input_filters; }; /* Per-vhost config... */ diff --git a/include/util_filter.h b/include/util_filter.h index 0f73772f0f..03ca49cf94 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -250,16 +250,27 @@ API_EXPORT(apr_status_t) ap_pass_brigade(ap_filter_t *filter, ap_bucket_brigade * The filter's callback and type should be passed. */ /** - * Register a filter for later use. This allows modules to name their filter - * functions for later addition to a specific request + * Register an input filter for later use. This allows modules to name their + * filter functions for later addition to a specific request * @param name The name to attach to the filter function * @param filter_func The filter function to name * @param The type of filter function, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION - * @deffunc void ap_register_filter(const char *name, ap_filter_func filter_func, ap_filter_type ftype) + * @deffunc void ap_register_input_filter(const char *name, ap_filter_func filter_func, ap_filter_type ftype) */ -API_EXPORT(void) ap_register_filter(const char *name, - ap_filter_func filter_func, - ap_filter_type ftype); +API_EXPORT(void) ap_register_input_filter(const char *name, + ap_filter_func filter_func, + ap_filter_type ftype); +/** + * Register an output filter for later use. This allows modules to name their + * filter functions for later addition to a specific request + * @param name The name to attach to the filter function + * @param filter_func The filter function to name + * @param The type of filter function, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION + * @deffunc void ap_register_output_filter(const char *name, ap_filter_func filter_func, ap_filter_type ftype) + */ +API_EXPORT(void) ap_register_output_filter(const char *name, + ap_filter_func filter_func, + ap_filter_type ftype); /* * ap_add_filter(): diff --git a/modules/experimental/mod_charset_lite.c b/modules/experimental/mod_charset_lite.c index 4dd5d4d21d..259852d882 100644 --- a/modules/experimental/mod_charset_lite.c +++ b/modules/experimental/mod_charset_lite.c @@ -703,7 +703,7 @@ static void charset_register_hooks(void) { ap_hook_fixups(find_code_page, NULL, NULL, AP_HOOK_MIDDLE); ap_hook_insert_filter(xlate_insert_filter, NULL, NULL, AP_HOOK_MIDDLE); - ap_register_filter(XLATEOUT_FILTER_NAME, xlate_filter, AP_FTYPE_CONTENT); + ap_register_output_filter(XLATEOUT_FILTER_NAME, xlate_filter, AP_FTYPE_CONTENT); } module charset_lite_module = diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index ec7e82dbbb..bcabe9a7d3 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -2542,7 +2542,7 @@ static const command_rec includes_cmds[] = static void register_hooks(void) { - ap_register_filter("INCLUDES", includes_filter, AP_FTYPE_CONTENT); + ap_register_output_filter("INCLUDES", includes_filter, AP_FTYPE_CONTENT); } module MODULE_VAR_EXPORT includes_module = diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 63082553ec..499bdc8844 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -3167,8 +3167,8 @@ static void register_hooks(void) * request-processing time. */ ap_hook_insert_filter(core_register_filter, NULL, NULL, AP_HOOK_MIDDLE); - ap_register_filter("CORE", core_filter, AP_FTYPE_CONNECTION + 1); - ap_register_filter("CHUNK", chunk_filter, AP_FTYPE_CONNECTION); + ap_register_output_filter("CORE", core_filter, AP_FTYPE_CONNECTION + 1); + ap_register_output_filter("CHUNK", chunk_filter, AP_FTYPE_CONNECTION); } API_VAR_EXPORT module core_module = { diff --git a/server/util_filter.c b/server/util_filter.c index 6fbd18368a..69b4779e18 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -58,7 +58,8 @@ /* ### make this visible for direct manipulation? * ### use a hash table */ -static ap_filter_rec_t *registered_filters = NULL; +static ap_filter_rec_t *registered_output_filters = NULL; +static ap_filter_rec_t *registered_input_filters = NULL; /* NOTE: Apache's current design doesn't allow a pool to be passed thu, so we depend on a global to hold the correct pool @@ -79,13 +80,15 @@ static ap_filter_rec_t *registered_filters = NULL; static apr_status_t filter_cleanup(void *ctx) { - registered_filters = NULL; + registered_output_filters = NULL; + registered_input_filters = NULL; return APR_SUCCESS; } -API_EXPORT(void) ap_register_filter(const char *name, - ap_filter_func filter_func, - ap_filter_type ftype) +static void ap_register_filter(const char *name, + ap_filter_func filter_func, + ap_filter_type ftype, + ap_filter_rec_t *reg_filter_list) { ap_filter_rec_t *frec = apr_palloc(FILTER_POOL, sizeof(*frec)); @@ -93,15 +96,31 @@ API_EXPORT(void) ap_register_filter(const char *name, frec->filter_func = filter_func; frec->ftype = ftype; - frec->next = registered_filters; - registered_filters = frec; + frec->next = reg_filter_list; + reg_filter_list = frec; apr_register_cleanup(FILTER_POOL, NULL, filter_cleanup, apr_null_cleanup); } +API_EXPORT(void) ap_register_input_filter(const char *name, + ap_filter_func filter_func, + ap_filter_type ftype) +{ + ap_register_filter(name, filter_func, ftype, + registered_input_filters); +} + +API_EXPORT(void) ap_register_output_filter(const char *name, + ap_filter_func filter_func, + ap_filter_type ftype) +{ + ap_register_filter(name, filter_func, ftype, + registered_output_filters); +} + API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r) { - ap_filter_rec_t *frec = registered_filters; + ap_filter_rec_t *frec = registered_output_filters; for (; frec != NULL; frec = frec->next) { if (!strcasecmp(name, frec->name)) {