]> granicus.if.org Git - apache/commitdiff
Final commit to add ap_rset_content_type accessor. Add AddOutputFiltersbyType
authorBill Stoddard <stoddard@apache.org>
Wed, 20 Mar 2002 02:05:43 +0000 (02:05 +0000)
committerBill Stoddard <stoddard@apache.org>
Wed, 20 Mar 2002 02:05:43 +0000 (02:05 +0000)
filters during call to ap_rset_content_type()

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94028 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/http_core.h
include/http_protocol.h
server/core.c
server/util_script.c

diff --git a/CHANGES b/CHANGES
index 68499a7e64b45994b5f424223cc7aacb07990b2c..a52c6bbdc59bb259fab5b8d342897c11cffb952b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,9 @@
 Changes with Apache 2.0.34-dev
+  *) Add accessor function to set r->content_type. From now on,
+     ap_rset_content_type() should be used to set r->content_type.
+     This change is required to properly implement the 
+     AddOutputFilterByType configuration directive.
+     [Bill Stoddard, Sander Striker, Ryan Bloom]
 
   *) Add new M_FOO symbols for the WebDAV/DeltaV methods specified by
      RFC 3253. Improved the method name/number mapping functions.
index 24375515c69bb0b6445983263f34db724bc23e7d..1fd8ab69f2eac1794a575ece80b9a3a304bcc917 100644 (file)
@@ -538,6 +538,9 @@ typedef struct {
     apr_array_header_t *sec_url;
 } core_server_config;
 
+/* for AddOutputFiltersByType in core.c */
+void ap_add_output_filters_by_type(request_rec *r);
+
 /* for http_config.c */
 void ap_core_reorder_directories(apr_pool_t *, server_rec *);
 
index 8aa5b0d3c54c3279b915cc1f033a413656a958f5..ae9d801a25d7692646c77a414fbf9f6c9b5f8163 100644 (file)
@@ -320,6 +320,11 @@ AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
  */
 AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
     
+/**
+ *
+ */
+AP_DECLARE(void) ap_rset_content_type(char *str, request_rec *r);
+
 /* Hmmm... could macrofy these for now, and maybe forever, though the
  * definitions of the macros would get a whole lot hairier.
  */
index 7fb15c518fe2402b1881d2272736c10e7575e49e..37be31056d85c8970c05c3989a3a17a463ee65e6 100644 (file)
@@ -2550,6 +2550,43 @@ static const char *add_ct_output_filters(cmd_parms *cmd, void *conf_,
 
     return NULL;
 }
+/* 
+ * Insert filters requested by the AddOutputFiltersByType 
+ * configuration directive. We cannot add filters based 
+ * on content-type until after the handler has started 
+ * to run. Only then do we reliabily know the content-type.
+ */
+void ap_add_output_filters_by_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, no content-types or if
+     * we don't have a filter configured.
+     */
+    if (r->proxyreq != PROXYREQ_NONE || !r->content_type ||
+        !conf->ct_output_filters) {
+        return;
+    }
+
+    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;
+}
 
 static apr_status_t writev_it_all(apr_socket_t *s,
                                   struct iovec *vec, int nvec,
@@ -3058,7 +3095,7 @@ static int core_override_type(request_rec *r)
     /* Check for overrides with ForceType / SetHandler
      */
     if (conf->mime_type && strcmp(conf->mime_type, "none"))
-        r->content_type = conf->mime_type;
+        ap_rset_content_type((char*) conf->mime_type, r);
 
     if (conf->handler && strcmp(conf->handler, "none"))
         r->handler = conf->handler;
@@ -3081,37 +3118,7 @@ static int core_override_type(request_rec *r)
     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, no content-types or if
-     * we don't have a filter configured.
-     */
-    if (r->proxyreq != PROXYREQ_NONE || !r->content_type ||
-        !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)
 {
@@ -4019,7 +4026,6 @@ static void register_hooks(apr_pool_t *p)
     /* 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,
index ba6d49cfae7fd1b7b1df5bfe64da64e366b05011..36ad107c345b84c35bbb9b330304c7807d6a2e5d 100644 (file)
@@ -569,7 +569,7 @@ AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
 
            tmp = apr_pstrdup(r->pool, l);
            ap_content_type_tolower(tmp);
-           r->content_type = tmp;
+           ap_rset_content_type(tmp, r);
        }
        /*
         * If the script returned a specific status, that's what