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;

Reply via email to