IE ignoring or second-guessing mime-types?  I'm shocked (tongue-in-cheek).

If you're on apache, one thing you can do is use mod_rewrite to make your file LOOK 
like it's a static XML file with an XML extension, which should work as intended.

For instance-

Say you only need to pass an ID number to your CGI script to get the correct XML file 
to print.

You can pass the ID number in the path, and then end the path with "text.xml", so your 
URLs would look like:

http://www.domain.com/xmlfiles/3343234/text.xml

Assuming the problem is that IE second guesses mime-types and looks for files with 
.xml extensions to choose whether or not to use a "tree" view (which is what the 
problem is, I believe), you'd have this in your httpd.conf to interpret the above URL 
and output the correct file in the correct location:

RewriteEngine On
RewriteRule ^/xmlfiles/(.*) /cgi-bin/xml.cgi?id=$1 [L,P]

Your ID will be passed to the xml.cgi stuff, and the extra "text.xml" stuff is just 
extraneous garbage that is there to trick IE into thinking it's downloading a static 
file with an .xml extension.

Not that elegant, but should work very nicely. Make sure you untaint the id, because I 
didn't do that with the RewriteRule here.

If you need to pass more variables, you need only to tweak the regex and add them into 
the path in the correct order.

Good luck!

-DJCP



Ranga Nathan <[EMAIL PROTECTED]> wrote:
> 
[forwarded submission from a non-member address -- rjk]


From: "Ranga Nathan" 
Date: Mon, 25 Feb 2002 19:01:38 -0800
Subject: CGI printing XML
To: 

When a CGI scripts prints an XML file to IE, it renders it as plain text!!!
But when it GETs an XML file with the xml extension it renders it with
collapse/expand view. Wonder if anyone has an angle on this. How can one
tell IE from a CGI to collaps/expand? I tried different mime types.. IE
simply seems to ignore it!!!
script is:
#!/usr/local/bin/perl

print 

  
     This is element one
  
  
     This is element two
  

HERE
====================================
Ranga Nathan
Reliance Technology
Legacy to Web integration consultancy
Text to web-database-spreadsheet, datamarts
ADABAS, NATURAL, Perl, Apache, Linux, Wintel solutions
Tel: 617 884 9801 Fax: 781 623 5646
http://www.cobolexplorer.com - cobol listings on the web
http://www.any2xml.com - text to anything
http://www.goreliance.com
http://www.adaexplorer.com - ADAREP on the web + stats


Reply via email to