Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: Content-Type not working on MSIE: msg#00431

apache.mod-perl

Subject: Re: Content-Type not working on MSIE

Hello,

SB>Can someone please summarize the problem and add possible solutions and
SB>post it here so we can add it to this document:
SB>http://perl.apache.org/docs/tutorials/client/browserbugs/browserbugs.html

Sometimes, MSIE will ignore the MIME type specified in a Content-Type
header, and instead guess the type of a file based on its extension. For
example, on most Windows systems files with a .reg extension are registry
files. So if you happen to have a Perl script on your mod_perl webserver
called foo.reg, even if it outputs a "Content-Type: text/plain" webserver,
MSIE may treat the output from the URL as a registry file (and pop up a
dialog box asking if you want to "run" the file, e.g., attempt to merge
its contents with the registry, in this example).

This is especially a problem if the computer running MSIE does something
special for .pl files (for example, feed the file to ActiveState Perl).

Here is how to reproduce the bug. Make a simple script like this:

#!/usr/local/bin/perl -w
use strict;

use Apache ();

my $r = Apache->request;
$r->content_type('text/plain');
$r->send_http_header;
$r->print('ok');

Call it plain.reg, and associate .reg files with Apache::Registry. An
.htaccess entry like this may do the trick:

<FilesMatch "\.reg$">
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
</FilesMatch>

Now if you access http://www.example.com/plain.reg with MSIE, you may
trigger this bug. (I'm not positive what causes MSIE to ignore
Content-Type on some extensions but not others. If plain.reg doesn't work
for you, try plain.exe, plain.bin, or some other file extensions.)

There are a variety of workarounds.

Easiest is to just fool IE, by making it think the script is named
something else. Most foolproof is to use extra path information:

http://www.example.com/plain.reg/plain.txt

You can also append a dummy parameter. Apparently, MSIE uses a simple
string match to find the extension.

http://www.example.com/plain.reg?bogus=plain.txt

Finally, MSIE respects the Content-Disposition MIME header. This isn't
officially part of the HTTP spec, but is especially useful because you can
suggest a filename. This is nice so that if the user does "Save As..." or
if your script produces a CSV file or some other application specific
output, a pretty filename will be suggested. Just include a line like this
in the Apache::Registry script before calling send_http_header():

$r->header_out('Content-Disposition' => 'inline; filename=plain.txt');

I just verified all of this on freshly patched IE 6.

Humbly,

Andrew

----------------------------------------------------------------------
Andrew Ho http://www.tellme.com/ andrew@xxxxxxxxxx
Engineer 1-800-555-TELL Voice 650-930-9062
Tellme Networks, Inc. Fax 650-930-9101
----------------------------------------------------------------------




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
version-control...    qnx.openqnx.dev...    redhat.rhn.user...    ietf.openpgp/20...    mail.mutt.user/...    web.microformat...    java.sync4j.use...    education.ezpro...    user-groups.blu...    solaris.manager...    org.fitug.debat...    technology.erps...    politics.activi...    linux.redhat.fe...    bug-tracking.ma...    xfce.user/2004-...    hams/2004-11/ms...    kde.users.pim/2...    culture.cooking...    freebsd.devel.x...    gnu.m4.adhoc/20...    ngpt.user/2002-...    apple.fink.deve...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation