From:             php-bugs at carldunham dot com
Operating system: Linux (Gentoo 1.4)
PHP version:      4.3.7
PHP Bug Type:     Output Control
Bug description:  HEAD request script terminates on non-header output

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 bug report at http://bugs.php.net/?id=29162&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29162&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29162&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29162&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29162&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29162&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29162&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29162&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29162&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29162&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29162&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29162&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29162&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29162&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29162&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29162&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29162&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29162&r=float

Reply via email to