cvs: php4 /sapi/apache php_apache.c

From: Date: Fri, 31 May 2002 23:49:49 +0000
Subject: cvs: php4 /sapi/apache php_apache.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12187@lists.php.net to get a copy of this message
rasmus Fri May 31 19:49:49 2002 EDT Modified files: /php4/sapi/apache php_apache.c Log: @ Renamed getallheaders() to apache_request_headers() and kept @ getallheaders() as an alias to it. Also added apache_response_headers() @ which returns the current response headers from Apache. Renamed getallheaders() to apache_request_headers() and kept getallheaders() as an alias to it. Also added apache_response_headers() which returns the current response headers from Apache. Index: php4/sapi/apache/php_apache.c diff -u php4/sapi/apache/php_apache.c:1.60 php4/sapi/apache/php_apache.c:1.61 --- php4/sapi/apache/php_apache.c:1.60 Fri May 31 05:07:12 2002 +++ php4/sapi/apache/php_apache.c Fri May 31 19:49:49 2002 @@ -17,11 +17,11 @@ | David Sklar <sklar@student.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_apache.c,v 1.60 2002/05/31 09:07:12 rvenkat Exp $ */ +/* $Id: php_apache.c,v 1.61 2002/05/31 23:49:49 rasmus Exp $ */ #include "php_apache_http.h" -#if defined(PHP_WIN32) || defined(NETWARE) +#ifdef PHP_WIN32 #include "zend.h" #include "ap_compat.h" #else @@ -39,7 +39,8 @@ extern module *top_module; PHP_FUNCTION(virtual); -PHP_FUNCTION(getallheaders); +PHP_FUNCTION(apache_request_headers); +PHP_FUNCTION(apache_response_headers); PHP_FUNCTION(apachelog); PHP_FUNCTION(apache_note); PHP_FUNCTION(apache_lookup_uri); @@ -50,11 +51,13 @@ function_entry apache_functions[] = { PHP_FE(virtual, NULL) - PHP_FE(getallheaders, NULL) + PHP_FE(apache_request_headers, NULL) PHP_FE(apache_note, NULL) PHP_FE(apache_lookup_uri, NULL) PHP_FE(apache_child_terminate, NULL) PHP_FE(apache_setenv, NULL) + PHP_FE(apache_response_headers, NULL) + PHP_FALIAS(getallheaders, apache_request_headers, NULL) {NULL, NULL, NULL} }; @@ -77,7 +80,7 @@ static PHP_MINIT_FUNCTION(apache) { #ifdef ZTS - ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor)php_apache_globals_ctor, NULL); + ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), php_apache_globals_ctor, NULL); #else php_apache_globals_ctor(&php_apache_info TSRMLS_CC); #endif @@ -180,10 +183,6 @@ php_info_print_table_row(1, "Apache for Windows 95/NT"); php_info_print_table_end(); php_info_print_table_start(); -#elif defined(NETWARE) - php_info_print_table_row(1, "Apache for NetWare"); - php_info_print_table_end(); - php_info_print_table_start(); #else php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE); php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET); @@ -208,11 +207,6 @@ sprintf(output_buf, "Connection: %d - Keep-Alive: %d", serv->timeout, serv->keep_alive_timeout); php_info_print_table_row(2, "Timeouts", output_buf); #if !defined(WIN32) && !defined(WINNT) -/* - This block seems to be working on NetWare; But it seems to be showing - all modules instead of just the loaded ones -*/ - php_info_print_table_row(2, "Server Root", server_root); strcpy(modulenames, ""); @@ -330,8 +324,11 @@ /* }}} */ /* {{{ proto array getallheaders(void) + Alias for apache_request_headers() */ +/* }}} */ +/* {{{ proto array apache_request_headers(void) Fetch all HTTP request headers */ -PHP_FUNCTION(getallheaders) +PHP_FUNCTION(apache_request_headers) { array_header *env_arr; table_entry *tenv; @@ -352,6 +349,28 @@ RETURN_FALSE; } } +} +/* }}} */ + +/* {{{ proto array apache_response_headers(void) + Fetch all HTTP response headers */ +PHP_FUNCTION(apache_response_headers) +{ + array_header *env_arr; + table_entry *tenv; + int i; + + if (array_init(return_value) == FAILURE) { + RETURN_FALSE; + } + env_arr = table_elts(((request_rec *) SG(server_context))->headers_out); + tenv = (table_entry *)env_arr->elts; + for (i = 0; i < env_arr->nelts; ++i) { + if (!tenv[i].key) continue; + if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) { + RETURN_FALSE; + } + } } /* }}} */

« previous php.cvs (#12187) next »