#29162 [Opn->Csd]: HEAD request script terminates on non-header output
| From: | vrana@php.net | Date: | Tue, 26 Apr 2005 15:17:45 +0000 |
| Subject: | #29162 [Opn->Csd]: HEAD request script terminates on non-header output | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969368009@lists.php.net to get a copy of this message | ||
ID: 29162
Updated by: vrana@php.net
Reported By: php-bugs at carldunham dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Linux (Gentoo 1.4)
PHP Version: 4.3.7
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Documented by REQUEST_METHOD in reserved.variables.server: (didn't find
better place for it)
"PHP script is terminated after sending headers (it means after
producing any output without output buffering) if request method was
HEAD."
Previous Comments:
------------------------------------------------------------------------
[2004-07-15 02:42:15] iliaa@php.net
This is expected behavior, it should be documented.
------------------------------------------------------------------------
[2004-07-14 22:00:29] php-bugs at carldunham dot com
Description:
------------
It seems that a script executing in response to a HEAD
request will terminate when non-header output is
generated. This can lead to different behavior in HEAD vs
GET, which may not be desirable. Other bug reports
(http://bugs.php.net/bug.php?id=15693) have indicated that
the entire script executes, which does not seem to be the
case.
I was unable to find documentation of what is the intended
behavior, although I would vote for having the script
complete no matter the method, as working around cases
where that is not desirable is easier:
if ($_SERVER['REQUEST_METHOD'] == 'HEAD') exit();
at the top of a script, vs.
if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
// do outputty things
}
// do non-outputty things
sprinkled throughout the code.
Reproduce code:
---------------
<?php
$fp = fopen('/tmp/test-head.out', 'a');
fwrite($fp, "Method = " . $_SERVER['REQUEST_METHOD'] . "\n");
echo "hello";
fwrite($fp, "POST: " . print_r($_POST, true) . "\n");
fwrite($fp, "GET: " . print_r($_GET, true) . "\n\n");
fclose($fp);
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29162&edit=1