|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2020-08-28 07:36 UTC] cmb@php.net
 
-Status:      Open
+Status:      Not a bug
-Assigned To:
+Assigned To: cmb
  [2020-08-28 07:36 UTC] cmb@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 23:00:01 2025 UTC | 
Description: ------------ When using ob_start with a custom calback ob_gzhandler tries resending headers and also generate a corrupted output. Both generates same headers with exception of: //Response Headers Keep-Alive: timeout=5, max=100 // Script with fine Output Keep-Alive: timeout=5, max=99 // Script with bad output //Request Headers Sec-Fetch-Site: none // Script with fine Output Sec-Fetch-Site: same-origin // Script with bad Output Test script: --------------- // Script with fine Output <?php header( 'Content-type: text/html; charset=utf-8' ); ob_start("ob_gzhandler"); echo 'Begin ...<br />'; for( $i = 0 ; $i < 5 ; $i++ ) { echo $i . '<br />'; ob_end_flush(); flush(); ob_flush(); ob_start("ob_gzhandler"); sleep(1); } echo 'End ...<br />'; // Script with bad Output <?php function ob_chunked_gzhandler($buffer, $phase) { //compression on $buffer = ob_gzhandler($buffer, $phase);//<--fourth line $length = strlen($buffer); return dechex($length) . "\r\n$buffer\r\n"; } header('Content-type: text/html; charset=utf-8'); ob_start("ob_chunked_gzhandler"); echo 'Begin ...<br />'; for ($i = 0; $i < 10; $i++) { echo $i . '<br />'; ob_end_flush(); flush(); ob_flush(); ob_start("ob_chunked_gzhandler"); sleep(1); } echo 'End ...<br />'; Expected result: ---------------- //Outputs fine: Begin ... 0 1 2 3 4 End ... Actual result: -------------- 55RW sJM��S��ӳI*Rз3�P���2 1b � 3�I*RзR�4) 1b � 3�I*Rзσ� 1b � 3�I*Rз{��� 1b � 3�I*Rз��{ 1b � 3�I*RзA�{� 1b � 3�I*Rзܧ�� 1b � 3�I*Rзh��J 1b � ��I*Rз�ܬ� 1b � ��I*Rз5�� 21 � s�KQ��ӳI*Rз��B //Error.log file [Thu Aug 27 11:53:48.261150 2020] [fcgid:warn] [pid 17632:tid 1148] [client ::1:6687] mod_fcgid: stderr: PHP Warning: Cannot modify header information - headers already sent by (output started at C:\\server\\lec\\var\\www\\output_custom.php:16) in C:\\server\\lec\\var\\www\\output_custom.php on line 4, referer: http://localhost/