#44725 [Opn->Bgs]: more byte output in flush function

From: Date: Thu, 12 Jun 2008 13:33:03 +0000
Subject: #44725 [Opn->Bgs]: more byte output in flush function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-125716@lists.php.net to get a copy of this message
 ID:               44725
 Updated by:       mgf@php.net
 Reported By:      hack988 at gamil dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Apache2 related
 Operating System: CentOS release 5
 PHP Version:      5.2.6RC5
 New Comment:

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/


Previous Comments:
------------------------------------------------------------------------

[2008-06-12 11:09:01] 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 10:31:06] 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-04-14 18:27:46] 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.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44725&edit=1



Thread (4 messages)

« previous php.bugs (#125716) next »