You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2005/09/10 14:38:32 UTC
DO NOT REPLY [Bug 36590] New: -
mod_rewrite type|T force mime type option doesn't work
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36590>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=36590
Summary: mod_rewrite type|T force mime type option doesn't work
Product: Apache httpd-2.0
Version: 2.0.54
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: mod_rewrite
AssignedTo: bugs@httpd.apache.org
ReportedBy: richardaburton@hotmail.com
Using the following rule:
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(.*\.html)$ $1@%1 [T=text/html]
To convert some urls like this:
http://example.com/index.html?image.jpg
to access files like this (produced by a batch downloading tool):
index.html@image.jpg
the rewrite rule needs the T option because otherwise apache will send a jpg
mime type, based on the file name.
The log for this rewrite is:
[rid#aa1218/initial] (3) [per-dir /tmp/www/] strip per-dir prefix:
/tmp/www/test/index.html -> test/index.html
[rid#aa1218/initial] (3) [per-dir /tmp/www/] applying pattern '^(.*\.html)$' to
uri 'test/index.html'
[rid#aa1218/initial] (2) [per-dir /tmp/www/] rewrite test/index.html ->
test/index.html@image.jpg
[rid#aa1218/initial] (3) [per-dir /tmp/www/] add per-dir prefix:
test/index.html@image.jpg -> /tmp/www/test/index.html@image.jpg
[rid#aa1218/initial] (2) [per-dir /tmp/www/] remember
/tmp/www/test/index.html@image.jpg to have MIME-type 'text/html'
[rid#aa1218/initial] (2) [per-dir /tmp/www/] strip document_root prefix:
/tmp/www/test/index.html@image.jpg -> /hcStore/8x10/index.html@image.jpg
[rid#aa1218/initial] (1) [per-dir /tmp/www/] internal redirect with
/hcStore/8x10/index.html@image.jpg [INTERNAL REDIRECT]
[rid#ab0208/initial/redir#1] (3) [per-dir /tmp/www/] strip per-dir prefix:
/tmp/www/test/index.html@image.jpg -> test/index.html@image.jpg
[rid#ab0208/initial/redir#1] (3) [per-dir /tmp/www/] applying pattern
'^(.*\.html)$' to uri 'test/index.html@image.jpg'
[rid#ab0208/initial/redir#1] (1) [per-dir /tmp/www/] pass through
/tmp/www/test/index.html@image.jpg
Note the lack of a log entry indicating that the forced mime type is actually
being set, which should be in the redir#1 block. livehttpheaders confirmed the
forced mime type did not find its way to the browser.
A couple of extra log points in hook_mimetype showed that it wasn't finding the
force mime type note for the request. This is probably because we are on a new
request second time through (the internal redirect), and so we should be using
r->prev->notes instead of r->notes. Potentially the forced mime type could be a
couple of redirects back, so all previous requests should probably(?) be checked
until one is found, or we have been through them all.
I'd suggest something like this as a possible fix (works fine for me):
static int hook_mimetype(request_rec *r)
{
const char *t;
request_rec *p = r;
/* now check if we have to force a MIME-type */
while (p) {
t = apr_table_get(p->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR);
if (t != NULL) {
rewritelog(r, 1, "force filename %s to have MIME-type '%s'",
r->filename, t);
ap_set_content_type(r, t);
return OK;
}
p = p->prev;
}
return DECLINED;
}
Richard.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org