diff options
| author | Stefan Roehrich <sr@php.net> | 2002-07-28 14:08:08 +0000 |
|---|---|---|
| committer | Stefan Roehrich <sr@php.net> | 2002-07-28 14:08:08 +0000 |
| commit | 6f786ebf3ed3c1e499231cab0cc99fd7faf8c0fb (patch) | |
| tree | 553b8c2f63aac7d6735969bfc94939a8b838065d /main/SAPI.c | |
| parent | 24b570dcacac21495ff7538836c1d723bb87f68b (diff) | |
| download | php-git-6f786ebf3ed3c1e499231cab0cc99fd7faf8c0fb.tar.gz | |
Commit patch as discussed on LinuxTag and posted to php-dev in June.
Disables zlib.output_compression for scripts with image/ content-type
header (fixes bug #16109) and makes it possible to switch
zlib.output_compression during script execution before the headers are
sent.
@- zlib.output_compression is disabled for "image/" content-type
@ headers and can be changed during script execution. (Stefan)
Diffstat (limited to 'main/SAPI.c')
| -rw-r--r-- | main/SAPI.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 8f53ff8539..af39e3bbdc 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -30,6 +30,10 @@ #if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE) #include "ext/pcre/php_pcre.h" #endif +#if HAVE_ZLIB +#include "ext/zlib/php_zlib.h" +ZEND_EXTERN_MODULE_GLOBALS(zlib) +#endif #ifdef ZTS #include "TSRM.h" #endif @@ -485,6 +489,11 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) if (!STRCASECMP(header_line, "Content-Type")) { char *ptr = colon_offset+1, *mimetype = NULL, *newheader; size_t len = header_line_len - (ptr - header_line), newlen; +#if HAVE_ZLIB + if(strncmp(ptr, "image/", sizeof("image/"))) { + ZLIBG(output_compression) = 0; + } +#endif while (*ptr == ' ' && *ptr != '\0') { ptr++; } @@ -633,6 +642,31 @@ SAPI_API int sapi_send_headers(TSRMLS_D) return SUCCESS; } +#if HAVE_ZLIB + /* Add output compression headers at this late stage in order to make + it possible to switch it off inside the script. */ + if (ZLIBG(output_compression)) { + switch (ZLIBG(ob_gzip_coding)) { + case CODING_GZIP: + if (sapi_add_header("Content-Encoding: gzip", sizeof("Content-Encoding: gzip") - 1, 1)==FAILURE) { + return FAILURE; + } + if (sapi_add_header("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1)==FAILURE) { + return FAILURE; + } + break; + case CODING_DEFLATE: + if (sapi_add_header("Content-Encoding: deflate", sizeof("Content-Encoding: deflate") - 1, 1)==FAILURE) { + return FAILURE; + } + if (sapi_add_header("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1)==FAILURE) { + return FAILURE; + } + break; + } + } +#endif + /* Success-oriented. We set headers_sent to 1 here to avoid an infinite loop * in case of an error situation. */ |
