]> granicus.if.org Git - php/commitdiff
Use "Status: %d" instead of "HTTP/1.0 %d X" in the CGI SAPI module
authorSascha Schumann <sas@php.net>
Wed, 3 Jul 2002 11:44:48 +0000 (11:44 +0000)
committerSascha Schumann <sas@php.net>
Wed, 3 Jul 2002 11:44:48 +0000 (11:44 +0000)
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

sapi/cgi/cgi_main.c

index c51c2c59c24df8b26e4c296e5c022e232df56935..cfd69d9f2ba9d9e97e482f994c9b9da1d25f593c 100644 (file)
@@ -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 */