]> granicus.if.org Git - apache/commitdiff
Since the mod_mime patch was applied, here is the rest of the patch to
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Aug 2001 04:24:09 +0000 (04:24 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Aug 2001 04:24:09 +0000 (04:24 +0000)
  introduce the ForceType and SetHandler [absolute references] directly
  into the very top of the fixups phase.  This means these will always
  override _any_ mime module, not just mod_mime.  Ergo, other mime modules
  can continue to set charset, encodings, etc.  Since these are globals,
  they belong in the core.

  This highlights a very serious drawback to the type_checker hook.  By
  using run first, a module that identifies _partial_ information (maybe
  just the content type) won't pass the query on to other modules, like
  mod_mime, that might further define the encoding or charset.  The
  type_checker hook should clearly become a run-all, and the modules should
  decline if they see someone ahead of them answered a question they were
  going to try to figure.

  Which means - if type_checker becomes RUN_ALL - this new override hook
  fn should become a type_checker again - and RUN_REALLY_FIRST, and let
  other modules _choose_ not to override this election.  (We can run it
  again at the end, for a recount ;)  Votes?

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

include/http_core.h
server/core.c

index 1193fb37e0b4b4d9bf2ca633da288313be772a8f..424ac90004021c06d74db0ff5b8d9d160ad81eca 100644 (file)
@@ -463,8 +463,10 @@ typedef struct {
     interpreter_source_e script_interpreter_source;
 #endif    
 
-    apr_array_header_t *output_filters;
-    apr_array_header_t *input_filters;
+    char *mime_type;                     /* forced with ForceType  */
+    char *handler;                       /* forced with SetHandler */
+    apr_array_header_t *output_filters;  /* forced with SetOutputFilters */
+    apr_array_header_t *input_filters;   /* forced with SetInputFilters */
 } core_dir_config;
 
 /* Per-server core configuration */
index ac1dcb0d79e0941bc60a85d1c8cb5cf599118e83..d27871df69fcf3d5dcc774bd3f62e802aad863ec 100644 (file)
@@ -160,6 +160,10 @@ static void *create_core_dir_config(apr_pool_t *a, char *dir)
     conf->add_default_charset = ADD_DEFAULT_CHARSET_UNSET;
     conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
 
+    /* Overriding all negotiation 
+     */
+    conf->mime_type = NULL;
+    conf->handler = NULL;
     conf->output_filters = apr_array_make(a, 2, sizeof(void *));
     conf->input_filters = apr_array_make(a, 2, sizeof(void *));
     return (void *)conf;
@@ -301,6 +305,15 @@ static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
            conf->add_default_charset_name = new->add_default_charset_name;
        }
     }
+
+    /* Overriding all negotiation 
+     */
+    if (new->mime_type) {
+        conf->mime_type = new->mime_type;
+    }
+    if (new->handler) {
+        conf->handler = new->handler;
+    }
     conf->output_filters = apr_array_append(a, base->output_filters, 
                                              new->output_filters);
     conf->input_filters = apr_array_append(a, base->input_filters,
@@ -2817,6 +2830,13 @@ AP_INIT_TAKE12("RLimitNPROC", set_limit_nproc,
 AP_INIT_TAKE12("RLimitNPROC", no_set_limit, NULL,
    OR_ALL, "soft/hard limits for max number of processes per uid"),
 #endif
+
+AP_INIT_TAKE1("ForceType", ap_set_string_slot_lower, 
+       (void *)APR_XtOffsetOf(core_dir_config, mime_type), OR_FILEINFO,
+     "a mime type that overrides other configured type"),
+AP_INIT_TAKE1("SetHandler", ap_set_string_slot_lower, 
+       (void *)APR_XtOffsetOf(core_dir_config, handler), OR_FILEINFO,
+   "a handler name that overrides any other configured handler"),
 AP_INIT_ITERATE("SetOutputFilter", add_filter, NULL, OR_FILEINFO,
    "filters to be run"),
 AP_INIT_ITERATE("SetInputFilter", add_input_filter, NULL, OR_FILEINFO,
@@ -2931,6 +2951,25 @@ static int core_map_to_storage(request_rec *r)
 
 static int do_nothing(request_rec *r) { return OK; }
 
+
+static int core_override_type(request_rec *r)
+{
+    core_dir_config *conf = 
+        (core_dir_config *)ap_get_module_config(r->per_dir_config,
+                                               &core_module);
+
+    /* Check for overrides with ForceType / SetHandler
+     */
+    if (conf->mime_type && strcmp(conf->mime_type, "none"))
+        r->content_type = conf->mime_type;
+
+    if (conf->handler && strcmp(conf->handler, "none"))
+        r->handler = conf->handler;
+
+    return OK;
+}
+
+
 static int default_handler(request_rec *r)
 {
     apr_bucket_brigade *bb;
@@ -3372,8 +3411,9 @@ static void register_hooks(apr_pool_t *p)
     ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_open_logs(core_open_logs,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_handler(default_handler,NULL,NULL,APR_HOOK_REALLY_LAST);
-    /* FIXME: I suspect we can eliminate the need for these - Ben */
+    /* 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_access_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_create_request(core_create_req, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_pre_mpm(ap_create_scoreboard, NULL, NULL, APR_HOOK_MIDDLE);