|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 08:00:01 2025 UTC |
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); }