Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 36198 invoked by uid 500); 1 Aug 2003 17:19:39 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 36182 invoked from network); 1 Aug 2003 17:19:39 -0000 From: =?ISO-8859-1?Q?Andr=E9?= Malo Subject: Re: better hook for mod_rewrite forcetype feature Date: Fri, 01 Aug 2003 19:18:02 +0200 References: Lines: 88 Organization: TIMTOWTDI MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1869434.5Qp25ROHkV" Content-Transfer-Encoding: 7Bit To: dev@httpd.apache.org Message-ID: X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --nextPart1869434.5Qp25ROHkV Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable * Andr=E9 Malo wrote: > In order to really make sure, that the mod_rewrite forcetype [T=3D...] take= s > 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 b= e > 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=3D...] i= n > server context disables multiviews. A working patch is attached. I'll commit it within some time if nobody objects. nd --nextPart1869434.5Qp25ROHkV Content-Type: text/x-diff; name="fixupmime.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fixupmime.patch" Index: modules/mappers/mod_rewrite.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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=0931 Jul 2003 16:56:28 -0000=091.209 +++ modules/mappers/mod_rewrite.c=091 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 - [E=3D...,CO=3D...]') + * (`RewriteRule - [E=3D...,CO=3D...,T=3D...]') */ if (output[0] =3D=3D '-' && !output[1]) { do_expand_env(r, p->env, briRR, briRC); do_expand_cookie(r, p->cookie, briRR, briRC); if (p->forced_mimetype !=3D NULL) { + apr_table_setn(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR, + p->forced_mimetype); if (perdir =3D=3D NULL) { - /* In the per-server context we can force the MIME-typ= e - * the correct way by notifying our MIME-type hook han= dler - * to do the job when the MIME-type API stage is reach= ed. - */ rewritelog(r, 2, "remember %s to have MIME-type '%s'",= r->filename, p->forced_mimetype); - apr_table_setn(r->notes, REWRITE_FORCED_MIMETYPE_NOTEV= AR, - p->forced_mimetype); } else { - /* In per-directory context we operate in the Fixup AP= I hook - * which is after the MIME-type hook, so our MIME-type= handler - * has no chance to set r->content_type. And because w= e 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-confo= rming. - * But it's the only chance we have... - */ rewritelog(r, 1, "[per-dir %s] force %s to have MIME-t= ype " "'%s'", perdir, r->filename, p->forced_mime= type); - ap_set_content_type(r, p->forced_mimetype); } } return 2; @@ -4682,11 +4668,6 @@ */ static const char * const aszPre[]=3D{ "mod_proxy.c", NULL }; =20 - /* check type before mod_mime, so that [T=3Dfoo/bar] will not be - * overridden by AddType definitions. - */ - static const char * const ct_aszSucc[]=3D{ "mod_mime.c", NULL }; - APR_REGISTER_OPTIONAL_FN(ap_register_rewrite_mapfunc); =20 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); =20 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_MID= DLE); } =20 /* the main config structure */ --nextPart1869434.5Qp25ROHkV--