php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kulakov74 at yandex dot ru
New email:
PHP Version: OS:

 

 [2008-06-11 11:03 UTC] kulakov74 at yandex dot ru
Description:
------------
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:
http://bugs.php.net/bug.php?id=28460
http://bugs.php.net/bug.php?id=22143
http://bugs.php.net/bug.php?id=24083

I guess many pages compress to more than 8K. 

Reproduce code:
---------------
$FileToSend="filename.txt";
header("Content-Length: ".filesize($FileToSend));
readfile($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. 



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-23 12:29 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [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: 

<?
ob_start();
phpinfo();
$Html=substr(ob_get_clean(), 0, 240000);
header("Content-Length: ".strlen($Html));
echo($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] jani@php.net
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 Dec 21 15:01:29 2024 UTC