mrampton has asked for the wisdom of the Perl Monks concerning the following question:

Alright, for my first perl project i created this Testcase/testMatrix creater/archiver.

It was built with perl & eperl using CGI and runs on Apache.

I havent touched it for a few months. However, today i noticed that when i tried submitting the contents of a CGI form in Netscape, I get the error, "The Document Contained no Data...". Now, I can't recall ever seeing this before, but that's most likey because I was using IE, and it works fine with IE.

I've decided Netscape must not like the Headers its recieving from my form. So my question is, what am I missing in my CGI file that causes this error with Netscape, and Netscape only?

Here's the first few lines of my CGI file:

#!/usr/bin/perl use Parse::ePerl; use CGI; use Data::Dumper; use strict; use Time::localtime; my $q=new CGI; print "Content-type: text/html\n\n";

Edit by tye

Replies are listed 'Best First'.
Re: My CGI gives "document contained no data"
by tadman (Prior) on Aug 04, 2001 at 08:46 UTC
    The super annoying thing about the headers is that the official HTTP spec says you should use CR-LF. Yes, that makes you ask what OS those guys were smoking at the time. Maybe your Web server will be kind enough to fix this for you, so you might not even notice there's a problem, but just because the rules are silly doesn't mean you should break them.

    As such, you should never print your own headers, and should get CGI.pm to do all the dirty work for you:
    print $q->header();
Re: Very lame question -- what can i say? I'm a newbie
by Everlasting God (Beadle) on Aug 03, 2001 at 22:18 UTC
    I kinda think that NS prefers "Content-Type: text/html\n\n" for the header line.

    'The fickle fascination of and Everlasting God' - Billy Corgan, The Smashing Pumpkins
Re: Very lame question -- what can i say? I'm a newbie
by tachyon (Chancellor) on Aug 03, 2001 at 22:34 UTC

    You show us that you return a valid header, thus no 500 internal server error. This "document contained no data" message appears when the script does not return any information to the browser. Often it happens when the script tries to access a nonexistent file and then return information from that file or the script takes so long to run that the browser times out. Add these lines as shown: <code> $|++; print "Content-type: text/html\n\n" # <- existing line print "

    Hello World!\n" <code>

    The $|++ forces buffer flushing and then after your header you print a short message :-) If this works but you get nothing else then, ahm, well, the document contained no data - because your script doesn't send any.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Very lame question -- what can i say? I'm a newbie
by marow (Initiate) on Aug 03, 2001 at 22:15 UTC
    OOOH I been there brother, as another newbie, I would start with use CGI qw(:standard); print header; and be sure that your tags are getting closed as well, netscape is more fussy about that sort of thing
Re: Very lame question -- what can i say? I'm a newbie
by mrampton (Initiate) on Aug 03, 2001 at 22:29 UTC
    alright.. I seemed to have fixed the problem by printing out some blank spaces directly after the header. Netscape is seems doesn't like it if nothing is printed, IE doesn't care.

    Also, sorry for the badly formatted question (i.e. no whitespace). It was my first post, and I wasnt aware i needed to enter my own html for formatting. oops.

    Thanks everyone for your suggestions though!
    -mark
      Netscape reported that the document contained no data because.... it contained no data. You didn't print any data, you simply printed a header. Netscape is handling the result from your CGI correctly; Explorer tends to make all kinds of wild assumptions and forgives a lot of errors in HTML.