From: Sascha Schumann Date: Wed, 3 Jul 2002 11:44:48 +0000 (+0000) Subject: Use "Status: %d" instead of "HTTP/1.0 %d X" in the CGI SAPI module X-Git-Tag: xmlrpc_epi_0_51_merge_pt~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=99cfb41da0c11b417cb276ed240c749524d356d6;p=php Use "Status: %d" instead of "HTTP/1.0 %d X" in the CGI SAPI module as per the CGI RFC. The status notation is incompatible with Apache's non-parsed-header mode "nph-*", but that has never worked before anyway. One could make the format string configurable. Noticed by: Sebastian Bergmann --- diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index c51c2c59c2..cfd69d9f2b 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -201,12 +201,24 @@ static void sapi_cgibin_flush(void *server_context) } -static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC) +static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { - if (sapi_header) { - PHPWRITE_H(sapi_header->header, sapi_header->header_len); + char buf[1024]; + int len; + sapi_header_struct *h; + zend_llist_position pos; + + len = sprintf(buf, "Status: %d\r\n", SG(sapi_headers).http_response_code); + PHPWRITE_H(buf, len); + + h = zend_llist_get_first_ex(&sapi_headers->headers, &pos); + while (h) { + PHPWRITE_H(h->header, h->header_len); + PHPWRITE_H("\r\n", 2); + h = zend_llist_get_next_ex(&sapi_headers->headers, &pos); } - PHPWRITE_H("\r\n", 2); + + return SAPI_HEADER_SENT_SUCCESSFULLY; } @@ -297,8 +309,8 @@ static sapi_module_struct cgi_sapi_module = { php_error, /* error handler */ NULL, /* header handler */ - NULL, /* send headers handler */ - sapi_cgi_send_header, /* send header handler */ + sapi_cgi_send_headers, /* send headers handler */ + NULL, /* send header handler */ sapi_cgi_read_post, /* read POST data */ sapi_cgi_read_cookies, /* read Cookies */