|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45234 Incorrect Content-Length header
Submitted: 2008-06-11 11:03 UTC Modified: 2008-10-27 05:23 UTC
From: kulakov74 at yandex dot ru Assigned:
Status: Closed Package: Zlib related
PHP Version: 5.2CVS-2008-06-11 (snap) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kulakov74 at yandex dot ru
New email:
PHP Version: OS:


 [2008-06-11 11:03 UTC] kulakov74 at yandex dot ru
Many pointed out to the problem that the Content-Length header may have incorrect value when using zlib.output_compression. This problem may have been fixed but not completely. When the compressed data fits within 8K Content-Length is sent by zlib after compression and hence the header (if present) is updated correctly, but when the compressed data is larger no Content-Length is sent by zlib and hence the value is not fixed. 8K is the default buffer size for zlib (mod_deflate) and is not configurable. Anyway, whatever the size of the buffer is, I think the initial Content-Length should be removed when zlib cannot determine the size of the compressed data in advance. 

The following bugs are related:

I guess many pages compress to more than 8K. 

Reproduce code:
header("Content-Length: ".filesize($FileToSend));

Expected result:
Content-Length header with the right value or removed. 

Actual result:
Content-Length header with the same value I set. Note that the file that is sent should COMPRESS to more than 8K in order for this to show. It may be 25K and the problem will not show up. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-23 12:29 UTC]
Please try using this CVS snapshot:
For Windows:

 [2008-10-23 13:07 UTC] kulakov74 at yandex dot ru
I'm very sorry, I cannot go into the trouble of installing PHP, all I could was check the bug with PHP 5.2.6 where it still was found. 

phpinfo() output this: 

This is not the latest release definitely. 
The test script I used was this: 

$Html=substr(ob_get_clean(), 0, 240000);
header("Content-Length: ".strlen($Html));

If the number 240000 is changed to 24000 the header is fine (changed from 24000 to some 5K value), and if it not the header is not correct (remains 240000).
 [2008-10-23 18:45 UTC] kulakov74 at yandex dot ru
The line "phpinfo() output this:" should be ignored.
 [2008-10-26 23:10 UTC]
Assumed fixed then.
 [2008-10-27 05:23 UTC] kulakov74 at yandex dot ru
Can't you check it yourself?! If you do then it is fixed.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 10:01:28 2024 UTC