]> granicus.if.org Git - php/commitdiff
Fixed bug #41378 (fastcgi protocol lacks support for Reason-Phrase in "Status:" header)
authorDmitry Stogov <dmitry@php.net>
Tue, 15 May 2007 08:17:20 +0000 (08:17 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 15 May 2007 08:17:20 +0000 (08:17 +0000)
sapi/cgi/cgi_main.c

index e5e5d5d51987523d9ec9320023cad27d52140a48..2487727aaba065161a26ddc961cc245e831aa6ee 100644 (file)
@@ -320,7 +320,16 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
                        }
 
                } else {
-                       len = sprintf(buf, "Status: %d\r\n", SG(sapi_headers).http_response_code);
+                       char *s;
+
+                       if (SG(sapi_headers).http_status_line &&
+                           (s = strchr(SG(sapi_headers).http_status_line, ' ')) != 0 &&
+                           (s - SG(sapi_headers).http_status_line) >= 5 &&
+                           strncasecmp(SG(sapi_headers).http_status_line, "HTTP/", 5) == 0) {
+                               len = sprintf(buf, "Status:%s\r\n", s);
+                       } else {
+                               len = sprintf(buf, "Status: %d\r\n", SG(sapi_headers).http_response_code);
+                       }
                }
 
                PHPWRITE_H(buf, len);