php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32424 no output is sent after calling ob_flush() after sending headers
Submitted: 2005-03-23 10:34 UTC Modified: 2006-01-01 01:00 UTC
Votes:4
Avg. Score:3.2 ± 0.4
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: tommythekid at mac dot com Assigned: thetaphi (profile)
Status: No Feedback Package: iPlanet related
PHP Version: 5.*, 4.* OS: Solaris 9 SPARC
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tommythekid at mac dot com
New email:
PHP Version: OS:

 

 [2005-03-23 10:34 UTC] tommythekid at mac dot com
Description:
------------
no output is sent after calling ob_flush() after sending headers. This problem appears to be NSAPI related. Removing the first ob_flush() from the code produces the expected results.

Reproduce code:
---------------
while (ob_end_clean());

ob_start();

header("X-Foo: BAR");

ob_flush();
flush();


echo "PRE\n\n";


ob_flush();
flush();

echo "POST\n\n";


ob_flush();
flush();

Expected result:
----------------
HTTP/1.1 200 OK
Server: Sun-ONE-Web-Server/6.1
Date: Wed, 23 Mar 2005 09:31:45 GMT
Content-type: text/html
X-powered-by: PHP/5.0.3
X-foo: BAR
Connection: close

PRE

POST



Actual result:
--------------
HTTP/1.1 200 OK
Server: Sun-ONE-Web-Server/6.1
Date: Wed, 23 Mar 2005 09:24:38 GMT
Content-type: text/html
X-powered-by: PHP/5.0.3
X-foo: BAR
Connection: close


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-25 16:59 UTC] thetaphi@php.net
Hallo Jani,
I experienced that problem also in my servers in the past (in some other use-case: using of the nsapi_virtual() function which does implicitly a flush of the headers and buffers in the nsapi C code) but I do not know exactly if it is a nsapi problem or some general sapi/buffers problem.

What did you change? If it has something to do with NSAPI code please send me a private email with your changes, because I am not familar with the buffering code.

The interesting thing is:
This bug only happens when the flush/ob_flush is done before any output to the client is done (the buffer is empty). In my case: nsapi_virtual() is the first instruction in the php code.
Happens also in PHP 4.3.
If I should look after this bug after easter assign me to this bug.
 [2005-06-24 13:25 UTC] thetaphi@php.net
I analyzed this bug and found out what the problem is:
In a normal response stage the following functions of the SAPI module are called:
* n times header_handler()
* one time send_headers() before the first call of ub_write()

In the case of this bug the following happens:
if you do not have any output before ob_flush() (no echo etc.) the send_headers() SAPI function is never called. In NSAPI this leads to the fact that an webserver function to start the response is never called. Further writes to ub_write will then result in loss of data.
I think somewhere in SAPI.c the call to send_headers() is missing before ob_flush() when nothing was send before.

A fix only for NSAPI would be to trigger the calls and before write anything with ub_write a check is done and the start_response is added. But this is not the right solution.
 [2005-12-24 02:38 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-01-01 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 05:01:31 2024 UTC