* Andr� Malo wrote:

> In order to really make sure, that the mod_rewrite forcetype [T=...] takes
> effect regardless of any static configuration, I'm playing with the idea to
> hook second time into the fixup stage at LAST position. This hook would be
> responsible for setting remembered mime-type both from server-context and
> directory context. The type-checker hook of mod_rewrite would disappear
> then. (Additionally this would probably solve the problem, that [T=...] in
> server context disables multiviews.

A working patch is attached. I'll commit it within some time if nobody
objects.

nd
Index: modules/mappers/mod_rewrite.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
retrieving revision 1.209
diff -u -r1.209 mod_rewrite.c
--- modules/mappers/mod_rewrite.c	31 Jul 2003 16:56:28 -0000	1.209
+++ modules/mappers/mod_rewrite.c	1 Aug 2003 17:07:00 -0000
@@ -3544,35 +3544,21 @@
      *  we stop processing and return immediately. The only thing
      *  we have not to forget are the environment variables and
      *  cookies:
-     *  (`RewriteRule <pat> - [E=...,CO=...]')
+     *  (`RewriteRule <pat> - [E=...,CO=...,T=...]')
      */
     if (output[0] == '-' && !output[1]) {
         do_expand_env(r, p->env, briRR, briRC);
         do_expand_cookie(r, p->cookie, briRR, briRC);
         if (p->forced_mimetype != NULL) {
+            apr_table_setn(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR,
+                           p->forced_mimetype);
             if (perdir == NULL) {
-                /* In the per-server context we can force the MIME-type
-                 * the correct way by notifying our MIME-type hook handler
-                 * to do the job when the MIME-type API stage is reached.
-                 */
                 rewritelog(r, 2, "remember %s to have MIME-type '%s'",
                            r->filename, p->forced_mimetype);
-                apr_table_setn(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR,
-                               p->forced_mimetype);
             }
             else {
-                /* In per-directory context we operate in the Fixup API hook
-                 * which is after the MIME-type hook, so our MIME-type handler
-                 * has no chance to set r->content_type. And because we are
-                 * in the situation where no substitution takes place no
-                 * sub-request will happen (which could solve the
-                 * restriction). As a workaround we do it ourself now
-                 * immediately although this is not strictly API-conforming.
-                 * But it's the only chance we have...
-                 */
                 rewritelog(r, 1, "[per-dir %s] force %s to have MIME-type "
                            "'%s'", perdir, r->filename, p->forced_mimetype);
-                ap_set_content_type(r, p->forced_mimetype);
             }
         }
         return 2;
@@ -4682,11 +4668,6 @@
      */
     static const char * const aszPre[]={ "mod_proxy.c", NULL };
 
-    /* check type before mod_mime, so that [T=foo/bar] will not be
-     * overridden by AddType definitions.
-     */
-    static const char * const ct_aszSucc[]={ "mod_mime.c", NULL };
-
     APR_REGISTER_OPTIONAL_FN(ap_register_rewrite_mapfunc);
 
     ap_hook_handler(handler_redirect, NULL, NULL, APR_HOOK_MIDDLE);
@@ -4695,8 +4676,8 @@
     ap_hook_child_init(init_child, NULL, NULL, APR_HOOK_MIDDLE);
 
     ap_hook_fixups(hook_fixup, aszPre, NULL, APR_HOOK_FIRST);
+    ap_hook_fixups(hook_mimetype, aszPre, NULL, APR_HOOK_LAST);
     ap_hook_translate_name(hook_uri2file, NULL, NULL, APR_HOOK_FIRST);
-    ap_hook_type_checker(hook_mimetype, NULL, ct_aszSucc, APR_HOOK_MIDDLE);
 }
 
     /* the main config structure */

Reply via email to