Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

What causes 'premature end of script headers'?

( #262011=categorized question: print w/ replies, xml ) Need Help??
Contributed by markjugg on May 31, 2003 at 02:12 UTC
Q&A  > CGI programming


Description:

What are possible causes of the 'premature end of script headers' message in a web server's error log after the failed execution of a Perl CGI script?

Answer: What causes 'premature end of script headers'?
contributed by Aristotle

Not having output a header when you should have. Whether that is because the script didn't compile or was aborted before it reached the code to output the header, the result is the same. Consult your server's error log to find out the actual error message.

Answer: What causes 'premature end of script headers'?
contributed by markjugg

Here are some ideas:

  • Something printed to STDERR
  • The "Content-Type" header is invalid or missing.
  • You are using SuExec and it's causing problems.

For further ideas, you can:

Mark

Answer: What causes 'premature end of script headers'?
contributed by jhourcle

Something printing to STDOUT before the headers have been sent, and a blank line has also been sent to mark the end of the headers, or an incorrectly formatted header was sent. You can debug these issues by printing immediately print "Content-type: text/plain\n\n"; and looking at the output that is generated.

If you're using CGIwrap, you can use the debugging mode to see what content was generated, including the headers. suEXEC can also provide some debugging help.

Answer: What causes 'premature end of script headers'?
contributed by solegaonkar

I faced this problem because of DOS end of line characters in the file. Fixed with dos2unix

Answer: What causes 'premature end of script headers'?
contributed by LesleyB

You might have a bug in your code.

use CGI::Carp qw(fatalsToBrowser);

will throw errors up to the browser.

You can also run cgi scripts from the command line to check they actually run.

Answer: What causes 'premature end of script headers'?
contributed by gvs_jagan

You could encounter the 'premature end of script headers'

1) In case you were trying to accept values from a html page thru textfields

per se

print p("enter your name" , textfield("nam","");

missing out on one of the coats could cause it. For instance

print p("enter your name", textfield("nam , ""); #the end coat near nam is missing, this could cause

2) Also if you forget paranthesis near the html headers . In the below mentioned case missing out the paranthesis near the end_html could cause you the error

print header, start_html() ;
end_html();# leaving the paranthesis here

regards jagan

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (9)
    As of 2014-09-02 23:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (34 votes), past polls