From 65768edcf3ef27a21a07e5e994bfd9ca1cabfa94 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Thu, 6 Nov 2014 17:59:31 +0000 Subject: [PATCH 01/11] Share HTTP status codes map --- main/http_status_codes.h | 80 +++++++++++++++++++++++++++++++++++++++ sapi/cgi/cgi_main.c | 57 ++-------------------------- sapi/cli/php_cli_server.c | 54 ++------------------------ sapi/fpm/fpm/fpm_main.c | 58 +++------------------------- 4 files changed, 92 insertions(+), 157 deletions(-) create mode 100644 main/http_status_codes.h diff --git a/main/http_status_codes.h b/main/http_status_codes.h new file mode 100644 index 00000000000..c9d32045153 --- /dev/null +++ b/main/http_status_codes.h @@ -0,0 +1,80 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Andrea Faulds | + +----------------------------------------------------------------------+ +*/ + +/* $Id: $ */ + +#ifndef HTTP_STATUS_CODES_H +#define HTTP_STATUS_CODES_H + +typedef struct _http_response_status_code_pair { + int code; + const char *str; +} http_response_status_code_pair; + +static http_response_status_code_pair http_status_map[] = { + { 100, "Continue" }, + { 101, "Switching Protocols" }, + { 200, "OK" }, + { 201, "Created" }, + { 202, "Accepted" }, + { 203, "Non-Authoritative Information" }, + { 204, "No Content" }, + { 205, "Reset Content" }, + { 206, "Partial Content" }, + { 300, "Multiple Choices" }, + { 301, "Moved Permanently" }, + { 302, "Found" }, + { 303, "See Other" }, + { 304, "Not Modified" }, + { 305, "Use Proxy" }, + { 307, "Temporary Redirect" }, + { 308, "Permanent Redirect" }, + { 400, "Bad Request" }, + { 401, "Unauthorized" }, + { 402, "Payment Required" }, + { 403, "Forbidden" }, + { 404, "Not Found" }, + { 405, "Method Not Allowed" }, + { 406, "Not Acceptable" }, + { 407, "Proxy Authentication Required" }, + { 408, "Request Timeout" }, + { 409, "Conflict" }, + { 410, "Gone" }, + { 411, "Length Required" }, + { 412, "Precondition Failed" }, + { 413, "Request Entity Too Large" }, + { 414, "Request-URI Too Long" }, + { 415, "Unsupported Media Type" }, + { 416, "Requested Range Not Satisfiable" }, + { 417, "Expectation Failed" }, + { 426, "Upgrade Required" }, + { 428, "Precondition Required" }, + { 429, "Too Many Requests" }, + { 431, "Request Header Fields Too Large" }, + { 500, "Internal Server Error" }, + { 501, "Not Implemented" }, + { 502, "Bad Gateway" }, + { 503, "Service Unavailable" }, + { 504, "Gateway Timeout" }, + { 505, "HTTP Version Not Supported" }, + { 511, "Network Authentication Required" }, + /* to allow search with while() loop */ + { 0, NULL } +}; + +#endif HTTP_STATUS_CODES_H diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index f06787543e4..59988579dda 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -69,6 +69,7 @@ #include "php_globals.h" #include "php_main.h" #include "fopen_wrappers.h" +#include "http_status_codes.h" #include "ext/standard/php_standard.h" #include "ext/standard/url.h" @@ -349,56 +350,6 @@ static void sapi_fcgi_flush(void *server_context TSRMLS_DC) #define SAPI_CGI_MAX_HEADER_LENGTH 1024 -typedef struct _http_error { - int code; - const char* msg; -} http_error; - -static const http_error http_error_codes[] = { - {100, "Continue"}, - {101, "Switching Protocols"}, - {200, "OK"}, - {201, "Created"}, - {202, "Accepted"}, - {203, "Non-Authoritative Information"}, - {204, "No Content"}, - {205, "Reset Content"}, - {206, "Partial Content"}, - {300, "Multiple Choices"}, - {301, "Moved Permanently"}, - {302, "Moved Temporarily"}, - {303, "See Other"}, - {304, "Not Modified"}, - {305, "Use Proxy"}, - {400, "Bad Request"}, - {401, "Unauthorized"}, - {402, "Payment Required"}, - {403, "Forbidden"}, - {404, "Not Found"}, - {405, "Method Not Allowed"}, - {406, "Not Acceptable"}, - {407, "Proxy Authentication Required"}, - {408, "Request Time-out"}, - {409, "Conflict"}, - {410, "Gone"}, - {411, "Length Required"}, - {412, "Precondition Failed"}, - {413, "Request Entity Too Large"}, - {414, "Request-URI Too Large"}, - {415, "Unsupported Media Type"}, - {428, "Precondition Required"}, - {429, "Too Many Requests"}, - {431, "Request Header Fields Too Large"}, - {500, "Internal Server Error"}, - {501, "Not Implemented"}, - {502, "Bad Gateway"}, - {503, "Service Unavailable"}, - {504, "Gateway Time-out"}, - {505, "HTTP Version not supported"}, - {511, "Network Authentication Required"}, - {0, NULL} -}; - static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { char buf[SAPI_CGI_MAX_HEADER_LENGTH]; @@ -449,7 +400,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos); } if (!has_status) { - http_error *err = (http_error*)http_error_codes; + http_response_status_code_pair *err = (http_response_status_code_pair*)http_status_map; while (err->code != 0) { if (err->code == SG(sapi_headers).http_response_code) { @@ -457,8 +408,8 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) } err++; } - if (err->msg) { - len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->msg); + if (err->str) { + len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->str); } else { len = slprintf(buf, sizeof(buf), "Status: %d\r\n", SG(sapi_headers).http_response_code); } diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 19a94218ff8..3cf63067297 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -68,6 +68,7 @@ #include "zend_hash.h" #include "zend_modules.h" #include "fopen_wrappers.h" +#include "http_status_codes.h" #include "zend_compile.h" #include "zend_execute.h" @@ -203,55 +204,6 @@ typedef struct php_cli_server_http_response_status_code_pair { const char *str; } php_cli_server_http_response_status_code_pair; -static php_cli_server_http_response_status_code_pair status_map[] = { - { 100, "Continue" }, - { 101, "Switching Protocols" }, - { 200, "OK" }, - { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 307, "Temporary Redirect" }, - { 308, "Permanent Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Timeout" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Long" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested Range Not Satisfiable" }, - { 417, "Expectation Failed" }, - { 426, "Upgrade Required" }, - { 428, "Precondition Required" }, - { 429, "Too Many Requests" }, - { 431, "Request Header Fields Too Large" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Timeout" }, - { 505, "HTTP Version Not Supported" }, - { 511, "Network Authentication Required" }, -}; - static php_cli_server_http_response_status_code_pair template_map[] = { { 400, "

%s

Your browser sent a request that this server could not understand.

" }, { 404, "

%s

The requested resource %s was not found on this server.

" }, @@ -336,12 +288,12 @@ static int status_comp(const void *a, const void *b) /* {{{ */ static const char *get_status_string(int code) /* {{{ */ { - php_cli_server_http_response_status_code_pair needle, *result = NULL; + http_response_status_code_pair needle, *result = NULL; needle.code = code; needle.str = NULL; - result = bsearch(&needle, status_map, sizeof(status_map) / sizeof(needle), sizeof(needle), status_comp); + result = bsearch(&needle, http_status_map, sizeof(http_status_map) / sizeof(needle), sizeof(needle), status_comp); if (result) { return result->str; diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 2552f9afe0d..d5e5162e7ba 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -97,6 +97,8 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #include "php_getopt.h" +#include "http_status_codes.h" + #include "fastcgi.h" #include @@ -341,56 +343,6 @@ static void sapi_cgibin_flush(void *server_context TSRMLS_DC) #define SAPI_CGI_MAX_HEADER_LENGTH 1024 -typedef struct _http_error { - int code; - const char* msg; -} http_error; - -static const http_error http_error_codes[] = { - {100, "Continue"}, - {101, "Switching Protocols"}, - {200, "OK"}, - {201, "Created"}, - {202, "Accepted"}, - {203, "Non-Authoritative Information"}, - {204, "No Content"}, - {205, "Reset Content"}, - {206, "Partial Content"}, - {300, "Multiple Choices"}, - {301, "Moved Permanently"}, - {302, "Moved Temporarily"}, - {303, "See Other"}, - {304, "Not Modified"}, - {305, "Use Proxy"}, - {400, "Bad Request"}, - {401, "Unauthorized"}, - {402, "Payment Required"}, - {403, "Forbidden"}, - {404, "Not Found"}, - {405, "Method Not Allowed"}, - {406, "Not Acceptable"}, - {407, "Proxy Authentication Required"}, - {408, "Request Time-out"}, - {409, "Conflict"}, - {410, "Gone"}, - {411, "Length Required"}, - {412, "Precondition Failed"}, - {413, "Request Entity Too Large"}, - {414, "Request-URI Too Large"}, - {415, "Unsupported Media Type"}, - {428, "Precondition Required"}, - {429, "Too Many Requests"}, - {431, "Request Header Fields Too Large"}, - {500, "Internal Server Error"}, - {501, "Not Implemented"}, - {502, "Bad Gateway"}, - {503, "Service Unavailable"}, - {504, "Gateway Time-out"}, - {505, "HTTP Version not supported"}, - {511, "Network Authentication Required"}, - {0, NULL} -}; - static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { char buf[SAPI_CGI_MAX_HEADER_LENGTH]; @@ -441,7 +393,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos); } if (!has_status) { - http_error *err = (http_error*)http_error_codes; + http_response_status_code_pair *err = (http_response_status_code_pair*)http_status_map; while (err->code != 0) { if (err->code == SG(sapi_headers).http_response_code) { @@ -449,8 +401,8 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) } err++; } - if (err->msg) { - len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->msg); + if (err->str) { + len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->str); } else { len = slprintf(buf, sizeof(buf), "Status: %d\r\n", SG(sapi_headers).http_response_code); } From 627b350f31be83eb1d5ac5fad692256dcfaf1281 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Sun, 14 Dec 2014 19:20:06 +0000 Subject: [PATCH 02/11] Fix indentation --- main/http_status_codes.h | 96 ++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/main/http_status_codes.h b/main/http_status_codes.h index c9d32045153..1383c6acdcd 100644 --- a/main/http_status_codes.h +++ b/main/http_status_codes.h @@ -22,57 +22,57 @@ #define HTTP_STATUS_CODES_H typedef struct _http_response_status_code_pair { - int code; - const char *str; + int code; + const char *str; } http_response_status_code_pair; static http_response_status_code_pair http_status_map[] = { - { 100, "Continue" }, - { 101, "Switching Protocols" }, - { 200, "OK" }, - { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 307, "Temporary Redirect" }, - { 308, "Permanent Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Timeout" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Long" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested Range Not Satisfiable" }, - { 417, "Expectation Failed" }, - { 426, "Upgrade Required" }, - { 428, "Precondition Required" }, - { 429, "Too Many Requests" }, - { 431, "Request Header Fields Too Large" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Timeout" }, - { 505, "HTTP Version Not Supported" }, - { 511, "Network Authentication Required" }, + { 100, "Continue" }, + { 101, "Switching Protocols" }, + { 200, "OK" }, + { 201, "Created" }, + { 202, "Accepted" }, + { 203, "Non-Authoritative Information" }, + { 204, "No Content" }, + { 205, "Reset Content" }, + { 206, "Partial Content" }, + { 300, "Multiple Choices" }, + { 301, "Moved Permanently" }, + { 302, "Found" }, + { 303, "See Other" }, + { 304, "Not Modified" }, + { 305, "Use Proxy" }, + { 307, "Temporary Redirect" }, + { 308, "Permanent Redirect" }, + { 400, "Bad Request" }, + { 401, "Unauthorized" }, + { 402, "Payment Required" }, + { 403, "Forbidden" }, + { 404, "Not Found" }, + { 405, "Method Not Allowed" }, + { 406, "Not Acceptable" }, + { 407, "Proxy Authentication Required" }, + { 408, "Request Timeout" }, + { 409, "Conflict" }, + { 410, "Gone" }, + { 411, "Length Required" }, + { 412, "Precondition Failed" }, + { 413, "Request Entity Too Large" }, + { 414, "Request-URI Too Long" }, + { 415, "Unsupported Media Type" }, + { 416, "Requested Range Not Satisfiable" }, + { 417, "Expectation Failed" }, + { 426, "Upgrade Required" }, + { 428, "Precondition Required" }, + { 429, "Too Many Requests" }, + { 431, "Request Header Fields Too Large" }, + { 500, "Internal Server Error" }, + { 501, "Not Implemented" }, + { 502, "Bad Gateway" }, + { 503, "Service Unavailable" }, + { 504, "Gateway Timeout" }, + { 505, "HTTP Version Not Supported" }, + { 511, "Network Authentication Required" }, /* to allow search with while() loop */ { 0, NULL } }; From 04c11f918abcf56b2f0c0d942f20e0e5da76f420 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Sun, 14 Dec 2014 21:57:07 +0100 Subject: [PATCH 03/11] Change is_long() to be an alias of is_integer() @@ See internals: news.php.net/php.internals/79639 @@ Manual will be updated so that is_int() will be an alias of is_integer() @@ I picked integer over int for consitentcy as we do not use str instead of string either --- ext/standard/basic_functions.c | 8 ++++---- ext/standard/php_type.h | 2 +- ext/standard/type.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 9ffe0fe14ee..fbccd5d4d23 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2513,7 +2513,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_is_bool, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_is_long, 0) +ZEND_BEGIN_ARG_INFO(arginfo_is_integer, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() @@ -3027,10 +3027,10 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(is_null, arginfo_is_null) PHP_FE(is_resource, arginfo_is_resource) PHP_FE(is_bool, arginfo_is_bool) - PHP_FE(is_long, arginfo_is_long) + PHP_FE(is_integer, arginfo_is_integer) PHP_FE(is_float, arginfo_is_float) - PHP_FALIAS(is_int, is_long, arginfo_is_long) - PHP_FALIAS(is_integer, is_long, arginfo_is_long) + PHP_FALIAS(is_int, is_integer, arginfo_is_integer) + PHP_FALIAS(is_long, is_integer, arginfo_is_integer) PHP_FALIAS(is_double, is_float, arginfo_is_float) PHP_FALIAS(is_real, is_float, arginfo_is_float) PHP_FE(is_numeric, arginfo_is_numeric) diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h index e6d8152b1be..9ecfcd6d156 100644 --- a/ext/standard/php_type.h +++ b/ext/standard/php_type.h @@ -30,7 +30,7 @@ PHP_FUNCTION(settype); PHP_FUNCTION(is_null); PHP_FUNCTION(is_resource); PHP_FUNCTION(is_bool); -PHP_FUNCTION(is_long); +PHP_FUNCTION(is_integer); PHP_FUNCTION(is_float); PHP_FUNCTION(is_numeric); PHP_FUNCTION(is_string); diff --git a/ext/standard/type.c b/ext/standard/type.c index a773e6c53cb..c410e225f12 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -271,10 +271,10 @@ PHP_FUNCTION(is_bool) } /* }}} */ -/* {{{ proto bool is_long(mixed var) - Returns true if variable is a long (integer) +/* {{{ proto bool is_integer(mixed var) + Returns true if variable is an integer Warning: This function is special-cased by zend_compile.c and so is usually bypassed */ -PHP_FUNCTION(is_long) +PHP_FUNCTION(is_integer) { php_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_LONG); } From a3615aeea40d56c3f4a7e59a8817898baed3ca1a Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Sun, 14 Dec 2014 22:13:07 +0100 Subject: [PATCH 04/11] NEWS --- NEWS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ef6ec3c34c1..293f201004b 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -PHP NEWS +PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 20??, PHP 7.0.0 @@ -26,6 +26,7 @@ PHP NEWS constructor). (dunglas at gmail dot com) . Removed ZEND_ACC_FINAL_CLASS, promoting ZEND_ACC_FINAL as final class modifier. (Guilherme Blanco) + . is_long() and is_int() are now an alias of is_integer(). (Kalle) - Date: . Fixed day_of_week function as it could sometimes return negative values From 6b8ed592b92027ceb4f76e6a06754a9c75ca4f36 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Sun, 14 Dec 2014 22:26:16 +0100 Subject: [PATCH 05/11] =?UTF-8?q?Change=20back=20to=20use=20is=5Fint()=20a?= =?UTF-8?q?s=20function=20instead=20of=20is=5Finteger(),=20as=20per=20Jan?= =?UTF-8?q?=20Tvrd=C3=ADk's=20request=20@github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext/standard/basic_functions.c | 8 ++++---- ext/standard/php_type.h | 2 +- ext/standard/type.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index fbccd5d4d23..479ac7b8a2d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2513,7 +2513,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_is_bool, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_is_integer, 0) +ZEND_BEGIN_ARG_INFO(arginfo_is_int, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() @@ -3027,10 +3027,10 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(is_null, arginfo_is_null) PHP_FE(is_resource, arginfo_is_resource) PHP_FE(is_bool, arginfo_is_bool) - PHP_FE(is_integer, arginfo_is_integer) + PHP_FE(is_int, arginfo_is_int) PHP_FE(is_float, arginfo_is_float) - PHP_FALIAS(is_int, is_integer, arginfo_is_integer) - PHP_FALIAS(is_long, is_integer, arginfo_is_integer) + PHP_FALIAS(is_integer, is_int, arginfo_is_int) + PHP_FALIAS(is_long, is_int, arginfo_is_int) PHP_FALIAS(is_double, is_float, arginfo_is_float) PHP_FALIAS(is_real, is_float, arginfo_is_float) PHP_FE(is_numeric, arginfo_is_numeric) diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h index 9ecfcd6d156..14a782c37b0 100644 --- a/ext/standard/php_type.h +++ b/ext/standard/php_type.h @@ -30,7 +30,7 @@ PHP_FUNCTION(settype); PHP_FUNCTION(is_null); PHP_FUNCTION(is_resource); PHP_FUNCTION(is_bool); -PHP_FUNCTION(is_integer); +PHP_FUNCTION(is_int); PHP_FUNCTION(is_float); PHP_FUNCTION(is_numeric); PHP_FUNCTION(is_string); diff --git a/ext/standard/type.c b/ext/standard/type.c index c410e225f12..41177f0b091 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -271,10 +271,10 @@ PHP_FUNCTION(is_bool) } /* }}} */ -/* {{{ proto bool is_integer(mixed var) +/* {{{ proto bool is_int(mixed var) Returns true if variable is an integer Warning: This function is special-cased by zend_compile.c and so is usually bypassed */ -PHP_FUNCTION(is_integer) +PHP_FUNCTION(is_int) { php_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_LONG); } From 6b00fba8770975ea39ec84deeef948e9788529b3 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Sun, 14 Dec 2014 22:32:42 +0100 Subject: [PATCH 06/11] NEWS --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 293f201004b..de98650f876 100644 --- a/NEWS +++ b/NEWS @@ -26,7 +26,7 @@ constructor). (dunglas at gmail dot com) . Removed ZEND_ACC_FINAL_CLASS, promoting ZEND_ACC_FINAL as final class modifier. (Guilherme Blanco) - . is_long() and is_int() are now an alias of is_integer(). (Kalle) + . is_long() & is_integer() is now an alias of is_int(). (Kalle) - Date: . Fixed day_of_week function as it could sometimes return negative values From d82fa2273f9a02a1cac1494da4a88c2297fe358a Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Sun, 14 Dec 2014 22:47:58 +0100 Subject: [PATCH 07/11] Implement feature request #55467 (phpinfo: PHP Variables with $ and single quotes) --- ext/standard/info.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/standard/info.c b/ext/standard/info.c index 7a118af7b44..73ec873d4ed 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -209,8 +209,9 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) php_info_print(""); } + php_info_print("$"); php_info_print(name); - php_info_print("[\""); + php_info_print("['"); if (string_key != NULL) { if (!sapi_module.phpinfo_as_text) { @@ -221,7 +222,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) } else { php_info_printf(ZEND_ULONG_FMT, num_key); } - php_info_print("\"]"); + php_info_print("']"); if (!sapi_module.phpinfo_as_text) { php_info_print(""); } else { From 9afae43b1238291f7c11fc9a2075289d07fb5ccf Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Sun, 14 Dec 2014 22:49:00 +0100 Subject: [PATCH 08/11] NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index de98650f876..a57e6cbb25a 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,7 @@ . Removed ZEND_ACC_FINAL_CLASS, promoting ZEND_ACC_FINAL as final class modifier. (Guilherme Blanco) . is_long() & is_integer() is now an alias of is_int(). (Kalle) + . Implemented FR #55467 (phpinfo: PHP Variables with $ and single quotes). (Kalle) - Date: . Fixed day_of_week function as it could sometimes return negative values From ad01fd8b49c6117d5c5fce98871c41781a5c00b9 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Sun, 14 Dec 2014 23:09:13 +0100 Subject: [PATCH 09/11] Fixed bug #55415 (php_info produces invalid anchor names) @@ Slightly based off Johannes' patch --- NEWS | 1 + ext/standard/info.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index a57e6cbb25a..aad4837de45 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,7 @@ modifier. (Guilherme Blanco) . is_long() & is_integer() is now an alias of is_int(). (Kalle) . Implemented FR #55467 (phpinfo: PHP Variables with $ and single quotes). (Kalle) + . Fixed bug #55415 (php_info produces invalid anchor names). (Kalle, Johannes) - Date: . Fixed day_of_week function as it could sometimes return negative values diff --git a/ext/standard/info.c b/ext/standard/info.c index 73ec873d4ed..d6911a42ddd 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -146,7 +146,13 @@ PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* { { if (zend_module->info_func || zend_module->version) { if (!sapi_module.phpinfo_as_text) { - php_info_printf("

%s

\n", zend_module->name, zend_module->name); + int len = 0; + zend_string *url_name = php_url_encode(zend_module->name, strlen(zend_module->name), &len); + + php_strtolower(url_name->val, url_name->len); + php_info_printf("

%s

\n", url_name->val, zend_module->name); + + efree(url_name); } else { php_info_print_table_start(); php_info_print_table_header(1, zend_module->name); From 9c18ad3ac9103bc0a6c7b7ab8938fd7272095652 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Sun, 14 Dec 2014 23:40:35 +0000 Subject: [PATCH 10/11] fixed tests, bugs in status codes merger --- .../tests/general_functions/header_redirection_001.phpt | 2 +- .../tests/general_functions/header_redirection_002.phpt | 2 +- main/http_status_codes.h | 4 ++-- sapi/cli/php_cli_server.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/standard/tests/general_functions/header_redirection_001.phpt b/ext/standard/tests/general_functions/header_redirection_001.phpt index ecf57ec54a3..c5ea70b56c4 100644 --- a/ext/standard/tests/general_functions/header_redirection_001.phpt +++ b/ext/standard/tests/general_functions/header_redirection_001.phpt @@ -6,6 +6,6 @@ Location: headers change the status code header('Location: http://example.com/'); ?> --EXPECTHEADERS-- -Status: 302 Moved Temporarily +Status: 302 Found Location: http://example.com/ --EXPECT-- diff --git a/ext/standard/tests/general_functions/header_redirection_002.phpt b/ext/standard/tests/general_functions/header_redirection_002.phpt index 2bf6dec5107..3f8e0b9dac7 100644 --- a/ext/standard/tests/general_functions/header_redirection_002.phpt +++ b/ext/standard/tests/general_functions/header_redirection_002.phpt @@ -7,6 +7,6 @@ header("HTTP/1.1 418 I'm a Teapot"); header('Location: http://example.com/'); ?> --EXPECTHEADERS-- -Status: 302 Moved Temporarily +Status: 302 Found Location: http://example.com/ --EXPECT-- diff --git a/main/http_status_codes.h b/main/http_status_codes.h index 1383c6acdcd..02186b5214c 100644 --- a/main/http_status_codes.h +++ b/main/http_status_codes.h @@ -74,7 +74,7 @@ static http_response_status_code_pair http_status_map[] = { { 505, "HTTP Version Not Supported" }, { 511, "Network Authentication Required" }, /* to allow search with while() loop */ - { 0, NULL } + { 1000, NULL } }; -#endif HTTP_STATUS_CODES_H +#endif /* HTTP_STATUS_CODES_H */ diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index b57ec32fd5a..35eab852277 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -276,8 +276,8 @@ static char *get_last_error() /* {{{ */ static int status_comp(const void *a, const void *b) /* {{{ */ { - const php_cli_server_http_response_status_code_pair *pa = (const php_cli_server_http_response_status_code_pair *) a; - const php_cli_server_http_response_status_code_pair *pb = (const php_cli_server_http_response_status_code_pair *) b; + const http_response_status_code_pair *pa = (const http_response_status_code_pair *) a; + const http_response_status_code_pair *pb = (const http_response_status_code_pair *) b; if (pa->code < pb->code) { return -1; From 7950429626f02afe77a45da6236f3eec84b49eff Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Mon, 15 Dec 2014 01:30:58 +0000 Subject: [PATCH 11/11] Revert HTTP status codes merger This reverts commits 65768edcf3ef27a21a07e5e994bfd9ca1cabfa94, 627b350f31be83eb1d5ac5fad692256dcfaf1281 and 9c18ad3ac9103bc0a6c7b7ab8938fd7272095652. --- .../header_redirection_001.phpt | 2 +- .../header_redirection_002.phpt | 2 +- main/http_status_codes.h | 80 ------------------- sapi/cgi/cgi_main.c | 57 ++++++++++++- sapi/cli/php_cli_server.c | 58 ++++++++++++-- sapi/fpm/fpm/fpm_main.c | 58 ++++++++++++-- 6 files changed, 161 insertions(+), 96 deletions(-) delete mode 100644 main/http_status_codes.h diff --git a/ext/standard/tests/general_functions/header_redirection_001.phpt b/ext/standard/tests/general_functions/header_redirection_001.phpt index c5ea70b56c4..ecf57ec54a3 100644 --- a/ext/standard/tests/general_functions/header_redirection_001.phpt +++ b/ext/standard/tests/general_functions/header_redirection_001.phpt @@ -6,6 +6,6 @@ Location: headers change the status code header('Location: http://example.com/'); ?> --EXPECTHEADERS-- -Status: 302 Found +Status: 302 Moved Temporarily Location: http://example.com/ --EXPECT-- diff --git a/ext/standard/tests/general_functions/header_redirection_002.phpt b/ext/standard/tests/general_functions/header_redirection_002.phpt index 3f8e0b9dac7..2bf6dec5107 100644 --- a/ext/standard/tests/general_functions/header_redirection_002.phpt +++ b/ext/standard/tests/general_functions/header_redirection_002.phpt @@ -7,6 +7,6 @@ header("HTTP/1.1 418 I'm a Teapot"); header('Location: http://example.com/'); ?> --EXPECTHEADERS-- -Status: 302 Found +Status: 302 Moved Temporarily Location: http://example.com/ --EXPECT-- diff --git a/main/http_status_codes.h b/main/http_status_codes.h deleted file mode 100644 index 02186b5214c..00000000000 --- a/main/http_status_codes.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Andrea Faulds | - +----------------------------------------------------------------------+ -*/ - -/* $Id: $ */ - -#ifndef HTTP_STATUS_CODES_H -#define HTTP_STATUS_CODES_H - -typedef struct _http_response_status_code_pair { - int code; - const char *str; -} http_response_status_code_pair; - -static http_response_status_code_pair http_status_map[] = { - { 100, "Continue" }, - { 101, "Switching Protocols" }, - { 200, "OK" }, - { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 307, "Temporary Redirect" }, - { 308, "Permanent Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Timeout" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Long" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested Range Not Satisfiable" }, - { 417, "Expectation Failed" }, - { 426, "Upgrade Required" }, - { 428, "Precondition Required" }, - { 429, "Too Many Requests" }, - { 431, "Request Header Fields Too Large" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Timeout" }, - { 505, "HTTP Version Not Supported" }, - { 511, "Network Authentication Required" }, - /* to allow search with while() loop */ - { 1000, NULL } -}; - -#endif /* HTTP_STATUS_CODES_H */ diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 4f97a701485..1bef17c2574 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -69,7 +69,6 @@ #include "php_globals.h" #include "php_main.h" #include "fopen_wrappers.h" -#include "http_status_codes.h" #include "ext/standard/php_standard.h" #include "ext/standard/url.h" @@ -351,6 +350,56 @@ static void sapi_fcgi_flush(void *server_context TSRMLS_DC) #define SAPI_CGI_MAX_HEADER_LENGTH 1024 +typedef struct _http_error { + int code; + const char* msg; +} http_error; + +static const http_error http_error_codes[] = { + {100, "Continue"}, + {101, "Switching Protocols"}, + {200, "OK"}, + {201, "Created"}, + {202, "Accepted"}, + {203, "Non-Authoritative Information"}, + {204, "No Content"}, + {205, "Reset Content"}, + {206, "Partial Content"}, + {300, "Multiple Choices"}, + {301, "Moved Permanently"}, + {302, "Moved Temporarily"}, + {303, "See Other"}, + {304, "Not Modified"}, + {305, "Use Proxy"}, + {400, "Bad Request"}, + {401, "Unauthorized"}, + {402, "Payment Required"}, + {403, "Forbidden"}, + {404, "Not Found"}, + {405, "Method Not Allowed"}, + {406, "Not Acceptable"}, + {407, "Proxy Authentication Required"}, + {408, "Request Time-out"}, + {409, "Conflict"}, + {410, "Gone"}, + {411, "Length Required"}, + {412, "Precondition Failed"}, + {413, "Request Entity Too Large"}, + {414, "Request-URI Too Large"}, + {415, "Unsupported Media Type"}, + {428, "Precondition Required"}, + {429, "Too Many Requests"}, + {431, "Request Header Fields Too Large"}, + {500, "Internal Server Error"}, + {501, "Not Implemented"}, + {502, "Bad Gateway"}, + {503, "Service Unavailable"}, + {504, "Gateway Time-out"}, + {505, "HTTP Version not supported"}, + {511, "Network Authentication Required"}, + {0, NULL} +}; + static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { char buf[SAPI_CGI_MAX_HEADER_LENGTH]; @@ -401,7 +450,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos); } if (!has_status) { - http_response_status_code_pair *err = (http_response_status_code_pair*)http_status_map; + http_error *err = (http_error*)http_error_codes; while (err->code != 0) { if (err->code == SG(sapi_headers).http_response_code) { @@ -409,8 +458,8 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) } err++; } - if (err->str) { - len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->str); + if (err->msg) { + len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->msg); } else { len = slprintf(buf, sizeof(buf), "Status: %d\r\n", SG(sapi_headers).http_response_code); } diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 35eab852277..a0a9052f8ad 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -68,7 +68,6 @@ #include "zend_hash.h" #include "zend_modules.h" #include "fopen_wrappers.h" -#include "http_status_codes.h" #include "zend_compile.h" #include "zend_execute.h" @@ -204,6 +203,55 @@ typedef struct php_cli_server_http_response_status_code_pair { const char *str; } php_cli_server_http_response_status_code_pair; +static php_cli_server_http_response_status_code_pair status_map[] = { + { 100, "Continue" }, + { 101, "Switching Protocols" }, + { 200, "OK" }, + { 201, "Created" }, + { 202, "Accepted" }, + { 203, "Non-Authoritative Information" }, + { 204, "No Content" }, + { 205, "Reset Content" }, + { 206, "Partial Content" }, + { 300, "Multiple Choices" }, + { 301, "Moved Permanently" }, + { 302, "Found" }, + { 303, "See Other" }, + { 304, "Not Modified" }, + { 305, "Use Proxy" }, + { 307, "Temporary Redirect" }, + { 308, "Permanent Redirect" }, + { 400, "Bad Request" }, + { 401, "Unauthorized" }, + { 402, "Payment Required" }, + { 403, "Forbidden" }, + { 404, "Not Found" }, + { 405, "Method Not Allowed" }, + { 406, "Not Acceptable" }, + { 407, "Proxy Authentication Required" }, + { 408, "Request Timeout" }, + { 409, "Conflict" }, + { 410, "Gone" }, + { 411, "Length Required" }, + { 412, "Precondition Failed" }, + { 413, "Request Entity Too Large" }, + { 414, "Request-URI Too Long" }, + { 415, "Unsupported Media Type" }, + { 416, "Requested Range Not Satisfiable" }, + { 417, "Expectation Failed" }, + { 426, "Upgrade Required" }, + { 428, "Precondition Required" }, + { 429, "Too Many Requests" }, + { 431, "Request Header Fields Too Large" }, + { 500, "Internal Server Error" }, + { 501, "Not Implemented" }, + { 502, "Bad Gateway" }, + { 503, "Service Unavailable" }, + { 504, "Gateway Timeout" }, + { 505, "HTTP Version Not Supported" }, + { 511, "Network Authentication Required" }, +}; + static php_cli_server_http_response_status_code_pair template_map[] = { { 400, "

%s

Your browser sent a request that this server could not understand.

" }, { 404, "

%s

The requested resource %s was not found on this server.

" }, @@ -276,8 +324,8 @@ static char *get_last_error() /* {{{ */ static int status_comp(const void *a, const void *b) /* {{{ */ { - const http_response_status_code_pair *pa = (const http_response_status_code_pair *) a; - const http_response_status_code_pair *pb = (const http_response_status_code_pair *) b; + const php_cli_server_http_response_status_code_pair *pa = (const php_cli_server_http_response_status_code_pair *) a; + const php_cli_server_http_response_status_code_pair *pb = (const php_cli_server_http_response_status_code_pair *) b; if (pa->code < pb->code) { return -1; @@ -290,12 +338,12 @@ static int status_comp(const void *a, const void *b) /* {{{ */ static const char *get_status_string(int code) /* {{{ */ { - http_response_status_code_pair needle, *result = NULL; + php_cli_server_http_response_status_code_pair needle, *result = NULL; needle.code = code; needle.str = NULL; - result = bsearch(&needle, http_status_map, sizeof(http_status_map) / sizeof(needle), sizeof(needle), status_comp); + result = bsearch(&needle, status_map, sizeof(status_map) / sizeof(needle), sizeof(needle), status_comp); if (result) { return result->str; diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index d5e5162e7ba..2552f9afe0d 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -97,8 +97,6 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #include "php_getopt.h" -#include "http_status_codes.h" - #include "fastcgi.h" #include @@ -343,6 +341,56 @@ static void sapi_cgibin_flush(void *server_context TSRMLS_DC) #define SAPI_CGI_MAX_HEADER_LENGTH 1024 +typedef struct _http_error { + int code; + const char* msg; +} http_error; + +static const http_error http_error_codes[] = { + {100, "Continue"}, + {101, "Switching Protocols"}, + {200, "OK"}, + {201, "Created"}, + {202, "Accepted"}, + {203, "Non-Authoritative Information"}, + {204, "No Content"}, + {205, "Reset Content"}, + {206, "Partial Content"}, + {300, "Multiple Choices"}, + {301, "Moved Permanently"}, + {302, "Moved Temporarily"}, + {303, "See Other"}, + {304, "Not Modified"}, + {305, "Use Proxy"}, + {400, "Bad Request"}, + {401, "Unauthorized"}, + {402, "Payment Required"}, + {403, "Forbidden"}, + {404, "Not Found"}, + {405, "Method Not Allowed"}, + {406, "Not Acceptable"}, + {407, "Proxy Authentication Required"}, + {408, "Request Time-out"}, + {409, "Conflict"}, + {410, "Gone"}, + {411, "Length Required"}, + {412, "Precondition Failed"}, + {413, "Request Entity Too Large"}, + {414, "Request-URI Too Large"}, + {415, "Unsupported Media Type"}, + {428, "Precondition Required"}, + {429, "Too Many Requests"}, + {431, "Request Header Fields Too Large"}, + {500, "Internal Server Error"}, + {501, "Not Implemented"}, + {502, "Bad Gateway"}, + {503, "Service Unavailable"}, + {504, "Gateway Time-out"}, + {505, "HTTP Version not supported"}, + {511, "Network Authentication Required"}, + {0, NULL} +}; + static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { char buf[SAPI_CGI_MAX_HEADER_LENGTH]; @@ -393,7 +441,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos); } if (!has_status) { - http_response_status_code_pair *err = (http_response_status_code_pair*)http_status_map; + http_error *err = (http_error*)http_error_codes; while (err->code != 0) { if (err->code == SG(sapi_headers).http_response_code) { @@ -401,8 +449,8 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) } err++; } - if (err->str) { - len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->str); + if (err->msg) { + len = slprintf(buf, sizeof(buf), "Status: %d %s\r\n", SG(sapi_headers).http_response_code, err->msg); } else { len = slprintf(buf, sizeof(buf), "Status: %d\r\n", SG(sapi_headers).http_response_code); }