cvs: php4 /ext/standard head.c /main SAPI.c SAPI.h /sapi/pi3web pi3web_sapi.c /sapi/tux php_tux.c

From: Date: Fri, 21 Jun 2002 09:31:22 +0000
Subject: cvs: php4 /ext/standard head.c /main SAPI.c SAPI.h /sapi/pi3web pi3web_sapi.c /sapi/tux php_tux.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12430@lists.php.net to get a copy of this message
derick Fri Jun 21 05:31:22 2002 EDT Modified files: /php4/ext/standard head.c /php4/main SAPI.c SAPI.h /php4/sapi/pi3web pi3web_sapi.c /php4/sapi/tux php_tux.c Log: - Added a new parameter to the header() function which overrides the HTTP response code. @- Added a new parameter to the header() function which overrides the HTTP @ response code. (Derick) Index: php4/ext/standard/head.c diff -u php4/ext/standard/head.c:1.56 php4/ext/standard/head.c:1.57 --- php4/ext/standard/head.c:1.56 Fri May 17 03:10:19 2002 +++ php4/ext/standard/head.c Fri Jun 21 05:31:20 2002 @@ -15,7 +15,7 @@ | Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: head.c,v 1.56 2002/05/17 07:10:19 jwoolley Exp $ */ +/* $Id: head.c,v 1.57 2002/06/21 09:31:20 derick Exp $ */ #include <stdio.h> #include "php.h" @@ -35,19 +35,20 @@ /* Implementation of the language Header() function */ -/* {{{ proto void header(string header [, bool replace]) +/* {{{ proto void header(string header [, bool replace, [int http_response_code]]) Sends a raw HTTP header */ PHP_FUNCTION(header) { char *header; int header_len; zend_bool replace = 1; + int http_code = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &header, - &header_len, &replace) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bl", &header, + &header_len, &replace, &http_code) == FAILURE) { return; } - sapi_add_header_ex(header, header_len, 1, replace TSRMLS_CC); + sapi_add_header_ex(header, header_len, 1, replace, http_code TSRMLS_CC); } /* }}} */ @@ -121,7 +122,7 @@ strcat(cookie, "; secure"); } - return sapi_add_header_ex(cookie, strlen(cookie), 0, 0 TSRMLS_CC); + return sapi_add_header_ex(cookie, strlen(cookie), 0, 0, 0 TSRMLS_CC); } Index: php4/main/SAPI.c diff -u php4/main/SAPI.c:1.132 php4/main/SAPI.c:1.133 --- php4/main/SAPI.c:1.132 Tue Jun 18 11:04:58 2002 +++ php4/main/SAPI.c Fri Jun 21 05:31:21 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.c,v 1.132 2002/06/18 15:04:58 sesser Exp $ */ +/* $Id: SAPI.c,v 1.133 2002/06/21 09:31:21 derick Exp $ */ #include <ctype.h> #include <sys/stat.h> @@ -393,7 +393,7 @@ /* This function expects a *duplicated* string, that was previously emalloc()'d. * Pointers sent to this functions will be automatically freed by the framework. */ -SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC) +SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace, int http_response_code TSRMLS_DC) { int retval; sapi_header_struct sapi_header; @@ -462,11 +462,11 @@ efree(mimetype); SG(sapi_headers).send_default_content_type = 0; } else if (!STRCASECMP(header_line, "Location")) { - if (SG(sapi_headers).http_response_code < 300 || - SG(sapi_headers).http_response_code > 307) { - /* Return a Found Redirect if one is not already specified */ + if (SG(sapi_headers).http_response_code < 300 || + SG(sapi_headers).http_response_code > 307) { + /* Return a Found Redirect if one is not already specified */ SG(sapi_headers).http_response_code = 302; - } + } } else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */ int newlen; char *result, *newheader; @@ -547,6 +547,9 @@ } } + if (http_response_code) { + SG(sapi_headers).http_response_code = http_response_code; + } if (sapi_module.header_handler) { retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) TSRMLS_CC); } else { Index: php4/main/SAPI.h diff -u php4/main/SAPI.h:1.81 php4/main/SAPI.h:1.82 --- php4/main/SAPI.h:1.81 Fri May 10 23:41:16 2002 +++ php4/main/SAPI.h Fri Jun 21 05:31:21 2002 @@ -133,9 +133,9 @@ SAPI_API void sapi_deactivate(TSRMLS_D); SAPI_API void sapi_initialize_empty_request(TSRMLS_D); -SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC); +SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace, int http_response_code TSRMLS_DC); #define sapi_add_header(header_line, header_line_len, duplicate) \ - sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1 TSRMLS_CC) + sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1, 0 TSRMLS_CC) SAPI_API int sapi_send_headers(TSRMLS_D); SAPI_API void sapi_free_header(sapi_header_struct *sapi_header); SAPI_API void sapi_handle_post(void *arg TSRMLS_DC); Index: php4/sapi/pi3web/pi3web_sapi.c diff -u php4/sapi/pi3web/pi3web_sapi.c:1.40 php4/sapi/pi3web/pi3web_sapi.c:1.41 --- php4/sapi/pi3web/pi3web_sapi.c:1.40 Sat Feb 23 10:16:59 2002 +++ php4/sapi/pi3web/pi3web_sapi.c Fri Jun 21 05:31:21 2002 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pi3web_sapi.c,v 1.40 2002/02/23 15:16:59 holger Exp $ */ +/* $Id: pi3web_sapi.c,v 1.41 2002/06/21 09:31:21 derick Exp $ */ #include "pi3web_sapi.h" #include "php.h" @@ -77,7 +77,7 @@ PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n"); PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n"); php_info_print_table_header(2, "Information Field", "Value"); - php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.40 2002/02/23 15:16:59 holger Exp $"); + php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.41 2002/06/21 09:31:21 derick Exp $"); php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp()); snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled()); php_info_print_table_row(2, "Debug Enabled", variable_buf); @@ -424,7 +424,7 @@ break; case PHP_MODE_INDENT: header_line = (char *)estrdup("Content-Type: text/plain"); - sapi_add_header_ex(header_line, strlen(header_line), 1, 1 TSRMLS_CC); + sapi_add_header_ex(header_line, strlen(header_line), 1, 1, 0 TSRMLS_CC); if ( open_file_for_scanning( &file_handle TSRMLS_CC ) == SUCCESS ) { zend_indent(); Index: php4/sapi/tux/php_tux.c diff -u php4/sapi/tux/php_tux.c:1.15 php4/sapi/tux/php_tux.c:1.16 --- php4/sapi/tux/php_tux.c:1.15 Mon Mar 4 03:25:20 2002 +++ php4/sapi/tux/php_tux.c Fri Jun 21 05:31:21 2002 @@ -195,7 +195,7 @@ sprintf(buf, "Server: %s", TUXAPI_version); - sapi_add_header_ex(buf, strlen(buf), 1, 0 TSRMLS_CC); + sapi_add_header_ex(buf, strlen(buf), 1, 0, 0 TSRMLS_CC); php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC); php_register_variable("SERVER_SOFTWARE", TUXAPI_version, track_vars_array TSRMLS_CC); php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_CC);

« previous php.cvs (#12430) next »