-PHP NEWS
+PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2011, PHP 5.4.0 Alpha 2
- General improvements:
. 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)
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 */
}
/* }}} */
-/* {{{ 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;
}