svn: /php/php-src/ branches/PHP_5_4/NEWS branches/PHP_5_4/ext/standard/basic_functions.c branches/PHP_5_4/ext/standard/head.c
trunk/ext/standard/basic_functions.c trunk/ext/standard/head.c
| From: | Kalle Sommer Nielsen | Date: | Tue, 12 Jul 2011 03:56:32 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_4/NEWS branches/PHP_5_4/ext/standard/basic_functions.c branches/PHP_5_4/ext/standard/head.c trunk/ext/standard/basic_functions.c trunk/ext/standard/head.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-65464@lists.php.net to get a copy of this message | ||
kalle Tue, 12 Jul 2011 03:56:32 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=313156
Log:
Changed http_response_code() to be able to set a response code
Changed paths:
U php/php-src/branches/PHP_5_4/NEWS
U php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c
U php/php-src/branches/PHP_5_4/ext/standard/head.c
U php/php-src/trunk/ext/standard/basic_functions.c
U php/php-src/trunk/ext/standard/head.c
Modified: php/php-src/branches/PHP_5_4/NEWS
===================================================================
--- php/php-src/branches/PHP_5_4/NEWS 2011-07-12 01:40:32 UTC (rev 313155)
+++ php/php-src/branches/PHP_5_4/NEWS 2011-07-12 03:56:32 UTC (rev 313156)
@@ -1,4 +1,4 @@
-PHP NEWS
+PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2011, PHP 5.4.0 Alpha 2
- General improvements:
@@ -16,6 +16,7 @@
. Lowered default value for Process Manager. FR #54098. (fat)
- Improved core functions:
+ . Changed http_response_code() to be able to set a response code. (Kalle)
. Fixed crypt_blowfish handling of 8-bit characters. (Stas) (CVE-2011-2483)
. Fixed bug#55084 (Function registered by header_register_callback is
called only once per process). (Hannes)
Modified: php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c 2011-07-12 01:40:32 UTC (rev 313155)
+++ php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c 2011-07-12 03:56:32 UTC (rev 313156)
@@ -1481,7 +1481,8 @@
ZEND_BEGIN_ARG_INFO(arginfo_headers_list, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO(arginfo_http_response_code, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_http_response_code, 0, 0, 0)
+ ZEND_ARG_INFO(0, response_code)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ html.c */
Modified: php/php-src/branches/PHP_5_4/ext/standard/head.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/standard/head.c 2011-07-12 01:40:32 UTC (rev 313155)
+++ php/php-src/branches/PHP_5_4/ext/standard/head.c 2011-07-12 03:56:32 UTC (rev 313156)
@@ -280,14 +280,30 @@
}
/* }}} */
-/* {{{ proto long http_response_code()
- Returns the current HTTP response code */
+/* {{{ proto long http_response_code([int response_code])
+ Sets a response code, or returns the current HTTP response code */
PHP_FUNCTION(http_response_code)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ long response_code = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &response_code) ==
FAILURE) {
return;
}
+ if (response_code)
+ {
+ long old_response_code;
+
+ old_response_code = SG(sapi_headers).http_response_code;
+ SG(sapi_headers).http_response_code = response_code;
+
+ if (old_response_code) {
+ RETURN_LONG(old_response_code);
+ }
+
+ RETURN_TRUE;
+ }
+
if (!SG(sapi_headers).http_response_code) {
RETURN_FALSE;
}
Modified: php/php-src/trunk/ext/standard/basic_functions.c
===================================================================
--- php/php-src/trunk/ext/standard/basic_functions.c 2011-07-12 01:40:32 UTC (rev 313155)
+++ php/php-src/trunk/ext/standard/basic_functions.c 2011-07-12 03:56:32 UTC (rev 313156)
@@ -1483,7 +1483,8 @@
ZEND_BEGIN_ARG_INFO(arginfo_headers_list, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO(arginfo_http_response_code, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_http_response_code, 0, 0, 0)
+ ZEND_ARG_INFO(0, response_code)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ html.c */
Modified: php/php-src/trunk/ext/standard/head.c
===================================================================
--- php/php-src/trunk/ext/standard/head.c 2011-07-12 01:40:32 UTC (rev 313155)
+++ php/php-src/trunk/ext/standard/head.c 2011-07-12 03:56:32 UTC (rev 313156)
@@ -280,14 +280,30 @@
}
/* }}} */
-/* {{{ proto long http_response_code()
- Returns the current HTTP response code */
+/* {{{ proto long http_response_code([int response_code])
+ Sets a response code, or returns the current HTTP response code */
PHP_FUNCTION(http_response_code)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ long response_code = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &response_code) ==
FAILURE) {
return;
}
+ if (response_code)
+ {
+ long old_response_code;
+
+ old_response_code = SG(sapi_headers).http_response_code;
+ SG(sapi_headers).http_response_code = response_code;
+
+ if (old_response_code) {
+ RETURN_LONG(old_response_code);
+ }
+
+ RETURN_TRUE;
+ }
+
if (!SG(sapi_headers).http_response_code) {
RETURN_FALSE;
}