}
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) &&
--- /dev/null
+--TEST--\r
+Req #44164 (Handle "Content-Length" HTTP header when zlib.output_compression active)\r
+--SKIPIF--\r
+<?php\r
+if (!function_exists('gzdeflate'))\r
+ die("skip zlib extension required");\r
+?>\r
+--INI--\r
+zlib.output_compression=On\r
+--ENV--\r
+HTTP_ACCEPT_ENCODING=gzip\r
+--FILE--\r
+<?php\r
+header("Content-length: 200");\r
+echo str_repeat("a", 200);\r
+--EXPECT--\r
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r