From: ob dot php at daevel dot net
Operating system: Debian Etch
PHP version: 5.2.3
PHP Bug Type: HTTP related
Bug description: Contents after "zlib.output_compression" and a 304 page
Description:
------------
Hello,
when zlib.output_compression is enabled and the script stop without any
contents (case of a 304 page), after all PHP sends contents.
So, if the client use keep-alive, the next request could be "corrupted".
I use php as an Apache 2 module. I reproduced it under PHP 4.4.X too.
Note : if I disable "zlib.output_compression" and use "ob_start(
'gz_handler' )" there is not this problem.
Reproduce code:
---------------
A minimal 304 page :
<?php
header( 'Date: '.gmdate('D, d M Y H:i:s').' GMT' );
header( 'Not Modified', true, 304 );
exit;
?>
A minimal client simulation :
<?php
$sk = fsockopen( 'your-domain.tld', 80 );
$headers = array(
'GET /test_304.php HTTP/1.1',
'Host: your-domain.tld',
'Accept-Encoding: gzip,deflate',
'Keep-Alive: 300',
'Connection: keep-alive',
'If-Modified-Since: Tue, 21 Aug 2007 13:00:54 GMT',
);
function sock_send( &$sk, $line )
{
echo '> ', $line, PHP_EOL;
fputs( $sk, $line . "\r\n" );
}
function sock_gets( &$sk )
{
$line = fgets( $sk, 4096 );
echo '< ', rtrim($line), PHP_EOL;
return $line;
}
for( $i = 1; $i <=2 ; $i++ )
{
echo "Sending request ", $i, PHP_EOL;
foreach( $headers as $h )
sock_send( $sk, $h );
sock_send( $sk, '' );
echo "Reading headers only (no contents should be send)", PHP_EOL;
while( !feof( $sk ) )
{
$line = trim(sock_gets( $sk ));
if( $line === '' )
{
break;
}
}
}
fclose( $sk );
?>
Expected result:
----------------
Response headers for the second request should be the same as the first.
In my example :
< HTTP/1.1 304 Not Modified
< Date: Tue, 21 Aug 2007 14:45:40 GMT
< Server: Apache/2.2.3 (Debian) PHP/4.4.4-8+etch4
< Connection: Keep-Alive
< Keep-Alive: timeout=60, max=100
< Vary: Accept-Encoding
Actual result:
--------------
Actually there is some "chars" (I suppose the end of compressed data, like
checksum ?)
< ▼ ♥☻ ♥ HTTP/1.1 304 Not
Modified
< Date: Tue, 21 Aug 2007 14:45:40 GMT
< Server: Apache/2.2.3 (Debian) PHP/4.4.4-8+etch4
< Connection: Keep-Alive
< Keep-Alive: timeout=60, max=99
< Vary: Accept-Encoding
<
--
Edit bug report at http://bugs.php.net/?id=42362&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42362&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42362&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42362&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42362&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42362&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42362&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42362&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42362&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42362&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42362&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42362&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42362&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42362&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42362&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42362&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42362&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42362&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42362&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42362&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42362&r=mysqlcfg