mirror of
https://github.com/apache/httpd.git
synced 2025-09-02 13:21:21 +03:00
Clean up "premature end of headers" FAQ and add additional
(and more common) cause description. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@78298 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
<!--#include virtual="header.html" -->
|
<!--#include virtual="header.html" -->
|
||||||
<H1 ALIGN="CENTER">Apache Server Frequently Asked Questions</H1>
|
<H1 ALIGN="CENTER">Apache Server Frequently Asked Questions</H1>
|
||||||
<P>
|
<P>
|
||||||
$Revision: 1.70 $ ($Date: 1997/06/12 11:29:11 $)
|
$Revision: 1.71 $ ($Date: 1997/06/12 15:24:00 $)
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
The latest version of this FAQ is always available from the main
|
The latest version of this FAQ is always available from the main
|
||||||
@@ -569,27 +569,48 @@
|
|||||||
<P>
|
<P>
|
||||||
It means just what it says: the server was expecting a complete set of
|
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
|
HTTP headers (one or more followed by a blank line), and didn't get
|
||||||
them. The most common cause of this (aside from people not
|
them.
|
||||||
outputting the required headers at all) a result of an interaction
|
</P>
|
||||||
with perl's output buffering. To make perl flush its buffers
|
<P>
|
||||||
after each output statement, insert the following statements before your
|
The most common cause of this problem is the script dying before
|
||||||
first <CODE>print</CODE> or <CODE>write</CODE> statement:
|
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.
|
||||||
|
</P>
|
||||||
|
<P>
|
||||||
|
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 <CODE>print</CODE> or <CODE>write</CODE> statements that send your
|
||||||
|
HTTP headers:
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
<DL>
|
<DL>
|
||||||
<DD><CODE>$cfh = select (STDOUT);<BR>
|
<DD><CODE>{<BR>
|
||||||
$| = 1;<BR>
|
local ($oldbar) = $|;<BR>
|
||||||
select ($cfh);</CODE>
|
$cfh = select (STDOUT);<BR>
|
||||||
|
$| = 1;<BR>
|
||||||
|
#<BR>
|
||||||
|
# print your HTTP headers here<BR>
|
||||||
|
#<BR>
|
||||||
|
$| = $oldbar;<BR>
|
||||||
|
select ($cfh);<BR>
|
||||||
|
}</CODE>
|
||||||
</DD>
|
</DD>
|
||||||
</DL>
|
</DL>
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
This is generally only necessary when you are calling external
|
This is generally only necessary when you are calling external
|
||||||
programs from your script that send output to stdout, or if there will
|
programs from your script that send output to stdout, or if there will
|
||||||
be along delay between the time the headers are sent and the actual
|
be a long delay between the time the headers are sent and the actual
|
||||||
content starts being emitted. To maximise performance, you should
|
content starts being emitted. To maximise performance, you should
|
||||||
turn buffering back <EM>on</EM> (with <CODE>$| = 0</CODE> or the
|
turn buffer-flushing back <EM>off</EM> (with <CODE>$| = 0</CODE> or the
|
||||||
equivalent) after the statements that send the headers.
|
equivalent) after the statements that send the headers, as displayed
|
||||||
|
above.
|
||||||
|
</P>
|
||||||
<P>
|
<P>
|
||||||
If your script isn't written in Perl, do the equivalent thing for
|
If your script isn't written in Perl, do the equivalent thing for
|
||||||
whatever language you <EM>are</EM> using (<EM>e.g.</EM>, for C, call
|
whatever language you <EM>are</EM> using (<EM>e.g.</EM>, for C, call
|
||||||
|
Reference in New Issue
Block a user