From: Kalle Sommer Nielsen Date: Mon, 9 Aug 2010 13:10:32 +0000 (+0000) Subject: Implemented FR #52555 (Ability to get HTTP response code) X-Git-Tag: php-5.4.0alpha1~191^2~1124 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4281addcb7053737f88095753732f2b382b80f63;p=php Implemented FR #52555 (Ability to get HTTP response code) - Patch by Paul Dragoonis --- diff --git a/NEWS b/NEWS index 52552be556..5804f369a9 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -PHP NEWS +PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 201?, PHP 5.3.99 - Upgraded bundled sqlite to version 3.6.23.1. (Ilia) @@ -89,6 +89,7 @@ PHP NEWS - Removed support for linking against MySQL client libraries older 4.1 from PDO_mysql. (Johannes) +- Implemented FR #52555 (Ability to get HTTP response code). (Paul Dragoonis) - Implemented FR #51295 (SQLite3::busyTimeout not existing). (Mark) - Implemented FR #48632 (OpenSSL AES support). (yonas dot y at gmail dot com, Pierre) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 1a745a43b4..8d9f5e1b4f 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1470,6 +1470,9 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_headers_list, 0) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_http_response_code, 0) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ html.c */ ZEND_BEGIN_ARG_INFO_EX(arginfo_htmlspecialchars, 0, 0, 1) @@ -2983,6 +2986,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(header_remove, arginfo_header_remove) PHP_FE(headers_sent, arginfo_headers_sent) PHP_FE(headers_list, arginfo_headers_list) + PHP_FE(http_response_code, arginfo_http_response_code) PHP_FE(connection_aborted, arginfo_connection_aborted) PHP_FE(connection_status, arginfo_connection_status) diff --git a/ext/standard/head.c b/ext/standard/head.c index 229398587f..7c0192c4cb 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -281,6 +281,18 @@ PHP_FUNCTION(headers_list) } /* }}} */ +/* {{{ proto long http_response_code() + Returns the current HTTP response code */ +PHP_FUNCTION(http_response_code) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + RETURN_LONG(SG(sapi_headers).http_response_code); +} +/* }}} */ + /* * Local variables: * tab-width: 4 diff --git a/ext/standard/head.h b/ext/standard/head.h index e221799227..e38fbf6d89 100644 --- a/ext/standard/head.h +++ b/ext/standard/head.h @@ -28,6 +28,7 @@ PHP_FUNCTION(setcookie); PHP_FUNCTION(setrawcookie); PHP_FUNCTION(headers_sent); PHP_FUNCTION(headers_list); +PHP_FUNCTION(http_response_code); PHPAPI int php_header(TSRMLS_D); PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, time_t expires, char *path, int path_len, char *domain, int domain_len, int secure, int url_encode, int httponly TSRMLS_DC);