phpbar.de logo

Mailinglisten-Archive

[php] Wer hatte nochmal den 500:"Premature end of script headers"? Ursache! Ursache!

[php] Wer hatte nochmal den 500:"Premature end of script headers"? Ursache! Ursache!

Schwerd Schwerd_(at)_bigfoot.com
Wed, 01 Dec 1999 23:12:20 +0100


Hallo,

war da nicht mal jemand mit einem "Premature end of script headers"?
(CGI-Fehler 500)

Ich hatte jetzt auch mal einen, und habs nachgeguckt. Hier ist, was ich fand:

-----------------------
What does it mean when my CGIs fail with "Premature end of script headers"? 

It means just what it says: the server was expecting a complete set of HTTP
headers (one or more followed by a blank line), and didn't get them. 

The most common cause of this problem is the script dying before sending
the complete set of headers, or possibly any at all, to the server. To see
if this is the case, try running the script standalone from an interactive
session, rather than as a script under the server. If you get error
messages, this is almost certainly the cause of the "premature end of
script headers" message. 

The second most common cause of this (aside from people not outputting the
required headers at all) is a result of an interaction with Perl's output
buffering. To make Perl flush its buffers after each output statement,
insert the following statements around the print or write statements that
send your HTTP headers: 


{
 local ($oldbar) = $|;
 $cfh = select (STDOUT);
 $| = 1;
 #
 # print your HTTP headers here
 #
 $| = $oldbar;
 select ($cfh);
} 

This is generally only necessary when you are calling external programs
from your script that send output to stdout, or if there will be a long
delay between the time the headers are sent and the actual content starts
being emitted. To maximize performance, you should turn buffer-flushing
back off (with $| = 0 or the equivalent) after the statements that send the
headers, as displayed above. 

If your script isn't written in Perl, do the equivalent thing for whatever
language you are using (e.g., for C, call fflush() after writing the
headers). 

-----------
Also: HTTP-Header fehlte! In Perl gehts ungefähr so:

    print $cgi->header(-type=>'text/html');
    print "<B>Nachricht!</B>\n";


!!END-OFF-TOPIC!!


Hope it helps,

Viele Grüße

Daniel Schwerd




php::bar PHP Wiki   -   Listenarchive