diff options
| author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-10-26 02:16:21 +0000 |
|---|---|---|
| committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-10-26 02:16:21 +0000 |
| commit | 1f191e4d2b41222834a3eda419dcc314a69dd2f4 (patch) | |
| tree | 611f54ab1a6e7fa56c10b041bc059195c74e9c95 | |
| parent | 18fa045e75cc596d401017397402e578bc6f7ec0 (diff) | |
| download | php-git-1f191e4d2b41222834a3eda419dcc314a69dd2f4.tar.gz | |
- Implemented request #44164, zlib.output_compression is now implicitly
disabled when the header "Content-length" is set.
#One could argue that any output handler could change the size of the
#response, so this exception for zlib.output_compression is an
#inconsistency. However, zlib.output_compression is presented as a
#performance setting, whose value should have no effect on the
#correctness of the scripts. This was not the case. Setting the
#header "content-length" and enabling zlib.output_compression was
#a recipe for infringing section 4.4 of RFC 2616.
| -rw-r--r-- | main/SAPI.c | 8 | ||||
| -rw-r--r-- | tests/basic/req44164.phpt | 17 |
2 files changed, 25 insertions, 0 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 31f2916c71..365f8f6cd9 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -706,6 +706,14 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) } efree(mimetype); SG(sapi_headers).send_default_content_type = 0; + } else if (!STRCASECMP(header_line, "Content-Length")) { + /* Script is setting Content-length. The script cannot reasonably + * know the size of the message body after compression, so it's best + * do disable compression altogether. This contributes to making scripts + * portable between setups that have and don't have zlib compression + * enabled globally. See req #44164 */ + zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), + "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } else if (!STRCASECMP(header_line, "Location")) { if ((SG(sapi_headers).http_response_code < 300 || SG(sapi_headers).http_response_code > 307) && diff --git a/tests/basic/req44164.phpt b/tests/basic/req44164.phpt new file mode 100644 index 0000000000..d0082861f2 --- /dev/null +++ b/tests/basic/req44164.phpt @@ -0,0 +1,17 @@ +--TEST--
+Req #44164 (Handle "Content-Length" HTTP header when zlib.output_compression active)
+--SKIPIF--
+<?php
+if (!function_exists('gzdeflate'))
+ die("skip zlib extension required");
+?>
+--INI--
+zlib.output_compression=On
+--ENV--
+HTTP_ACCEPT_ENCODING=gzip
+--FILE--
+<?php
+header("Content-length: 200");
+echo str_repeat("a", 200);
+--EXPECT--
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
