cvs: /php4 SAPI.c SAPI.h /php4/ext/session php_session.h /php4/ext/standard basic_functions.c head.c output.c php_output.h /php4/sapi/aolserver
aolserver.c /php4/sapi/apache mod_php4.c /php4/sapi/cgi cgi_main.c /php4/sapi/isapi php4isapi.c /php4/sapi/phttpd phttpd.c /php4/sapi/roxen roxen.c
/php4/sapi/servlet servlet.c /php4/sapi/thttpd thttpd.c

From: Date: Thu, 13 Jan 2000 17:37:25 +0000
Subject: cvs: /php4 SAPI.c SAPI.h /php4/ext/session php_session.h /php4/ext/standard basic_functions.c head.c output.c php_output.h /php4/sapi/aolserver
aolserver.c /php4/sapi/apache mod_php4.c /php4/sapi/cgi cgi_main.c /php4/sapi/isapi php4isapi.c /php4/sapi/phttpd phttpd.c /php4/sapi/roxen roxen.c
/php4/sapi/servlet servlet.c /php4/sapi/thttpd thttpd.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-9112@lists.php.net to get a copy of this message
zeev Thu Jan 13 09:37:25 2000 EDT Modified files: /php4 SAPI.c SAPI.h /php4/ext/session php_session.h /php4/ext/standard basic_functions.c head.c output.c php_output.h /php4/sapi/aolserver aolserver.c /php4/sapi/apache mod_php4.c /php4/sapi/cgi cgi_main.c /php4/sapi/isapi php4isapi.c /php4/sapi/phttpd phttpd.c /php4/sapi/roxen roxen.c /php4/sapi/servlet servlet.c /php4/sapi/thttpd thttpd.c Log: - Added flush() support to SAPI - Got rid of the old flush() implemenetation in favour of the new one - Added implicit_flush() support to the output buffering layer. @- Added implicit_flush() to control whether flush() should be called @ implicitly after any output (Zeev) Index: php4/SAPI.c diff -u php4/SAPI.c:1.40 php4/SAPI.c:1.41 --- php4/SAPI.c:1.40 Wed Jan 5 11:25:17 2000 +++ php4/SAPI.c Thu Jan 13 09:37:20 2000 @@ -357,3 +357,15 @@ return SUCCESS; } + +SAPI_API int sapi_flush() +{ + if (sapi_module.flush) { + SLS_FETCH(); + + sapi_module.flush(SG(server_context)); + return SUCCESS; + } else { + return FAILURE; + } +} Index: php4/SAPI.h diff -u php4/SAPI.h:1.25 php4/SAPI.h:1.26 --- php4/SAPI.h:1.25 Fri Dec 31 17:31:27 1999 +++ php4/SAPI.h Thu Jan 13 09:37:20 2000 @@ -126,6 +126,9 @@ SAPI_API void sapi_unregister_post_reader(sapi_post_content_type_reader *post_content_type_reader); SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(char *content_type_dup SLS_DC)); +SAPI_API int sapi_flush(); + + struct _sapi_module_struct { char *name; @@ -133,6 +136,7 @@ int (*shutdown)(struct _sapi_module_struct *sapi_module); int (*ub_write)(const char *str, unsigned int str_length); + void (*flush)(void *server_context); void (*sapi_error)(int type, const char *error_msg, ...); Index: php4/ext/session/php_session.h diff -u php4/ext/session/php_session.h:1.24 php4/ext/session/php_session.h:1.25 --- php4/ext/session/php_session.h:1.24 Sun Dec 12 06:16:55 1999 +++ php4/ext/session/php_session.h Thu Jan 13 09:37:20 2000 @@ -152,7 +152,7 @@ #ifdef TRANS_SID void session_adapt_uris(const char *, uint, char **, uint *); #else -#define session_adapt_uris(a,b,c,d) do { } while(0) +#define session_adapt_uris(a,b,c,d) #endif void _php_session_auto_start(void *data); Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.147 php4/ext/standard/basic_functions.c:1.148 --- php4/ext/standard/basic_functions.c:1.147 Tue Jan 4 05:56:13 2000 +++ php4/ext/standard/basic_functions.c Thu Jan 13 09:37:20 2000 @@ -595,28 +595,10 @@ convert_to_string(return_value); } + PHP_FUNCTION(flush) { -#if APACHE - SLS_FETCH(); -#endif - -#if APACHE -# if MODULE_MAGIC_NUMBER > 19970110 - rflush(((request_rec *) SG(server_context))); -# else - bflush(((request_rec *) SG(server_context))->connection->client); -# endif -#endif -#if FHTTPD - /*FIXME -- what does it flush really? the whole response?*/ -#endif -#if CGI_BINARY - fflush(stdout); -#endif -#if USE_SAPI - sapi_rqst->flush(sapi_rqst->scid); -#endif + sapi_flush(); } Index: php4/ext/standard/head.c diff -u php4/ext/standard/head.c:1.24 php4/ext/standard/head.c:1.25 --- php4/ext/standard/head.c:1.24 Fri Dec 31 17:31:52 1999 +++ php4/ext/standard/head.c Thu Jan 13 09:37:20 2000 @@ -15,7 +15,7 @@ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: head.c,v 1.24 2000/01/01 01:31:52 sas Exp $ */ +/* $Id: head.c,v 1.25 2000/01/13 17:37:20 zeev Exp $ */ #include <stdio.h> #include "php.h" @@ -203,163 +203,6 @@ } - - - -#if 0 -/* - * php_header() flushes the header info built up using calls to - * the Header() function. If type is 1, a redirect to str is done. - * Otherwise type should be 0 and str NULL. - * - * The function returns non-zero if output is allowed after the - * call, and zero otherwise. Any call to php_header() must check - * the return status and if false, no output must be sent. This - * is in order to correctly handle HEAD requests. - */ -PHPAPI int php_header(void) -{ -#if APACHE - CookieList *cookie; - int len = 0; - time_t t; - char *dt, *cookievalue = NULL; -#endif -#if APACHE || defined(USE_SAPI) || FHTTPD - char *tempstr; -#endif - PLS_FETCH(); - SLS_FETCH(); - - if (PG(header_is_being_sent)) { - return 0; - } else { - PG(header_is_being_sent) = 1; - } - -#if APACHE - if (!((request_rec *) SG(server_context))) { /* we're not in a request, allow output */ - PG(header_is_being_sent) = 0; - return 1; - } - if ((php_print_header && !php_header_printed) || (php_print_header && php_header_printed == 2)) { - cookie = php_pop_cookie_list(); - while (cookie) { - if (cookie->name) - len += strlen(cookie->name); - if (cookie->value) { - cookievalue = php_url_encode(cookie->value, strlen (cookie->value)); - len += strlen(cookievalue); - } - if (cookie->path) - len += strlen(cookie->path); - if (cookie->domain) - len += strlen(cookie->domain); - tempstr = emalloc(len + 100); - if (!cookie->value || (cookie->value && !*cookie->value)) { - /* - * MSIE doesn't delete a cookie when you set it to a null value - * so in order to force cookies to be deleted, even on MSIE, we - * pick an expiry date 1 year and 1 second in the past - */ - sprintf(tempstr, "%s=deleted", cookie->name); - t = time(NULL) - 31536001; - strcat(tempstr, "; expires="); - dt = php_std_date(t); - strcat(tempstr, dt); - efree(dt); - } else { - /* FIXME: XXX: this is not binary data safe */ - sprintf(tempstr, "%s=%s", cookie->name, cookie->value ? cookievalue : ""); - if (cookie->name) efree(cookie->name); - if (cookie->value) efree(cookie->value); - if (cookievalue) efree(cookievalue); - cookie->name=NULL; - cookie->value=NULL; - cookievalue=NULL; - if (cookie->expires > 0) { - strcat(tempstr, "; expires="); - dt = php_std_date(cookie->expires); - strcat(tempstr, dt); - efree(dt); - } - } - if (cookie->path && strlen(cookie->path)) { - strcat(tempstr, "; path="); - strcat(tempstr, cookie->path); - efree(cookie->path); - cookie->path=NULL; - } - if (cookie->domain && strlen(cookie->domain)) { - strcat(tempstr, "; domain="); - strcat(tempstr, cookie->domain); - efree(cookie->domain); - cookie->domain=NULL; - } - if (cookie->secure) { - strcat(tempstr, "; secure"); - } - table_add(((request_rec *) SG(server_context))->headers_out, "Set-Cookie", tempstr); - if (cookie->domain) efree(cookie->domain); - if (cookie->path) efree(cookie->path); - if (cookie->name) efree(cookie->name); - if (cookie->value) efree(cookie->value); - if (cookievalue) efree(cookievalue); - efree(cookie); - cookie = php_pop_cookie_list(); - efree(tempstr); - } - php_header_printed = 1; - header_called = 1; - send_http_header(((request_rec *) SG(server_context))); - if (((request_rec *) SG(server_context))->header_only) { - set_header_request(1); - PG(header_is_being_sent) = 0; - return(0); - } - } -#else - if (php_print_header && !php_header_printed) { - if (!cont_type) { -#if USE_SAPI - sapi_rqst->header(sapi_rqst->scid,"Content-type: text/html\015\012\015\012"); -#else - PUTS_H("Content-type: text/html\015\012\015\012"); -#endif - } else { -#if 0 /*WIN32|WINNT / *M$ does us again*/ - if (!strcmp(cont_type,"text/html")){ -#endif -#if USE_SAPI - tempstr=emalloc(strlen(cont_type)+18); - sprintf(tempstr,"Content-type: %s\015\012\015\012",cont_type); - sapi_rqst->header(sapi_rqst->scid,tempstr); - efree(tempstr); -#else - PUTS_H("Content-type:"); - PUTS_H(cont_type); - PUTS_H("\015\012\015\012"); -#endif - efree(cont_type); -#if 0 /*WIN32|WINNT / *M$ does us again*/ - } else { - PUTS_H("\015\012"); - }/*end excluding output of text/html*/ -#endif - } -#if USE_SAPI - sapi_rqst->flush(sapi_rqst->scid); -#else - fflush(stdout); -#endif - php_header_printed = 1; - header_called = 1; - } -#endif - PG(header_is_being_sent) = 0; - return(1); -} -#else PHPAPI int php_header() { SLS_FETCH(); @@ -370,8 +213,6 @@ return 1; /* allow output */ } } -#endif - void php_push_cookie_list(char *name, char *value, time_t expires, char *path, char *domain, int secure) Index: php4/ext/standard/output.c diff -u php4/ext/standard/output.c:1.10 php4/ext/standard/output.c:1.11 --- php4/ext/standard/output.c:1.10 Fri Dec 31 17:31:52 1999 +++ php4/ext/standard/output.c Thu Jan 13 09:37:20 2000 @@ -37,13 +37,7 @@ #endif static inline void php_ob_send(void); -void php_start_ob_buffering(void); -void php_end_ob_buffering(int send_buffer); -int php_ob_get_buffer(pval *p); -/* HEAD support */ -void set_header_request(int value); - typedef struct { int (*php_body_write)(const char *str, uint str_length); /* string output */ int (*php_header_write)(const char *str, uint str_length); /* unbuffer string output */ @@ -51,6 +45,7 @@ uint ob_size; uint ob_block_size; uint ob_text_length; + unsigned char implicit_flush; } php_output_globals; #ifdef ZTS @@ -82,13 +77,14 @@ OG(ob_size) = 0; OG(ob_block_size) = 0; OG(ob_text_length) = 0; + OG(implicit_flush) = 0; } PHP_GINIT_FUNCTION(output) { #ifdef ZTS - output_globals_id = ts_allocate_id(sizeof(php_output_globals), NULL, NULL); + output_globals_id = ts_allocate_id(sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL); #else php_output_init_globals(OLS_C); #endif @@ -186,6 +182,18 @@ } +PHPAPI void php_start_implicit_flush() +{ + php_end_ob_buffering(1); /* Switch out of output buffering if we're in it */ + +} + + +PHPAPI void php_end_implicit_flush() +{ +} + + /* * Output buffering - implementation */ @@ -321,6 +329,7 @@ free(newstr); } + return result; } @@ -347,10 +356,6 @@ * HEAD support */ -void set_header_request(int value) -{ - /* deprecated */ -} PHP_FUNCTION(ob_start) { @@ -376,6 +381,27 @@ RETURN_FALSE; } } + + +PHP_FUNCTION(ob_implicit_flush) +{ + zval **zv_flag; + int flag; + + switch(ZEND_NUM_ARGS()) { + case 0: + flag = 1; + break; + case 1: + if (zend_get_parameters_ex(1, &zv_flag)==FAILURE) { + RETURN_FALSE; + } + convert_to_long_ex(zv_flag); + flag = (*zv_flag)->value.lval; + break; + } +} + /* Index: php4/ext/standard/php_output.h diff -u php4/ext/standard/php_output.h:1.3 php4/ext/standard/php_output.h:1.4 --- php4/ext/standard/php_output.h:1.3 Fri Dec 31 17:31:52 1999 +++ php4/ext/standard/php_output.h Thu Jan 13 09:37:20 2000 @@ -27,6 +27,10 @@ PHPAPI int php_header_write(const char *str, uint str_length); PHPAPI void php_start_ob_buffering(void); PHPAPI void php_end_ob_buffering(int send_buffer); +PHPAPI int php_ob_get_buffer(pval *p); +PHPAPI void php_start_implicit_flush(); +PHPAPI void php_end_implicit_flush(); + extern zend_module_entry output_module_entry; #define phpext_output_ptr &output_module_entry Index: php4/sapi/aolserver/aolserver.c diff -u php4/sapi/aolserver/aolserver.c:1.27 php4/sapi/aolserver/aolserver.c:1.28 --- php4/sapi/aolserver/aolserver.c:1.27 Wed Jan 5 11:25:18 2000 +++ php4/sapi/aolserver/aolserver.c Thu Jan 13 09:37:20 2000 @@ -22,7 +22,7 @@ * - CGI/1.1 conformance */ -/* $Id: aolserver.c,v 1.27 2000/01/05 19:25:18 sas Exp $ */ +/* $Id: aolserver.c,v 1.28 2000/01/13 17:37:20 zeev Exp $ */ /* conflict between PHP and AOLserver headers */ #define Debug php_Debug @@ -206,7 +206,7 @@ NSLS_FETCH(); PUTS("<table border=5 width=600>\n"); - php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.27 2000/01/05 19:25:18 sas Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.28 2000/01/13 17:37:20 zeev Exp $"); php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -297,6 +297,7 @@ php_module_shutdown_wrapper, /* shutdown */ php_ns_sapi_ub_write, /* unbuffered write */ + NULL, /* flush */ php_error, /* error handler */ Index: php4/sapi/apache/mod_php4.c diff -u php4/sapi/apache/mod_php4.c:1.11 php4/sapi/apache/mod_php4.c:1.12 --- php4/sapi/apache/mod_php4.c:1.11 Fri Dec 31 17:32:00 1999 +++ php4/sapi/apache/mod_php4.c Thu Jan 13 09:37:21 2000 @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php4.c,v 1.11 2000/01/01 01:32:00 sas Exp $ */ +/* $Id: mod_php4.c,v 1.12 2000/01/13 17:37:21 zeev Exp $ */ #include "zend.h" #include "php.h" @@ -124,7 +124,7 @@ } -static int zend_apache_ub_write(const char *str, uint str_length) +static int sapi_apache_ub_write(const char *str, uint str_length) { int ret; SLS_FETCH(); @@ -143,6 +143,17 @@ } + +static void sapi_apache_flush(void *server_context) +{ +#if MODULE_MAGIC_NUMBER > 19970110 + rflush((request_rec *) server_context); +#else + bflush((request_rec *) server_context->connection->client); +#endif +} + + int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC) { uint total_read_bytes=0, read_bytes; @@ -216,8 +227,10 @@ php_module_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ + + sapi_apache_ub_write, /* unbuffered write */ + sapi_apache_flush, /* flush */ - zend_apache_ub_write, /* unbuffered write */ php_error, /* error handler */ Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.14 php4/sapi/cgi/cgi_main.c:1.15 --- php4/sapi/cgi/cgi_main.c:1.14 Fri Dec 31 17:32:00 1999 +++ php4/sapi/cgi/cgi_main.c Thu Jan 13 09:37:21 2000 @@ -83,12 +83,18 @@ PHPAPI extern int optind; -static int zend_cgibin_ub_write(const char *str, uint str_length) +static int sapi_cgibin_ub_write(const char *str, uint str_length) { return fwrite(str, 1, str_length, stdout); } +static void sapi_cgibin_flush(void *server_context) +{ + fflush(stdout); +} + + static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_context) { if (sapi_header) { @@ -126,7 +132,8 @@ php_module_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ - zend_cgibin_ub_write, /* unbuffered write */ + sapi_cgibin_ub_write, /* unbuffered write */ + sapi_cgibin_flush, /* flush */ php_error, /* error handler */ Index: php4/sapi/isapi/php4isapi.c diff -u php4/sapi/isapi/php4isapi.c:1.10 php4/sapi/isapi/php4isapi.c:1.11 --- php4/sapi/isapi/php4isapi.c:1.10 Fri Dec 31 17:32:01 1999 +++ php4/sapi/isapi/php4isapi.c Thu Jan 13 09:37:21 2000 @@ -130,7 +130,7 @@ }; -static int zend_isapi_ub_write(const char *str, uint str_length) +static int sapi_isapi_ub_write(const char *str, uint str_length) { DWORD num_bytes = str_length; LPEXTENSION_CONTROL_BLOCK ecb; @@ -296,7 +296,8 @@ php_isapi_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ - zend_isapi_ub_write, /* unbuffered write */ + sapi_isapi_ub_write, /* unbuffered write */ + NULL, /* flush */ php_error, /* error handler */ Index: php4/sapi/phttpd/phttpd.c diff -u php4/sapi/phttpd/phttpd.c:1.5 php4/sapi/phttpd/phttpd.c:1.6 --- php4/sapi/phttpd/phttpd.c:1.5 Wed Jan 5 11:25:19 2000 +++ php4/sapi/phttpd/phttpd.c Thu Jan 13 09:37:22 2000 @@ -168,6 +168,7 @@ php_module_shutdown_wrapper, /* shutdown */ php_phttpd_sapi_ub_write, /* unbuffered write */ + NULL, /* flush */ php_error, /* error handler */ Index: php4/sapi/roxen/roxen.c diff -u php4/sapi/roxen/roxen.c:1.11 php4/sapi/roxen/roxen.c:1.12 --- php4/sapi/roxen/roxen.c:1.11 Fri Dec 31 17:32:02 1999 +++ php4/sapi/roxen/roxen.c Thu Jan 13 09:37:22 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: roxen.c,v 1.11 2000/01/01 01:32:02 sas Exp $ */ +/* $Id: roxen.c,v 1.12 2000/01/13 17:37:22 zeev Exp $ */ #include "php.h" #ifdef HAVE_ROXEN @@ -470,7 +470,7 @@ /* char buf[512]; */ PUTS("<table border=5 width=600>\n"); - php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.11 2000/01/01 01:32:02 sas Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.12 2000/01/13 17:37:22 zeev Exp $"); /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -519,15 +519,16 @@ "Roxen", php_module_startup, /* startup */ - pike_module_exit, /* shutdown */ + pike_module_exit, /* shutdown */ php_roxen_sapi_ub_write, /* unbuffered write */ + NULL, /* flush */ php_error, /* error handler */ - php_roxen_sapi_header_handler, /* header handler */ + php_roxen_sapi_header_handler, /* header handler */ php_roxen_sapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ + NULL, /* send header handler */ php_roxen_sapi_read_post, /* read POST data */ php_roxen_sapi_read_cookies, /* read Cookies */ Index: php4/sapi/servlet/servlet.c diff -u php4/sapi/servlet/servlet.c:1.9 php4/sapi/servlet/servlet.c:1.10 --- php4/sapi/servlet/servlet.c:1.9 Fri Dec 31 17:32:04 1999 +++ php4/sapi/servlet/servlet.c Thu Jan 13 09:37:23 2000 @@ -122,7 +122,7 @@ * sapi callbacks */ -static int zend_servlet_ub_write(const char *str, uint str_length) +static int sapi_servlet_ub_write(const char *str, uint str_length) { SLS_FETCH(); if (!SG(server_context)) { @@ -215,7 +215,8 @@ php_module_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ - zend_servlet_ub_write, /* unbuffered write */ + sapi_servlet_ub_write, /* unbuffered write */ + NULL, /* flush */ php_error, /* error handler */ Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.3 php4/sapi/thttpd/thttpd.c:1.4 --- php4/sapi/thttpd/thttpd.c:1.3 Fri Dec 31 17:32:05 1999 +++ php4/sapi/thttpd/thttpd.c Thu Jan 13 09:37:24 2000 @@ -108,6 +108,8 @@ php_module_shutdown_wrapper, sapi_thttpd_ub_write, + NULL, + php_error, NULL,

« previous php.version4 (#9112) next »