Return-Path: Delivered-To: apache-cvs-archive@hyperreal.org Received: (qmail 7649 invoked by uid 6000); 21 May 1998 10:48:39 -0000 Received: (qmail 7643 invoked by alias); 21 May 1998 10:48:37 -0000 Delivered-To: apache-1.3-cvs@hyperreal.org Received: (qmail 7641 invoked by uid 168); 21 May 1998 10:48:36 -0000 Date: 21 May 1998 10:48:36 -0000 Message-ID: <19980521104836.7640.qmail@hyperreal.org> From: rse@hyperreal.org To: apache-1.3-cvs@hyperreal.org Subject: cvs commit: apache-1.3/src/modules/standard mod_rewrite.c Sender: apache-cvs-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org rse 98/05/21 03:48:36 Modified: src CHANGES src/modules/standard mod_rewrite.c Log: Make sure a MIME-type can be forced via a RewriteRule even when no substitution takes place, for instance via the following rule: RewriteRule ^myscript$ - [T=application/x-httpd-cgi] This was often requested by users (not only the submitter of the bug report) in the past to force a single script without a .cgi extension and outside any cgi-bin dirs to be executed as a CGI program. PR: 2254 Revision Changes Path 1.859 +7 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.858 retrieving revision 1.859 diff -u -r1.858 -r1.859 --- CHANGES 1998/05/21 04:11:23 1.858 +++ CHANGES 1998/05/21 10:48:33 1.859 @@ -1,5 +1,12 @@ Changes with Apache 1.3b7 + *) Make sure a MIME-type can be forced via a RewriteRule even when no + substitution takes place, for instance via the following rule: + ``RewriteRule ^myscript$ - [T=application/x-httpd-cgi]'' This was often + requested by users in the past to force a single script without a .cgi + extension and outside any cgi-bin dirs to be executed as a CGI program. + [Ralf S. Engelschall] PR#2254 + *) A fix for protocol issues surrounding 400, 408, and 414 responses. [Ed Korthof] 1.106 +29 -1 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.105 retrieving revision 1.106 diff -u -r1.105 -r1.106 --- mod_rewrite.c 1998/05/20 15:34:26 1.105 +++ mod_rewrite.c 1998/05/21 10:48:35 1.106 @@ -1794,6 +1794,32 @@ /* and add the variable to Apache's structures */ add_env_variable(r, env); } + if (p->forced_mimetype != NULL) { + 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); + ap_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); + r->content_type = p->forced_mimetype; + } + } return 2; } @@ -1951,7 +1977,9 @@ * Finally we had to remember if a MIME-type should be * forced for this URL (`RewriteRule .. .. [T=]') * Later in the API processing phase this is forced by our - * MIME API-hook function. + * MIME API-hook function. This time its no problem even for + * the per-directory context (where the MIME-type hook was + * already processed) because a sub-request happens ;-) */ if (p->forced_mimetype != NULL) { ap_table_setn(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR,