php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42848 Status: header incorrect under FastCGI
Submitted: 2007-10-04 04:41 UTC Modified: 2007-11-01 11:16 UTC
Votes:8
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:5 (71.4%)
From: madcamel at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: CGI/CLI related
PHP Version: 5.2.4 OS: Linux, FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: madcamel at gmail dot com
New email:
PHP Version: OS:

 

 [2007-10-04 04:41 UTC] madcamel at gmail dot com
Description:
------------
When PHP is used as a FastCGI it outputs incorrect Status: headers.

For example, a redirect triggered by header("Location: http://x.com/")
returns "Status: 302", not "Status: 302 Moved Temporarily" as is explicitly required by the FastCGI specification.

This leads to most web servers returning "HTTP/1.1 302" instead of "HTTP/1.1 302 Moved Temporarily", thereby breaking some very picky browsers.

This problem also also occurs with 404 if a PHP file could not be found, and I'm sure every other type of "Special" response. This makes it different than bug 41738.

Related bugs:
http://bugs.php.net/bug.php?id=41378
http://bugs.php.net/bug.php?id=31065
http://bugs.php.net/bug.php?id=36705


Reproduce code:
---------------
--- Test 1
<?php
        header("HTTP/1.1 302 Moved Permanently");
        header("Location: http://www.google.com/");
?>

$ php-fcgi fun.php
Status: 302
Location: http://www.google.com/
Content-type: text/html

--- Test 2
<?php
        header("Location: http://www.google.com/");
?>
$ php-fcgi fun.php
Status: 302
Location: http://www.google.com/
Content-type: text/html

--- Test 3
<?php
        header("Status: 302 Moved Temporarily");
        header("Location: http://www.google.com/");
?>

$ php-fcgi fun.php
Status: 302
Status: 302 Moved Temporarily
Location: http://www.google.com/
Content-type: text/html

Note the duplicate "Status:" headers, which is dissallowed by the FastCGI spec. 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-04 04:47 UTC] madcamel at gmail dot com
404 behavior:
$ php-fcgi does-not-exist.php
Status: 404
Content-type: text/html

Expected: "Status: 404 Not Found"
 [2007-10-23 16:25 UTC] madcamel at gmail dot com
Nope, still the same behavior. 

I notice there is rudimentary handling for adding descriptions to status codes in isapi/php5isapi.c:270

Could something like this but perhaps a little more robust be added to the cgi/fcgi sapi perhaps?
 [2007-10-30 22:15 UTC] jani@php.net
Dmitry, any ideas about this?
 [2007-11-01 11:16 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_3 (not in PHP_5_2).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 12:01:27 2024 UTC