Any interest in the attached patch? It introduces a
headers_response_code() function which returns
SG(sapi_headers).http_response code. This information does not seem to
be otherwise available -- the status line does not come back with
headers_list().
Index: ext/standard/basic_functions.c
===
RCS file: /repository/php-src/ext/standard/basic_functions.c,v
retrieving revision 1.725.2.31.2.64.2.35
diff -u -r1.725.2.31.2.64.2.35 basic_functions.c
--- ext/standard/basic_functions.c 25 May 2008 14:06:13 -
1.725.2.31.2.64.2.35
+++ ext/standard/basic_functions.c 16 Jun 2008 17:51:40 -
@@ -1680,9 +1680,13 @@
static
ZEND_BEGIN_ARG_INFO(arginfo_headers_list, 0)
ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_headers_response_code, 0)
+ZEND_END_ARG_INFO()
/* }}} */
/* {{{ html.c */
-static
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_htmlspecialchars, 0, 0, 1)
ZEND_ARG_INFO(0, string)
ZEND_ARG_INFO(0, quote_style)
@@ -3392,6 +3396,7 @@
PHP_FE(header,
arginfo_header)
PHP_FE(headers_sent,
arginfo_headers_sent)
PHP_FE(headers_list,
arginfo_headers_list)
+PHP_FE(headers_response_code,
arginfo_headers_response_code)
PHP_FE(connection_aborted,
arginfo_connection_aborted)
PHP_FE(connection_status,
arginfo_connection_status)
Index: ext/standard/head.c
===
RCS file: /repository/php-src/ext/standard/head.c,v
retrieving revision 1.84.2.1.2.7.2.4
diff -u -r1.84.2.1.2.7.2.4 head.c
--- ext/standard/head.c 10 Jun 2008 08:14:52 - 1.84.2.1.2.7.2.4
+++ ext/standard/head.c 16 Jun 2008 17:51:40 -
@@ -258,6 +258,20 @@
}
/* }}} */
+/* {{{ proto int headers_response_code(void)
+ Return response code for current request */
+PHP_FUNCTION(headers_response_code)
+{
+if (ZEND_NUM_ARGS() 0) {
+WRONG_PARAM_COUNT;
+}
+if (!SG(sapi_headers).http_response_code) {
+RETURN_FALSE;
+}
+RETURN_LONG(SG(sapi_headers).http_response_code);
+}
+/* }}} */
+
/*
* Local variables:
* tab-width: 4
Index: ext/standard/head.h
===
RCS file: /repository/php-src/ext/standard/head.h,v
retrieving revision 1.28.2.1.2.2.2.1
diff -u -r1.28.2.1.2.2.2.1 head.h
--- ext/standard/head.h 31 Dec 2007 07:17:15 - 1.28.2.1.2.2.2.1
+++ ext/standard/head.h 16 Jun 2008 17:51:40 -
@@ -27,6 +27,7 @@
PHP_FUNCTION(setrawcookie);
PHP_FUNCTION(headers_sent);
PHP_FUNCTION(headers_list);
+PHP_FUNCTION(headers_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);
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php