diff options
author | Zeev Suraski <zeev@php.net> | 2000-01-13 17:37:25 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2000-01-13 17:37:25 +0000 |
commit | 972631be7105a3120a405dc0d25c2dbb7179cd13 (patch) | |
tree | fce49aae99b6b0f3f2cd2f80a9a5580ff495fa6b /ext/standard/head.c | |
parent | c658fc5cbdede7c8d11c7bf7eb84b342ae34c2e3 (diff) | |
download | php-git-972631be7105a3120a405dc0d25c2dbb7179cd13.tar.gz |
- 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)
Diffstat (limited to 'ext/standard/head.c')
-rw-r--r-- | ext/standard/head.c | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/ext/standard/head.c b/ext/standard/head.c index 2fa708eda5..a6b973cec6 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -203,163 +203,6 @@ PHP_FUNCTION(Header) } - - - -#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 @@ PHPAPI int php_header() return 1; /* allow output */ } } -#endif - void php_push_cookie_list(char *name, char *value, time_t expires, char *path, char *domain, int secure) |