ID:               25175
 Updated by:       [EMAIL PROTECTED]
 Reported By:      phpbug at paypc dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Output Control
 Operating System: Linux 2.4
 PHP Version:      4.3.2
 New Comment:

try this script:

<?php ob_start(); ?>
foo
<?php

header("Connection-Type: Keep-Alive");
header('Content-Length: ' . ob_get_length());
ob_end_flush();
echo ob_get_length();

?>

And access it with this command:

# lynx -head lynx -dump -head http://localhost/test.php

I get this (correct) output:

HTTP/1.1 200 OK
Date: Thu, 21 Aug 2003 03:52:44 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.3RC5-dev
X-Powered-By: PHP/4.3.3RC5-dev
Connection-Type: Keep-Alive
Content-Length: 4
Connection: close
Content-Type: text/html




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

[2003-08-20 22:33:34] phpbug at paypc dot com

One last thing... this bug report isn't just a pedantic exercise.

When I have that defective Content-Length header in the headers, IE
5.00.3700.1000 SP4 under Windows 2000 Profession SP4 "hangs" for a few
seconds during a pageview when that header is present.  When I comment
out the Content-Length header invocation, this problem goes away.  NO
INTERVENINIG PROXIES ARE INVOLVED - as it's a local intranet without
even an intevening router in between the two machines.

I am to understand that HTTP pipelining and keep-alive support is
dramatically assisted by the presence of this header.  I would like to
make use of it.

I am going to sprinkle my preamble+postamble across a wider mixture of
PHP pages on my system (some with DB content and some without) to see
if I can find common modes of failure.

If any Zend/PHP devs can suggest a more surgical strike, I'd sincerely
appreciate it.

=Apollyon=

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

[2003-08-20 20:45:00] phpbug at paypc dot com

Furthermore, when I removed the Keep-Alive header, nothing changes.

IN FACT, my preamble file is now:

header.inc:
------------------------------
<?php
$start_time=gettimeofday();
ob_start();
?>
------------------------------

footer.inc:
------------------------------
<?php
header('Content-Length: ' . ob_get_length());
ob_end_flush();
?>
---------------------------------

The headers output from a page:

HTTP/1.1 200 OK
Date: Thu, 21 Aug 2003 01:36:53 GMT
Server: Apache/1.3.27 Ben-SSL/1.48
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=2989258979bd07405999448563ef4bfc; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Content-Length: 2809
Content-Type: text/html
------------------------------

The real content length is 2890 bytes.

I make use of the following PEAR libraries:

HTML_Quickform, ADODB session management, and Log (when enabled).  I
make use of mySQL and ctype() functions throughout my application.  I
utilise a "user-supplied session function"  for PHP to make use of
ADODB as opposed to using the built-in default session handler.

=Apollyon=

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

[2003-08-20 20:34:39] phpbug at paypc dot com

Testing with that script fragment (as the entire web-page), I get the
following for output:
------------ SNIP -------------
HTTP/1.1 200 OK^M
Date: Thu, 21 Aug 2003 01:28:13 GMT^M
Server: Apache/1.3.27 Ben-SSL/1.48^M
Connection-Type: Keep-Alive^M
Content-Length: 0^M
Content-Type: text/html^M
^M
------------ SNIP -------------

I assume this is correct.  I displayed the CR's (I'm on UNIX).

Apache 1.3.x doesn't support HTTP/1.1 style connections?  

In Apache 1.1 and 1.2 documentation, I see:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Enabling Keep-Alive Support
Apache 1.1 comes with Keep-Alive support on by default, however there
are some directives you can use to modify Apache's behavior:

Note: Apache 1.2 uses a different syntax for the KeepAlive directive.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<

I am *NOT* using PHP built as a CGI SAPI - it's a statically linked
MODULE built into Apache-SSL.

=Apollyon=

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

[2003-08-20 10:32:07] [EMAIL PROTECTED]

What if eliminating the following line?

header("Connection-Type: Keep-Alive");

Note that HTTP/1.1 style connection is not supported in either Apache 1
or CGI SAPI.

And also try to generate a null output and see how it'll work:

<?php
header("Connection-Type: Keep-Alive");
header('Content-Length: 0');
?>

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

[2003-08-20 07:05:31] phpbug at paypc dot com

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 this bug report at http://bugs.php.net/?id=25175&edit=1

Reply via email to