httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <b...@wstoddard.com>
Subject [PATCH] AddOutputFiltersbyType
Date Fri, 15 Mar 2002 16:33:54 GMT
The essential feature of this patch is that ap_add_output_filters_by_type() is called out
of the ap_http_header_filter.

Bill

Index: include/http_core.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/http_core.h,v
retrieving revision 1.63
diff -u -r1.63 http_core.h
--- include/http_core.h 13 Mar 2002 20:47:42 -0000 1.63
+++ include/http_core.h 15 Mar 2002 16:19:06 -0000
@@ -538,6 +538,9 @@
     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: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.394
diff -u -r1.394 http_protocol.c
--- modules/http/http_protocol.c 13 Mar 2002 20:47:49 -0000 1.394
+++ modules/http/http_protocol.c 15 Mar 2002 16:19:06 -0000
@@ -1295,6 +1295,13 @@

     r->sent_bodyct = 1;         /* Whatever follows is real body stuff... */

+    /* Insert filters requested by the AddOutputFiltersByType
+     * configuration directive. Content-type filters must be
+     * inserted after the content handlers have run because
+     * only then, do we reliably know the content-type.
+     */
+    ap_add_output_filters_by_type(r);
+
     if (r->chunked) {
         /* We can't add this filter until we have already sent the headers.
          * If we add it before this point, then the headers will be chunked

Index: server/core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.162
diff -u -r1.162 core.c
--- server/core.c 13 Mar 2002 20:47:59 -0000 1.162
+++ server/core.c 15 Mar 2002 16:19:07 -0000
@@ -2545,6 +2545,43 @@

     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,
@@ -3076,37 +3113,7 @@
     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)
 {
@@ -4014,7 +4021,6 @@
     /* 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,


Mime
View raw message