php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44725 more byte output in flush function
Submitted: 2008-04-14 18:27 UTC Modified: 2008-06-12 13:33 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: hack988 at gamil dot com Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 5.2.6RC5 OS: CentOS release 5
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: hack988 at gamil dot com
New email:
PHP Version: OS:

 

 [2008-04-14 18:27 UTC] hack988 at gamil dot com
Description:
------------
flush function output for html body in some times.it disappear at begin and end of html body.

exsample code:
<?php
define('XML_RPC', TRUE);
$XMLRPCVersion="1.0";
flush();
exit;

....more code
?>
it display:
0

<?php
define('XML_RPC', TRUE);
$XMLRPCVersion="1.0";
ob_flush();
exit;

....more code
?>
it display nothing

compare with to http headers i found that:

"Content-Length: 0"
exist when use ob_flush but not exist in flush
so i add this in my php codes like this
<?php
define('XML_RPC', TRUE);
$XMLRPCVersion="1.0";
header("Content-Length: 0");
flush();
exit;

....more code
?>
now all thing is work will!
i download php source code an compare flush with ob_flush.
in ob_flush:

	if (send_buffer) {
		if (just_flush) { /* if flush is called prior to proper end, ensure presence of NUL */
			final_buffer[final_buffer_length] = '\0';
		}
		OG(php_body_write)(final_buffer, final_buffer_length TSRMLS_CC);
	} 

in flush:
	if (sapi_module.flush) {
		sapi_module.flush(SG(server_context));
		return SUCCESS;
	} else {
		return FAILURE;
	}

i can't understand well with this codes but i think maybe some buffer is not zeromemory befor used.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-12 10:31 UTC] vesselin dot atanasov at gmail dot com
I can confirm that flush outputs superfluous characters. Actually I can reproduce it with a much simpler script:

<?php
flush ();
?>

In my case I too get a superfluous "0" (without the double quotes).
 [2008-06-12 11:09 UTC] vesselin dot atanasov at gmail dot com
Actually for text block being output with a print statement it prepends the length of the text block as a hex string followed with a CRLF. So the following script:

------------------------------
<?php
echo "zzzzzzzzzzzzzz";
flush ();
echo "qqq"
?>
------------------------------

will output:
------------------------------
e
zzzzzzzzzzzzzz
3
qqq
0

------------------------------
 [2008-06-12 13:33 UTC] mgf@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

That's chunked encoding. Read about it on this page: http://httpwatch.com/httpgallery/chunked/
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 03:01:28 2024 UTC