Re: CGI scripts and MSIE



On Thu, 24 May 2007 10:28:20 +0100, Nigel Wade wrote:

Geoffrey Clements wrote:

I'm having fun setting up my home server for the web and other things -
it's been a great learning experience but I've now got a problem that
seems to affect IE only:

Last night I put a perl script into my cgi-bin directory and gave it
some testing by connecting from my desktop using both konq and firefox,
everything seems to be fine. At work this morning I thought I'd take a
quick look with MSIE and, well, you can probably guess ... it doesn't
work.

The file name is xxx.pl (actually it's not but you get my drift). With
MSIE it pops up a dialog asking if I want to save or open xxx.pl. When
I save and look at the contents it is the HTML output generated by
xxx.pl. Is there a (standard) way to deal with this at the server end?
My server is Debian Etch and my web-server is lighttpd.

I ask this question because I'm still quite a novice at this sort of
thing and googling hasn't turned up anything useful yet.


I would guess that you haven't specified in the HTML what the contents
are. Most likely the other browsers have defaulted to text/html, or have
a defined action for extension .pl. IE has not defaulted to text/html
and has no action for .pl. So it has fallen back to the [safe] position
of not interpreting the contents at all, and instead allowing you to
save them.

What you need to do is add a header to the HTML you send back saying
what the contents are. If it is HTML add the header "Content-type:
text/html" to your output. It's better to use the Perl CGI modules, for
example:

require "cgi-lib.pl";
print &PrintHeader;

or

use CGI qw(:standard);
print header;

will do what you require.

For reference, although header defaults to setting
"Content-type: text/html\n\n" it will also take the content type as an
argument, so print header('text/html') is valid

--
Stephen Patterson :: steve@xxxxxxxxxxxxxx :: http://patter.mine.nu/
GPG: B416F0DE :: Jabber: patter@xxxxxxxxxxxxxxx
"Don't be silly, Minnie. Who'd be walking round these cliffs with a gas
oven?"
.



Relevant Pages

  • Re: Grey logos in letterheads
    ... If you really need the rationalisation, it is/was this: ... from which both HTML and XML protocols sprang: ... header and leaving it up to the recipient device to figure it out. ...
    (microsoft.public.mac.office.word)
  • Re: Grey logos in letterheads
    ... small comment--actually, both of my points came about because people constantly post about both those problems on the general Word groups, not here. ... I was trying to write an explanation to defend the lost headers in HTML to someone over there when I realized there was no way I could rationalize it. ... user can edit it and it can have a running header on each page. ...
    (microsoft.public.mac.office.word)
  • Re: Diacritical marks in array dont translate
    ... >>> encoding you specified in your HTML. ... > header transmitted by a server. ... MUST or MAY allow the Content-Type header to be overridden by the `meta' ... There are used UAs out there which does not support Unicode, ...
    (comp.lang.javascript)
  • Re: Unable to Control Header in html mail
    ... The dialog is correct - you can't preview HTML. ... If I'm following correctly, the header and footers are behaving as expected, ... Teach Yourself Outlook 2003 in 24 Hours ... > page setup all the header and footer areas are blank. ...
    (microsoft.public.outlook.printing)
  • Re: multiple row updates in MYSQL using HTML
    ... > if the checkbox is checked incase you are updating most of the records ... >>all to another perl script to perform the update. ... >>I basically need maintenance of one table with unlimited rows containing ... HTML? ...
    (comp.lang.perl)