From:             phpbug at paypc dot com
Operating system: Linux 2.4
PHP version:      4.3.2
PHP Bug Type:     Output Control
Bug description:  ob_get_length() returns incorrect value

Description:
------------
Very straightforward.

I have a preamble and postamble include on ALL of my main .php pages...
which use ADODB session management, some PEAR, and other typical dynaweb
goodies.

The Content-Length header is *ALWAYS* off by about 81 bytes, as in, the
ob_get_length() is always smaller than the actual size of the content
sent...

I've verified this with "netcat" - after trimming the headers from the
reply, the content is 81 bytes larger than advertised in the
Content-Length header.

I observed no change in behaviour after adding the ob_clean() call into my
header file.

OTHERWISE, things work fine.

What's the deal?  Is Apache silently adding CRLF's?

I am NOT using the gzhandler or transparent compression here.  This is
just straightforward output.

=Lord Apollyon=


Reproduce code:
---------------
The code for all of my index.php's consist of the following:

<?PHP
include_once 'db_header.inc';
................
include_once 'db_footer.inc';
?>

db_header.inc:

<?php
$start_time=gettimeofday();
ob_clean();   // paranoid and desperate
ob_start();
header("Connection-Type: Keep-Alive");
?>

db_footer.inc contains:

<?PHP
if ($LOGGING) 
{
    $LOG->close();
        $LOGGING=FALSE;
}
header('Content-Length: ' . ob_get_length());
ob_end_flush();
?>

Note: there are no blank lines at the beginning of my *.inc or *.php
files.

Expected result:
----------------
I would expect Content-Length to reflect the actual output size.



-- 
Edit bug report at http://bugs.php.net/?id=25175&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25175&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25175&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25175&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25175&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25175&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25175&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25175&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25175&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25175&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25175&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25175&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25175&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25175&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25175&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25175&r=gnused

Reply via email to