in reply to Re: Re: CGI header doesn't like me
in thread CGI header doesn't like me

At the risk of being annoying, here is an example of my second pint

use CGI qw/:standard/; my $cgi = new CGI; print $cgi->header('text/plain'); print "testing\n";

I had believed that this would display simply "testing" within the browser window. That isn't the case -- it attempts to download the output -- but I haven't been able to figure out why, or how to change this behaviour

Replies are listed 'Best First'.
Re: Re: Re: Re: CGI header doesn't like me
by bobn (Chaplain) on Sep 10, 2003 at 04:40 UTC

    what you have works on my system, using mozilla as the browser.

    http requires a blank line after headers, before the actual content. On my system, print $cgi->header('text/plain'); does that. You should run your program from the command line to see that that is happening on your system.

    On the other hand, the extra "\n" doesn't hurt anything.

    --Bob Niederman, http://bob-n.com

    All code given here is UNTESTED unless otherwise stated.

Re: Re: Re: Re: CGI header doesn't like me
by Roger (Parson) on Sep 10, 2003 at 06:51 UTC
    I tried with the following code, and I got no problems:
    use CGI; my $cgi = new CGI; print $cgi->header('text/plain'); print <<HTML; <HTML> <BODY> HELLO HTML! </BODY> </HTML> HTML
    I got the following output:
    Content-Type: text/plain; charset=ISO-8859-1 <HTML> <BODY> HELLO HTML! </BODY> </HTML>
    HTML return code 200 means that the browser is happy with the stream but have no content to print, so the browser prints some debug message. Adding an extra return tells the browser to display the empty page.

    There was nothing wrong with the browser nor the code.