If you thought this patch;

>   --- mod_mime.c 2001/08/28 15:31:08 1.60
>   +++ mod_mime.c 2001/08/30 04:11:57 1.61
>   @@ -116,8 +116,6 @@
>    
>        apr_array_header_t *remove_mappings; /* A simple list, walked once */
>    
>   -    char *type;                 /* Type forced with ForceType  */
>   -    char *handler;              /* Handler forced with SetHandler */
>        char *default_language;     /* Language if no AddLanguage ext found */
>                            /* Due to the FUD about JS and charsets 
>                                     * default_charset is actually in src/main */

seemed to have nothing to do with exinfo/mime.types, you are right :(  This was
work left over from this afternoon, which I completely forgot about while debugging
the ErrorDocument as text/plain bug.

I am certain it belongs in core.c.  What I'm less certain about is why it must become
a fixups phase.  I'd like to fix this in the morning, so please read the following
diatribe and comment.

Type checking is far more complex than a 'single variable' - we can't continue this
way.  If mod_mime figures a file is Language es, and nothing more, then we need to
have mod_mime_magic finish the job.  Actually, we need to start with this forced
handler/type and end with the forced handler/type, so it's optimized (we don't want
to mod_mime_magically consume cpu) but involatile (unless a fixups hook wishes to
play games.)  So if type_checker becomes run-all - I'll make this fn run both as
very first and very last in the type_checker hook (instead of fixups.)


Bill



> wrowe       01/08/29 21:24:10
> 
>   Modified:    include  http_core.h
>                server   core.c
>   Log:
>     Since the mod_mime patch was applied, here is the rest of the patch to
>     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?
>   
>   Revision  Changes    Path
>   1.50      +4 -2      httpd-2.0/include/http_core.h
>   
>   Index: http_core.h
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/include/http_core.h,v
>   retrieving revision 1.49
>   retrieving revision 1.50
>   diff -u -r1.49 -r1.50
>   --- http_core.h 2001/08/26 05:10:17 1.49
>   +++ http_core.h 2001/08/30 04:24:09 1.50
>   @@ -463,8 +463,10 @@
>        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 */
>   
>   
>   
>   1.53      +41 -1     httpd-2.0/server/core.c
>   
>   Index: core.c
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/server/core.c,v
>   retrieving revision 1.52
>   retrieving revision 1.53
>   diff -u -r1.52 -r1.53
>   --- core.c 2001/08/28 15:45:01 1.52
>   +++ core.c 2001/08/30 04:24:09 1.53
>   @@ -160,6 +160,10 @@
>        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 @@
>        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", 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 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 @@
>        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);
>   
>   
>   
> 

Reply via email to