php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41378 fastcgi protocol lacks support for Reason-Phrase in "Status:" header
Submitted: 2007-05-12 18:52 UTC Modified: 2007-05-15 08:53 UTC
From: anight at eyelinkmedia dot com Assigned: dmitry (profile)
Status: Closed Package: HTTP related
PHP Version: 5.2.2 OS: any
Private report: No CVE-ID: None
 [2007-05-12 18:52 UTC] anight at eyelinkmedia dot com
Description:
------------
Right now there is no way to set application-defined "Reason-Phrase" (as defined in rfc2616) along with Status-Code in a Status-Line of http response for fastcgi sapi. This affects php-4.4.7 too (fastcgi module based on same code).

Fastcgi specs says:
http://www.fastcgi.com/devkit/doc/fcgi-spec.html
6.1 Role Protocols
[skipped]
Role protocols do not support the non-parsed header feature of CGI. FastCGI 
applications set response status using the Status and Location CGI headers.

As I understand, the only way to specify Reason-Phrase is to pass it via Status: header. This header itself will not reach a client, because it is only valid within fastcgi protocol.


Reproduce code:
---------------
<? header("HTTP/1.0 404 Not Found"); ?>

Expected result:
----------------
web server respond with "HTTP/1.1 404 Not Found" status line.

Actual result:
--------------
web server respond with "HTTP/1.1 404" status line.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-12 18:56 UTC] anight at eyelinkmedia dot com
proposed patch:

--- sapi/cgi/cgi_main.c 2007-02-16 14:47:20.000000000 +0300
+++ sapi/cgi/cgi_main.c 2007-05-11 16:48:37.000000000 +0400
@@ -329,8 +329,22 @@
                        }

                } else {
+                       if (SG(sapi_headers).http_status_line) {
+                               char *ptr;
+                               for (ptr = SG(sapi_headers).http_status_line; *ptr; ptr++) {
+                                       if (*ptr == ' ' && *(ptr + 1) != ' ' && *(ptr + 1) != 0) {
+                                               len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH,
+                                                       "Status: %s\r\n", ptr + 1);
+                                               if (len > SAPI_CGI_MAX_HEADER_LENGTH) {
+                                                       len = SAPI_CGI_MAX_HEADER_LENGTH;
+                                               }
+                                               goto done;
+                                       }
+                               }
+                       }
                        len = sprintf(buf, "Status: %d\r\n", SG(sapi_headers).http_response_code);
                }
+done:

                PHPWRITE_H(buf, len);
        }
 [2007-05-15 08:53 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC