[PHP4BETA] CVS update: php4

From: Date: Wed, 05 May 1999 21:05:43 +0000
Subject: [PHP4BETA] CVS update: php4
Groups: php.version4 
Request: Send a blank email to php-version4+get-659@lists.php.net to get a copy of this message
Date: Wednesday May 5, 1999 @ 17:05 Author: zeev Update of /repository/php4 In directory php:/tmp/cvs-serv5229 Modified Files: SAPI.c SAPI.h cgi_main.c main.c main.h output.c output.h Log Message: Get CGI to work with the new headers code. Now Apache is the only interface that doesn't use it. Index: php4/SAPI.c diff -u php4/SAPI.c:1.6 php4/SAPI.c:1.7 --- php4/SAPI.c:1.6 Wed May 5 15:53:15 1999 +++ php4/SAPI.c Wed May 5 17:05:43 1999 @@ -97,6 +97,7 @@ SAPI_API int sapi_send_headers() { int retval; + sapi_header_struct default_header = { DEFAULT_CONTENT_TYPE, sizeof(DEFAULT_CONTENT_TYPE)-1 }; SLS_FETCH(); if (SG(headers_sent)) { @@ -115,7 +116,13 @@ return SUCCESS; break; case SAPI_HEADER_DO_SEND: + if (SG(sapi_headers).content_type.header) { + sapi_module.send_header(&SG(sapi_headers).content_type, SG(server_context)); + } else { + sapi_module.send_header(&default_header, SG(server_context)); + } zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) sapi_module.send_header, SG(server_context)); + sapi_module.send_header(NULL, SG(server_context)); SG(headers_sent) = 1; return SUCCESS; break; Index: php4/SAPI.h diff -u php4/SAPI.h:1.6 php4/SAPI.h:1.7 --- php4/SAPI.h:1.6 Wed May 5 15:53:15 1999 +++ php4/SAPI.h Wed May 5 17:05:43 1999 @@ -90,7 +90,7 @@ int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers); int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC); - void (*send_header)(void *server_context, sapi_header_struct *sapi_header); + void (*send_header)(sapi_header_struct *sapi_header, void *server_context); }; Index: php4/cgi_main.c diff -u php4/cgi_main.c:1.6 php4/cgi_main.c:1.7 --- php4/cgi_main.c:1.6 Sun May 2 15:54:01 1999 +++ php4/cgi_main.c Wed May 5 17:05:43 1999 @@ -76,6 +76,15 @@ } +static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_context) +{ + if (sapi_header) { + PHPWRITE_H(sapi_header->header, sapi_header->header_len); + } + PHPWRITE_H("\r\n", 2); +} + + static sapi_module_struct sapi_module = { "PHP Language", /* name */ @@ -83,6 +92,10 @@ php_module_shutdown_wrapper, /* shutdown */ zend_cgibin_ub_write, /* unbuffered write */ + + NULL, /* header handler */ + NULL, /* send headers handler */ + sapi_cgi_send_header, /* send header handler */ }; @@ -117,8 +130,15 @@ static void init_request_info(SLS_D) { + char *request_method = getenv("REQUEST_METHOD"); + SG(request_info).query_string = getenv("QUERY_STRING"); SG(request_info).request_uri = getenv("PATH_INFO"); + if (request_method && !strcmp(request_method, "HEAD")) { + SG(request_info).headers_only = 1; + } else { + SG(request_info).headers_only = 0; + } } @@ -215,7 +235,7 @@ switch (c) { case 'f': if (!_cgi_started){ - if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) { + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { php_module_shutdown(); return FAILURE; } @@ -228,7 +248,7 @@ break; case 'v': if (!_cgi_started) { - if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) { + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { php_module_shutdown(); return FAILURE; } @@ -238,7 +258,7 @@ break; case 'i': if (!_cgi_started) { - if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) { + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { php_module_shutdown(); return FAILURE; } @@ -286,7 +306,7 @@ #endif if (!_cgi_started) { - if (php_request_startup(CLS_C ELS_CC PLS_CC)==FAILURE) { + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { php_module_shutdown(); return FAILURE; } Index: php4/main.c diff -u php4/main.c:1.45 php4/main.c:1.46 --- php4/main.c:1.45 Wed May 5 15:53:15 1999 +++ php4/main.c Wed May 5 17:05:43 1999 @@ -29,7 +29,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.45 1999/05/05 19:53:15 zeev Exp $ */ +/* $Id: main.c,v 1.46 1999/05/05 21:05:43 zeev Exp $ */ #include <stdio.h> @@ -597,7 +597,7 @@ -int php_request_startup(CLS_D ELS_DC PLS_DC) +int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC) { PG(unclean_shutdown) = 0; @@ -628,12 +628,11 @@ php3_printf("Unable to initialize request info.\n"); return FAILURE; } - + sapi_activate(SLS_C); init_compiler(CLS_C ELS_CC); init_executor(CLS_C ELS_CC); startup_scanner(CLS_C); - return SUCCESS; } @@ -661,11 +660,11 @@ CLS_FETCH(); ELS_FETCH(); PLS_FETCH(); + SLS_FETCH(); php3_header(); zend_end_ob_buffering(1); - php3_call_shutdown_functions(); php_ini_rshutdown(); @@ -679,6 +678,8 @@ php3_unset_timeout(); + sapi_deactivate(SLS_C); + #if CGI_BINARY fflush(stdout); if(request_info.php_argv0) { @@ -1193,7 +1194,7 @@ SG(server_context) = r; - if (php_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) { + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) { return FAILURE; } php3_TreatHeaders(); Index: php4/main.h diff -u php4/main.h:1.7 php4/main.h:1.8 --- php4/main.h:1.7 Sun May 2 14:07:40 1999 +++ php4/main.h Wed May 5 17:05:43 1999 @@ -29,7 +29,7 @@ */ -/* $Id: main.h,v 1.7 1999/05/02 18:07:40 andi Exp $ */ +/* $Id: main.h,v 1.8 1999/05/05 21:05:43 zeev Exp $ */ #ifndef _MAIN_H @@ -39,7 +39,7 @@ #include "php_globals.h" #include "SAPI.h" -PHPAPI int php_request_startup(CLS_D ELS_DC PLS_DC); +PHPAPI int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC); PHPAPI void php_request_shutdown(void *dummy); PHPAPI void php_request_shutdown_for_exec(void *dummy); PHPAPI int php_module_startup(sapi_module_struct *sf); Index: php4/output.c diff -u php4/output.c:1.8 php4/output.c:1.9 --- php4/output.c:1.8 Wed May 5 15:53:15 1999 +++ php4/output.c Wed May 5 17:05:43 1999 @@ -19,8 +19,8 @@ #include "SAPI.h" /* output functions */ -int (*zend_body_write)(const char *str, uint str_length); /* string output */ -int (*zend_header_write)(const char *str, uint str_length); /* unbuffer string output */ +PHPAPI int (*zend_body_write)(const char *str, uint str_length); /* string output */ +PHPAPI int (*zend_header_write)(const char *str, uint str_length); /* unbuffer string output */ static int zend_ub_body_write(const char *str, uint str_length); static int zend_ub_body_write_no_header(const char *str, uint str_length); static int zend_b_body_write(const char *str, uint str_length); Index: php4/output.h diff -u php4/output.h:1.2 php4/output.h:1.3 --- php4/output.h:1.2 Mon Apr 26 10:00:46 1999 +++ php4/output.h Wed May 5 17:05:43 1999 @@ -6,8 +6,8 @@ PHPAPI void zend_output_startup(); /* exported output functions */ -int (*zend_body_write)(const char *str, uint str_length); /* string output */ -int (*zend_header_write)(const char *str, uint str_length); /* unbuffer string output */ +PHPAPI int (*zend_body_write)(const char *str, uint str_length); /* string output */ +PHPAPI int (*zend_header_write)(const char *str, uint str_length); /* unbuffer string output */ void zend_start_ob_buffering(); void zend_end_ob_buffering(int send_buffer); int zend_ob_get_buffer(pval *p); -- PHP 4 Beta

« previous php.version4 (#659) next »