|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27424 flush sets SG(headers_sent) to true preventing sapi_send_headers from running
Submitted: 2004-02-27 11:21 UTC Modified: 2004-03-07 22:08 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: scottmacvicar at ntlworld dot com Assigned:
Status: Closed Package: Apache2 related
PHP Version: 4CVS-2004-02-27 (stable) OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: scottmacvicar at ntlworld dot com
New email:
PHP Version: OS:


 [2004-02-27 11:21 UTC] scottmacvicar at ntlworld dot com
If you have zlib.output_compression = On in php.ini and echo some content then flush under apache 2 then you'll get some binary data due to the lack of headers.

I've had a look at the code and when you call flush() under Apache 2 it has

SG(headers_sent) = 1;
sapi_apache2.c line 265

During php_request_shutdown() sapi_send_headers is called to add appropriate gzip headers.

Within sapi_send_headers there is a check to see if headers have already been sent. SAPI.c line 701.

I've read previous bug reports on flush and Apache 2 in particular, bug #25701. Ilia mentions that Apache 2 and Apache 1 behave differently, on flush Apache 2 sends any pending headers but in this case the gzip headers haven't been added yet.

I can see two ways to handle this,
Disable zlib.output_compression if flush is called
Make flush do nothing if zlib.output_compression is enabled


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-07 22:08 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 23:01:30 2024 UTC