summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CHANGES5
-rw-r--r--include/http_core.h3
-rw-r--r--include/http_protocol.h5
-rw-r--r--server/core.c70
-rw-r--r--server/util_script.c2
5 files changed, 52 insertions, 33 deletions
diff --git a/CHANGES b/CHANGES
index 68499a7e64..a52c6bbdc5 100644
--- 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.
diff --git a/include/http_core.h b/include/http_core.h
index 24375515c6..1fd8ab69f2 100644
--- a/include/http_core.h
+++ b/include/http_core.h
@@ -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 *);
diff --git a/include/http_protocol.h b/include/http_protocol.h
index 8aa5b0d3c5..ae9d801a25 100644
--- a/include/http_protocol.h
+++ b/include/http_protocol.h
@@ -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.
*/
diff --git a/server/core.c b/server/core.c
index 7fb15c518f..37be31056d 100644
--- a/server/core.c
+++ b/server/core.c
@@ -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,
diff --git a/server/util_script.c b/server/util_script.c
index ba6d49cfae..36ad107c34 100644
--- a/server/util_script.c
+++ b/server/util_script.c
@@ -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