|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2013-06-24 21:08 UTC] preinheimer@php.net
 Description:
------------
Hi,
Consider the test script. 
One might expect to see: Content-Encoding: gzip in the response headers, but it's not there. If however you comment out that flush() compression is applied. 
As a small amount of background, I work on two tools that help display data from the xhprof extension. They both include flush(); ignore_user_abort(); before doing work to store the profiling information in attempt to have as little impact on the user as possible. Clearly flush() wasn't the safe command I thought it was, as it's having a large affect on the application I'm profiling. 
I'm prepared to write this up in the documentation, but I don't really think this is expected behavior. 
Test script:
---------------
<?php
ob_start('ob_gzhandler');
phpinfo();
flush();
Expected result:
----------------
output compressed
Actual result:
--------------
no compression
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 15:00:01 2025 UTC | 
So if I run: <?php ob_start('ob_gzhandler'); phpinfo(); ob_flush(); phpinfo(); flush(); With something like: curl -H "Accept-Encoding: gzip, deflate" http://test.local/obtest.php It looks (to me) like the entire output is compressed. The difference in behavior seems, well, necessary to allow the end agent to actually be able to read the output. But confusing from a "different output depending on what happened earlier" standpoint.