From:             phpbugs at thequod dot de
Operating system: 
PHP version:      5.0.4
PHP Bug Type:     CGI related
Bug description:  PHP sends multiple Status headers

Description:
------------
Multiple "Status" lines get send when    
using "header('Location: url')", which produces an  
additional 302 (REDIRECT) status code.  
    
This causes FastCGI (at least) to produce a 500 Internal    
Server Error:    
FastCGI: comm with server "/path/to/fcgi-starter" aborted:    
error parsing headers: duplicate header 'status'    
  
    
Documentation    
(http://us2.php.net/manual/en/function.header.php) says:    
Note:  The HTTP status header line will always be the    
first sent to the client [[NOT TRUE! - reproduce: echo  
"<?php header('Status: 304'); ?>" | php5/bin/php-fcgi]],  
regardless of the    
actual header() call being the first or not. The status    
may be overridden by calling header() with a new status    
line at any time unless the HTTP headers have already been    
sent [[NOT TRUE! - this bug]].    
    
-----------------------------------    
configure (both PHP5 and PHP4):    
./configure --enable-memory-limit    
--enable-force-cgi-redirect  \    
--enable-track-vars --with-pcre-regex --with-mysql    
--without-sqlite \    
--with-zlib --with-bz2 --enable-mbstring --with-openssl    
--enable-exif \    
--with-dom=shared --with-ttf=shared --with-gd=shared    
--enable-calendar \    
--with-iconv --enable-inline-optimization    
--enable-gd-native-ttf \    
--with-ldap --with-ldap-sasl \    
--with-gettext \    
--without-mm --enable-fastcgi --prefix=/home/daniel/php5    
    

Reproduce code:
---------------
$ cat << "?>" | php5/bin/php-fcgi 
<?php 
header( 'Status: 404' ); 
header( 'Status: 301' ); 
header( 'Location: http://www.example.org' ); 
?> 


Expected result:
----------------
Status: 301  
Content-type: text/html  
X-Powered-By: PHP/5.0.4  
Location: http://www.example.org  
  

Actual result:
--------------
Status: 302 
Content-type: text/html 
X-Powered-By: PHP/5.0.4 
Status: 301 
Location: http://www.example.org 
 

-- 
Edit bug report at http://bugs.php.net/?id=33225&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33225&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33225&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33225&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33225&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33225&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33225&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33225&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33225&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33225&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33225&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33225&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33225&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33225&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33225&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33225&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33225&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33225&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33225&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33225&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33225&r=mysqlcfg

Reply via email to