You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Justin Erenkrantz <je...@ebuilt.com> on 2002/02/18 07:55:07 UTC
[PATCH] Add content-type specific filters
This adds AddOutputFilterByType directive. In our mod_deflate
conversations, I think we kept coming back to this as a real
good idea.
So, a mod_deflate admin could do:
AddOutputFilterByType DEFLATE text/html
and mod_deflate would only work on text/html requests.
Notice that it sticks the content-type info in extension_mappings.
I'm not really that what it's intended for, but hey, it works. ;-)
I think this patch is fine in and of itself, but it doesn't work as
expected due to the mod_dir/mod_negotiation showstopper (yeah, it's a
showstopper for the next release). I've got some hacky code that
fixes up ap_internal_fast_redirect() to propogate the filters on a
redirect. But, it just showcases how badly broken fast_redirect is,
so I'd rather we just toss it. -- justin
Index: modules/http/mod_mime.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/mod_mime.c,v
retrieving revision 1.76
diff -u -r1.76 mod_mime.c
--- modules/http/mod_mime.c 8 Dec 2001 02:04:51 -0000 1.76
+++ modules/http/mod_mime.c 18 Feb 2002 06:48:09 -0000
@@ -392,6 +392,9 @@
AP_INIT_ITERATE2("AddOutputFilter", add_extension_info,
(void *)APR_XtOffsetOf(extension_info, output_filters), OR_FILEINFO,
"output filter name (or ; delimited names) followed by one or more file extensions"),
+AP_INIT_ITERATE2("AddOutputFilterByType", add_extension_info,
+ (void *)APR_XtOffsetOf(extension_info, output_filters), OR_FILEINFO,
+ "output filter name (or ; delimited names) followed by one or more file extensions"),
AP_INIT_ITERATE2("AddType", add_extension_info,
(void *)APR_XtOffsetOf(extension_info, forced_type), OR_FILEINFO,
"a mime type followed by one or more file extensions"),
@@ -873,8 +876,25 @@
}
if (r->content_type) {
- content_type *ctp;
- int override = 0;
+ content_type *ctp;
+ int override = 0;
+ const extension_info *ctinfo = NULL;
+
+ /* Do content-type specific info before we add language
+ * decoration.
+ */
+ ctinfo = (extension_info*)apr_hash_get(conf->extension_mappings,
+ r->content_type,
+ APR_HASH_KEY_STRING);
+ if (ctinfo) {
+ if (ctinfo->output_filters && r->proxyreq == PROXYREQ_NONE) {
+ const char *filter, *filters = ctinfo->output_filters;
+ while (*filters
+ && (filter = ap_getword(r->pool, &filters, ';'))) {
+ ap_add_output_filter(filter, NULL, r, r->connection);
+ }
+ }
+ }
if ((ctp = analyze_ct(r, r->content_type))) {
param *pp = ctp->param;
Re: [PATCH] Add content-type specific filters
Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Mon, Feb 18, 2002 at 04:43:01PM -0800, Justin Erenkrantz wrote:
> + while (f) {
> + if (!strcasecmp(base_info->name, f->name)) {
> + found = 1;
> + }
> + f = f->next;
Oh, there should be a break right after "found = 1;" -- justin
Re: [PATCH] Add content-type specific filters
Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Mon, Feb 18, 2002 at 09:49:27AM -0600, William A. Rowe, Jr. wrote:
> -1. It requires the user to install mod_mime. mod_mime handles mime types
> for files, if the server is filesystem-less (a distinct possibility in 2.1 and
> beyond, even in 2.0 for that matter, but not trivial) then they lose this legit
> directive.
>
> Please make this a core directive, as I've already moved SetHandler and the
> Set{Input|Output}Filter directives. No sense in populating more cruft in the
> wrong module.
Well, it wasn't like I didn't see this veto coming a mile away.
This patch is much more complicated since it has to essentially
duplicate logic that mod_mime already has.
I'll commit this soon-ish unless you scream. -- justin
Index: include/ap_mmn.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/ap_mmn.h,v
retrieving revision 1.32
diff -u -r1.32 ap_mmn.h
--- include/ap_mmn.h 29 Jan 2002 00:00:39 -0000 1.32
+++ include/ap_mmn.h 19 Feb 2002 00:17:04 -0000
@@ -95,12 +95,13 @@
* 20020118 (2.0.31-dev) Input filtering split of blocking and mode
* 20020127 (2.0.31-dev) bump for pre_mpm hook change
* 20020128 (2.0.31-dev) bump for pre_config hook change
+ * 20020218 (2.0.33-dev) bump for AddOutputFilterByType directive
*/
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20020128
+#define MODULE_MAGIC_NUMBER_MAJOR 20020218
#endif
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */
Index: include/http_core.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/http_core.h,v
retrieving revision 1.61
diff -u -r1.61 http_core.h
--- include/http_core.h 27 Jan 2002 19:12:56 -0000 1.61
+++ include/http_core.h 19 Feb 2002 00:17:04 -0000
@@ -507,6 +507,8 @@
const char *input_filters; /* forced with SetInputFilters */
int accept_path_info; /* forced with AcceptPathInfo */
+ apr_hash_t *ct_output_filters; /* added with AddOutputFilterByType */
+
/*
* What attributes/data should be included in ETag generation?
*/
Index: server/core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.148
diff -u -r1.148 core.c
--- server/core.c 17 Feb 2002 19:21:31 -0000 1.148
+++ server/core.c 19 Feb 2002 00:17:13 -0000
@@ -183,6 +183,56 @@
return (void *)conf;
}
+/*
+ * Overlay one hash table of ct_output_filters onto another
+ */
+static void *merge_ct_filters(apr_pool_t *p,
+ const void *key,
+ apr_ssize_t klen,
+ const void *overlay_val,
+ const void *base_val,
+ const void *data)
+{
+ ap_filter_rec_t *cur;
+ const ap_filter_rec_t *overlay_info = (const ap_filter_rec_t *)overlay_val;
+ const ap_filter_rec_t *base_info = (const ap_filter_rec_t *)base_val;
+
+ cur = NULL;
+
+ while (overlay_info) {
+ ap_filter_rec_t *new;
+
+ new = apr_pcalloc(p, sizeof(ap_filter_rec_t));
+ new->name = apr_pstrdup(p, overlay_info->name);
+ new->next = cur;
+ cur = new;
+ overlay_info = overlay_info->next;
+ }
+
+ while (base_info) {
+ ap_filter_rec_t *f;
+ int found = 0;
+
+ /* We can't have dups. */
+ f = cur;
+ while (f) {
+ if (!strcasecmp(base_info->name, f->name)) {
+ found = 1;
+ }
+ f = f->next;
+ }
+ if (!found) {
+ f = apr_pcalloc(p, sizeof(ap_filter_rec_t));
+ f->name = apr_pstrdup(p, base_info->name);
+ f->next = cur;
+ cur = f;
+ }
+ base_info = base_info->next;
+ }
+
+ return cur;
+}
+
static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
{
core_dir_config *base = (core_dir_config *)basev;
@@ -344,6 +394,21 @@
conf->input_filters = new->input_filters;
}
+ if (conf->ct_output_filters && new->ct_output_filters) {
+ conf->ct_output_filters = apr_hash_merge(a,
+ new->ct_output_filters,
+ conf->ct_output_filters,
+ merge_ct_filters,
+ NULL);
+ }
+ else if (new->ct_output_filters) {
+ conf->ct_output_filters = apr_hash_copy(a, new->ct_output_filters);
+ }
+ else if (conf->ct_output_filters) {
+ /* That memcpy above isn't enough. */
+ conf->ct_output_filters = apr_hash_copy(a, base->ct_output_filters);
+ }
+
/*
* Now merge the setting of the FileETag directive.
*/
@@ -2359,6 +2424,34 @@
}
#endif
+static const char *add_ct_output_filters(cmd_parms *cmd, void *conf_,
+ const char *arg, const char *arg2)
+{
+ core_dir_config *conf=conf_;
+ ap_filter_rec_t *old, *new;
+
+ if (!conf->ct_output_filters) {
+ conf->ct_output_filters = apr_hash_make(cmd->pool);
+ old = NULL;
+ }
+ else {
+ old = (ap_filter_rec_t*) apr_hash_get(conf->ct_output_filters, arg2,
+ APR_HASH_KEY_STRING);
+ }
+
+ new = apr_pcalloc(cmd->pool, sizeof(ap_filter_rec_t));
+ new->name = apr_pstrdup(cmd->pool, arg);
+
+ /* We found something, so let's append it. */
+ if (old) {
+ new->next = old;
+ }
+
+ apr_hash_set(conf->ct_output_filters, arg2, APR_HASH_KEY_STRING, new);
+
+ return NULL;
+}
+
static apr_status_t writev_it_all(apr_socket_t *s,
struct iovec *vec, int nvec,
apr_size_t len, apr_size_t *nbytes)
@@ -2737,6 +2830,9 @@
AP_INIT_TAKE1("SetInputFilter", ap_set_string_slot,
(void *)APR_XtOffsetOf(core_dir_config, input_filters), OR_FILEINFO,
"filter (or ; delimited list of filters) to be run on the request body"),
+AP_INIT_ITERATE2("AddOutputFilterByType", add_ct_output_filters,
+ (void *)APR_XtOffsetOf(core_dir_config, ct_output_filters), OR_FILEINFO,
+ "output filter name (or ; delimited names) followed by one or more content-types"),
/*
* These are default configuration directives that mpms can/should
@@ -2879,6 +2975,35 @@
return OK;
}
+static int core_filters_type(request_rec *r)
+{
+ core_dir_config *conf;
+ const char *ctype, *ctypes;
+
+ conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
+ &core_module);
+
+ /* We can't do anything with proxy requests or if we don't have a filter
+ * configured. */
+ if (r->proxyreq != PROXYREQ_NONE || !conf->ct_output_filters) {
+ return OK;
+ }
+
+ ctypes = r->content_type;
+
+ /* We must be able to handle decorated content-types. */
+ while (*ctypes && (ctype = ap_getword(r->pool, &ctypes, ';'))) {
+ ap_filter_rec_t *ct_filter;
+ ct_filter = apr_hash_get(conf->ct_output_filters, ctype,
+ APR_HASH_KEY_STRING);
+ while (ct_filter) {
+ ap_add_output_filter(ct_filter->name, NULL, r, r->connection);
+ ct_filter = ct_filter->next;
+ }
+ }
+
+ return OK;
+}
static int default_handler(request_rec *r)
{
@@ -3738,6 +3863,7 @@
/* FIXME: I suspect we can eliminate the need for these do_nothings - Ben */
ap_hook_type_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_hook_fixups(core_override_type,NULL,NULL,APR_HOOK_REALLY_FIRST);
+ ap_hook_fixups(core_filters_type,NULL,NULL,APR_HOOK_MIDDLE);
ap_hook_access_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_hook_create_request(core_create_req, NULL, NULL, APR_HOOK_MIDDLE);
APR_OPTIONAL_HOOK(proxy, create_req, core_create_proxy_req, NULL, NULL,
Re: [PATCH] Add content-type specific filters
Posted by "William A. Rowe, Jr." <wr...@covalent.net>.
From: "Justin Erenkrantz" <je...@ebuilt.com>
Sent: Monday, February 18, 2002 12:55 AM
> This adds AddOutputFilterByType directive. In our mod_deflate
> conversations, I think we kept coming back to this as a real
> good idea.
The idea is good.
> I think this patch is fine in and of itself,
-1. It requires the user to install mod_mime. mod_mime handles mime types
for files, if the server is filesystem-less (a distinct possibility in 2.1 and
beyond, even in 2.0 for that matter, but not trivial) then they lose this legit
directive.
Please make this a core directive, as I've already moved SetHandler and the
Set{Input|Output}Filter directives. No sense in populating more cruft in the
wrong module.
> but it doesn't work as
> expected due to the mod_dir/mod_negotiation showstopper (yeah, it's a
> showstopper for the next release).
>
> I've got some hacky code that
> fixes up ap_internal_fast_redirect() to propogate the filters on a
> redirect. But, it just showcases how badly broken fast_redirect is,
> so I'd rather we just toss it. -- justin
A definate bug, and as I raised in status, a distinct possibility :)
The only problem with -removing- it altogether is that the internal redirect
must occur by the end of the fixup()s chain or we don't know what we are about
to serve after ap_process_request, prior to ap_run_request.
Bill
Re: Optimize mod_mime was Re: [PATCH] Add content-type specific filters
Posted by Brian Pane <br...@cnet.com>.
Justin Erenkrantz wrote:
>On Mon, Feb 18, 2002 at 12:16:39AM -0800, Brian Pane wrote:
>
>>This reminds me: mod_mime needs some performance work.
>>
>>I probably won't have time to address this between now
>>and 2.0 GA, and the performance problem isn't big
>>enough to be a GA showstopper, but I'll summarize the
>>issues here in case anyone else is interested in tackling
>>the problem.
>>
>
>Hehe. I just tried to tackle it and Remove*Filter has got
>me beaten. I give up.
>
Thanks for trying. I'll try to build upon your patch when I have
time (hopefully this weekend or next).
>Also, I'll ask again, is there any function where you can pass in a
>filter name and receive the handle? (Since you only have the name,
>you can't register it.) I'm thinking we have to traverse the trie,
>right? But, there's no function now. Oh, joy. Another function
>for me to write. =)
>
I don't think there's a function like this, but I can add one.
It would basically be just add_any_filter() with most of the
code removed.
--Brian
Optimize mod_mime was Re: [PATCH] Add content-type specific filters
Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Mon, Feb 18, 2002 at 12:16:39AM -0800, Brian Pane wrote:
> This reminds me: mod_mime needs some performance work.
>
> I probably won't have time to address this between now
> and 2.0 GA, and the performance problem isn't big
> enough to be a GA showstopper, but I'll summarize the
> issues here in case anyone else is interested in tackling
> the problem.
Hehe. I just tried to tackle it and Remove*Filter has got
me beaten. I give up.
The actual splitting out of the input/output filters isn't too
bad for merging and addition. However, the semantic for remove
is that it must be propogated downward - you can't just remove it
at that level - you must propogate removals downward and do removals
at each step. The mod_mime code just can't do this cleanly. I
think the real thing to do is to have another hash for
remove_mappings.
Also, I'll ask again, is there any function where you can pass in a
filter name and receive the handle? (Since you only have the name,
you can't register it.) I'm thinking we have to traverse the trie,
right? But, there's no function now. Oh, joy. Another function
for me to write. =)
Anyway, this patch doesn't even compile, but you get the idea if
you want to pick up the pieces of my shattered dream. -- justin
Index: modules/http/mod_mime.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/mod_mime.c,v
retrieving revision 1.76
diff -u -r1.76 mod_mime.c
--- modules/http/mod_mime.c 8 Dec 2001 02:04:51 -0000 1.76
+++ modules/http/mod_mime.c 20 Feb 2002 08:13:05 -0000
@@ -106,8 +106,8 @@
char *language_type; /* Added with AddLanguage... */
char *handler; /* Added with AddHandler... */
char *charset_type; /* Added with AddCharset... */
- char *input_filters; /* Added with AddInputFilter... */
- char *output_filters; /* Added with AddOutputFilter... */
+ ap_filter_rec_t *input_filters; /* Added with AddInputFilter... */
+ ap_filter_rec_t *output_filters; /* Added with AddOutputFilter... */
} extension_info;
#define MULTIMATCH_UNSET 0
@@ -121,6 +121,8 @@
* extension_info structure */
apr_array_header_t *remove_mappings; /* A simple list, walked once */
+ ap_filter_rec_t *remove_input_filters; /* Filters that need to removed. */
+ ap_filter_rec_t *remove_output_filters;
char *default_language; /* Language if no AddLanguage ext found */
@@ -156,6 +158,8 @@
new->extension_mappings = NULL;
new->remove_mappings = NULL;
+ new->remove_input_filters = NULL;
+ new->remove_output_filters = NULL;
new->default_language = NULL;
@@ -163,6 +167,53 @@
return new;
}
+
+/* Note: does not preserve ordering. */
+static ap_filter_rec_t* copy_filters(ap_filter_rec_t *f, apr_pool_t *p)
+{
+ ap_filter_rec_t *g, *h;
+
+ h = NULL;
+
+ while (f) {
+ g = apr_pcalloc(p, sizeof(ap_filter_rec_t));
+ g->name = apr_pstrdup(p, f->name);
+ g->next = h;
+ h = g;
+ f = f->next;
+ }
+
+ return h;
+}
+
+static ap_filter_rec_t* remove_filters(ap_filter_rec_t *remove,
+ ap_filter_rec_t *list)
+{
+ ap_filter_rec_t *ret = list;
+
+ while (remove) {
+ ap_filter_rec_t *trailer = NULL;
+ list = ret;
+ while (list) {
+ if (!strcasecmp(remove->name, list->name)) {
+ if (!trailer) {
+ ret = ret->next;
+ }
+ else {
+ trailer->next = list->next;
+ }
+ }
+ else {
+ trailer = list;
+ }
+ list = list->next;
+ }
+ remove = remove->next;
+ }
+
+ return ret;
+}
+
/*
* Overlay one hash table of extension_mappings onto another
*/
@@ -193,11 +244,19 @@
if (overlay_info->charset_type) {
new_info->charset_type = overlay_info->charset_type;
}
+ /* Should we attempt to merge these filters? */
if (overlay_info->input_filters) {
- new_info->input_filters = overlay_info->input_filters;
+ new_info->input_filters = copy_filters(overlay_info->input_filters, p);
+ }
+ else if (base_info->input_filters) {
+ new_info->input_filters = copy_filters(base_info->input_filters, p);
}
if (overlay_info->output_filters) {
- new_info->output_filters = overlay_info->output_filters;
+ new_info->output_filters = copy_filters(overlay_info->output_filters,
+ p);
+ }
+ else if (base_info->output_filters) {
+ new_info->output_filters = copy_filters(base_info->output_filters, p);
}
return new_info;
@@ -258,8 +317,22 @@
if (new->extension_mappings) {
if (add->remove_mappings)
remove_items(p, add->remove_mappings, new->extension_mappings);
+ if (add->remove_input_filters &&
+ new->extension_mappings->input_filters) {
+ new->extension_mappings->input_filters =
+ remove_filters(add->remove_input_filters,
+ new->extension_mappings->input_filters);
+ }
+ if (add->remove_output_filters &&
+ new->extension_mappings->output_filters) {
+ new->extension_mappings->output_filters =
+ remove_filters(add->remove_output_filters,
+ new->extension_mappings->output_filters);
+ }
}
new->remove_mappings = NULL;
+ new->remove_output_filters = NULL;
+ new->remove_input_filters = NULL;
new->default_language = add->default_language ?
add->default_language : base->default_language;
@@ -324,6 +397,69 @@
suffix->offset = (int) (long) cmd->info;
return NULL;
}
+
+static const char *add_filter_info(cmd_parms *cmd, void *m_,
+ const char *arg, const char *arg2)
+{
+ mime_dir_config *m = (mime_dir_config *) m_;
+ extension_info *exinfo;
+ const char *filter, *filters;
+ ap_filter_rec_t *old, *new;
+
+ if (!m->extension_mappings) {
+ m->extension_mappings = apr_hash_make(cmd->pool);
+ exinfo = NULL;
+ }
+ else {
+ exinfo = (extension_info*)apr_hash_get(m->extension_mappings, arg2,
+ APR_HASH_KEY_STRING);
+ }
+ if (!exinfo) {
+ exinfo = apr_pcalloc(cmd->pool, sizeof(extension_info));
+ apr_hash_set(m->extension_mappings, arg2,
+ APR_HASH_KEY_STRING, exinfo);
+ }
+
+ filters = arg;
+ while (*filters && (filter = ap_getword(cmd->pool, &filters, ';'))) {
+ new = apr_pcalloc(cmd->pool, sizeof(ap_filter_rec_t));
+ new->name = apr_pstrdup(cmd->pool, filter);
+ /* cmd->info == 0 -> input_filters
+ * cmd->info == 1 -> output_filters
+ */
+ if (!cmd->info) {
+ new->next = exinfo->input_filters;
+ exinfo->input_filters = new;
+ }
+ else {
+ new->next = exinfo->output_filters;
+ exinfo->output_filters = new;
+ }
+ }
+ return NULL;
+}
+
+static const char *remove_filter_info(cmd_parms *cmd, void *m_,
+ const char *arg, const char *arg2)
+{
+ mime_dir_config *m = (mime_dir_config *) m_;
+ ap_filter_rec_t *new;
+
+ new = apr_pcalloc(cmd->pool, sizeof(ap_filter_rec_t));
+ new->name = apr_pstrdup(cmd->pool, arg);
+ /* cmd->info == 0 -> input_filters
+ * cmd->info == 1 -> output_filters
+ */
+ if (!cmd->info) {
+ new->next = m->remove_input_filters;
+ m->remove_input_filters = new;
+ }
+ else {
+ new->next = m->remove_output_filters;
+ m->remove_output_filters = new;
+ }
+ return NULL;
+}
/* The sole bit of server configuration that the MIME module has is
* the name of its config file, so...
@@ -383,14 +519,12 @@
AP_INIT_ITERATE2("AddHandler", add_extension_info,
(void *)APR_XtOffsetOf(extension_info, handler), OR_FILEINFO,
"a handler name followed by one or more file extensions"),
-AP_INIT_ITERATE2("AddInputFilter", add_extension_info,
- (void *)APR_XtOffsetOf(extension_info, input_filters), OR_FILEINFO,
+AP_INIT_ITERATE2("AddInputFilter", add_filter_info, 0, OR_FILEINFO,
"input filter name (or ; delimited names) followed by one or more file extensions"),
AP_INIT_ITERATE2("AddLanguage", add_extension_info,
(void *)APR_XtOffsetOf(extension_info, language_type), OR_FILEINFO,
"a language (e.g., fr), followed by one or more file extensions"),
-AP_INIT_ITERATE2("AddOutputFilter", add_extension_info,
- (void *)APR_XtOffsetOf(extension_info, output_filters), OR_FILEINFO,
+AP_INIT_ITERATE2("AddOutputFilter", add_filter_info, 1, OR_FILEINFO,
"output filter name (or ; delimited names) followed by one or more file extensions"),
AP_INIT_ITERATE2("AddType", add_extension_info,
(void *)APR_XtOffsetOf(extension_info, forced_type), OR_FILEINFO,
@@ -409,14 +543,12 @@
AP_INIT_ITERATE("RemoveHandler", remove_extension_info,
(void *)APR_XtOffsetOf(extension_info, handler), OR_FILEINFO,
"one or more file extensions"),
-AP_INIT_ITERATE("RemoveInputFilter", remove_extension_info,
- (void *)APR_XtOffsetOf(extension_info, input_filters), OR_FILEINFO,
+AP_INIT_ITERATE("RemoveInputFilter", remove_filter_info, 0, OR_FILEINFO,
"one or more file extensions"),
AP_INIT_ITERATE("RemoveLanguage", remove_extension_info,
(void *)APR_XtOffsetOf(extension_info, language_type), OR_FILEINFO,
"one or more file extensions"),
-AP_INIT_ITERATE("RemoveOutputFilter", remove_extension_info,
- (void *)APR_XtOffsetOf(extension_info, output_filters), OR_FILEINFO,
+AP_INIT_ITERATE("RemoveOutputFilter", remove_filter_info, 1, OR_FILEINFO,
"one or more file extensions"),
AP_INIT_ITERATE("RemoveType", remove_extension_info,
(void *)APR_XtOffsetOf(extension_info, forced_type), OR_FILEINFO,
@@ -837,19 +969,19 @@
* hook, which may be too early (dunno.)
*/
if (exinfo->input_filters && r->proxyreq == PROXYREQ_NONE) {
- const char *filter, *filters = exinfo->input_filters;
- while (*filters
- && (filter = ap_getword(r->pool, &filters, ';'))) {
- ap_add_input_filter(filter, NULL, r, r->connection);
+ ap_filter_rec_t *f = exinfo->input_filters;
+ while (f) {
+ ap_add_input_filter(f->name, NULL, r, r->connection);
+ f = f->next;
}
if (conf->multimatch & MULTIMATCH_FILTERS)
found = 1;
}
if (exinfo->output_filters && r->proxyreq == PROXYREQ_NONE) {
- const char *filter, *filters = exinfo->output_filters;
- while (*filters
- && (filter = ap_getword(r->pool, &filters, ';'))) {
- ap_add_output_filter(filter, NULL, r, r->connection);
+ ap_filter_rec_t *f = exinfo->output_filters;
+ while (f) {
+ ap_add_output_filter(f->name, NULL, r, r->connection);
+ f = f->next;
}
if (conf->multimatch & MULTIMATCH_FILTERS)
found = 1;
Re: [PATCH] Add content-type specific filters
Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Mon, Feb 18, 2002 at 12:16:39AM -0800, Brian Pane wrote:
> This reminds me: mod_mime needs some performance work.
Probably. One other thing that would be nice is if we could retrieve
the filter handle from the ap_filter_t structure. That would make it
easy to add filters to another request if we have the ap_filter_t.
I'm thinking of my mods to ap_internal_fast_redirect(). -- justin
Re: [PATCH] Add content-type specific filters
Posted by Brian Pane <bp...@pacbell.net>.
>
>
>+ if (ctinfo) {
>+ if (ctinfo->output_filters && r->proxyreq == PROXYREQ_NONE) {
>+ const char *filter, *filters = ctinfo->output_filters;
>+ while (*filters
>+ && (filter = ap_getword(r->pool, &filters, ';'))) {
>+ ap_add_output_filter(filter, NULL, r, r->connection);
>+ }
>+ }
>+ }
>
This reminds me: mod_mime needs some performance work.
I probably won't have time to address this between now
and 2.0 GA, and the performance problem isn't big
enough to be a GA showstopper, but I'll summarize the
issues here in case anyone else is interested in tackling
the problem.
* With this patch, there are now two loops in find_ct()
that use ap_getword() to separate words from a
semicolon-delimited list on every request. This parsing
really should happen at config time, not request time.
* Also, the ap_add_output_filter() call is somewhat slow.
It runs in roughly O(n) time, where n==strlen(filter).
The O(1)-time alternative is to use ap_add_output_filter_handle()
in cases where it's possible to do the filter-name-to-filter
lookup in advance.
A faster approach would be to store the filter metadata as
a list of objects, instead of a semicolon-delimited string:
During config processing, pre-parse the semicolon-delimited
list, and create a linked list out of the filter names.
Then, for each filter name in the list, try to look up the
filter associated with that name. If the lookup succeeds,
store the corresponding filter handle in that node in the
linked list. (Even if a new filter is later installed with
the same name, that's okay; the filter handle is a pointer-to-
pointer object that will always point to whatever the current
filter for that name is.)
With this list created during config processing, the request
processing would look something like this:
for each node N in the linked list {
if (N->filter_handle != NULL) {
ap_add_output_filter_handle(N->filter_handle, ...);
}
else {
ap_add_output_filter(N->filter_name, ...);
}
}
--Brian
Default *.conf files use incorrect DocumentRoot
Posted by "Philip M. Gollucci" <ph...@sduwebship.student.umd.edu>.
A default install of
httpd-2.0_20020301051226.tar.gz
with configure
./configure --prefix=/usr/home/install/apache/2.0.32 --with-mpm=prefork
--enable-so --with-port=9595
cd /usr/home/install/apache/2.0.32/sbin
./apachectl start
Syntax error in httpd.conf
DocumentRoot must exist.
Heres are the patchs which fix it for all the *.conf files in the conf/
directory. Basically, its stuff/htdocs where it should be
stuff/share/htdocs ... I just realized the same thing happened with
cgi-bin, icons, did the same thing. Its 3:30am and I might not be
thinking straight, so I'll get opinion before I send a patch... which I
have.
END
------------------------------------------------------------------------------
Philip M. Gollucci (p6m7g8) philip@p6m7g8.com 301.314.3118
Science, Discovery, & the Universe (UMCP)
Webmaster & Webship Teacher
URL: http://www.sdu.umd.edu
EJPress.com
Database/PERL Programmer & System Admin
URL : http://www.ejournalpress.com
Resume : http://p6m7g8.com/Work/index.html