in reply to Not your normal " Premature end of script headers:"

By definition, in order to get this server-generated error, your script(s) must generate some output before the server (or in some cases the scripts) had the opportunity to output and finish the required headers.

As it concerns all your CGI scripts, it must be something not linked to any single individual script, but must be more general.

Therefore your first task should be to hunt for the exact output made by your failing scripts. Most likely it is an error message and that normally goes into the Apache error log and CGI::Carp should be able to catch it.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

  • Comment on Re: Not your normal " Premature end of script headers:"

Replies are listed 'Best First'.
Re^2: Not your normal " Premature end of script headers:"
by hangon (Deacon) on Jun 18, 2008 at 23:16 UTC

    While the problem is more general, the nature of the problem suggests that it is triggered by an event, or an accumulation or sequence of events. A script may or may not be triggering the problem, but determining or eliminating this possibility is a step toward resolution.

    Could a particular execution path in a script change something in the environment? Could it trigger a bug in Apache? Could a bug in an XS module overwrite some memory location that it shouldn't? Could the problem be related to POST or GET parameters sent to a script? Maybe.

Re^2: Not your normal " Premature end of script headers:"
by mr_mischief (Monsignor) on Jun 23, 2008 at 15:32 UTC
    To be more accurate, it means the process Apache is calling produces an insufficient set of headers. There need not be any output at all, let alone at any specific point in time relative to something else. If there is no content-type header, the error is issued.

    The lack of output or incorrect output could be caused by many things. It could be caused by STDOUT being redirected elsewhere. It could be an error condition in the shell or the script interpreter/compiler is the only output. It could mean the script runs but produces no output at all. It could mean the output is in the wrong order, or that it doesn't include the content-type header at all.

    The reason for the error is often found in the error log, such as

    [Mon Jun 23 10:05:39 2008] [error] [client 192.168.1.253] (13)Permissi +on denied: exec of '/var/www/vhosts/chris.test/foo.pl' failed
    which would then be followed in the stock error log format by another entry like
    [Mon Jun 23 10:05:39 2008] [error] [client 192.168.1.253] Premature en +d of script headers: foo.pl

    If the script simply produces no output at all or produces output which doesn't include the content type header, you'll just get the one error logged about premature end of script headers.