From: Ken Coar Date: Thu, 12 Jun 1997 15:24:00 +0000 (+0000) Subject: Clean up "premature end of headers" FAQ and add additional X-Git-Tag: APACHE_1_3_PRE_NT~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f21eb24f00be26f5df14e0a74692be1b84ba398c;p=thirdparty%2Fapache%2Fhttpd.git 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 --- diff --git a/docs/manual/misc/FAQ.html b/docs/manual/misc/FAQ.html index 29a076b7199..2757d14f072 100644 --- a/docs/manual/misc/FAQ.html +++ b/docs/manual/misc/FAQ.html @@ -15,7 +15,7 @@

Apache Server Frequently Asked Questions

- $Revision: 1.70 $ ($Date: 1997/06/12 11:29:11 $) + $Revision: 1.71 $ ($Date: 1997/06/12 15:24:00 $)

The latest version of this FAQ is always available from the main @@ -569,27 +569,48 @@

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 (aside from people not - outputting the required headers at all) a result of an interaction - with perl's output buffering. To make perl flush its buffers - after each output statement, insert the following statements before your - first print or write statement: + 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:

-
$cfh = select (STDOUT);
- $| = 1;
- select ($cfh);
+
{
+  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 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 - turn buffering back on (with $| = 0 or the - equivalent) after the statements that send the headers. + 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