Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ext/zlib/tests/bug44168.phpt
Binary file not shown.
4 changes: 4 additions & 0 deletions ext/zlib/zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,14 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o
if (SUCCESS == php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS, &flags TSRMLS_CC)) {
/* only run this once */
if (!(flags & PHP_OUTPUT_HANDLER_STARTED)) {
sapi_header_line cl_header = {ZEND_STRL("Content-Length"), 0};

if (SG(headers_sent) || !ZLIBG(output_compression)) {
deflateEnd(&ctx->Z);
return FAILURE;
}

sapi_header_op(SAPI_HEADER_DELETE, &cl_header);
switch (ZLIBG(compression_coding)) {
case PHP_ZLIB_ENCODING_GZIP:
sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1 TSRMLS_CC);
Expand Down
8 changes: 0 additions & 8 deletions main/SAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,14 +804,6 @@ 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) &&
Expand Down