#45234 [Fbk->Opn]: Incorrect Content-Length header

From: Date: Thu, 23 Oct 2008 13:07:44 +0000
Subject: #45234 [Fbk->Opn]: Incorrect Content-Length header
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-130005@lists.php.net to get a copy of this message
ID: 45234 User updated by: kulakov74 at yandex dot ru Reported By: kulakov74 at yandex dot ru -Status: Feedback +Status: Open Bug Type: Zlib Related Operating System: Linux PHP Version: 5.2CVS-2008-06-11 (snap) New Comment: 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). Previous Comments: ------------------------------------------------------------------------ [2008-10-23 12:29:03] 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-06-11 11:03:49] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45234&edit=1

« previous php.bugs (#130005) next »