#25175 [Opn]: ob_get_length() returns incorrect value
| From: | phpbug at paypc dot com | Date: | Thu, 21 Aug 2003 09:33:51 +0000 |
| Subject: | #25175 [Opn]: ob_get_length() returns incorrect value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-46406@lists.php.net to get a copy of this message | ||
ID: 25175
User updated by: phpbug at paypc dot com
Reported By: phpbug at paypc dot com
Status: Open
Bug Type: Output Control
Operating System: Linux 2.4
PHP Version: 4.3.2
New Comment:
*ARGH* I hate "thinkoes" -- it should be obvious from context (and
perusing my phpconfig) that I've TURNED OFF enable_trans_sid, not
turned it on.
Upon re-reading my posting (naturally AFTER I'd hit submit), I noted
the think-o.
My apologies.
=Apollyon=
Previous Comments:
------------------------------------------------------------------------
[2003-08-21 04:31:10] phpbug at paypc dot com
OK, let me put forth some declarations so we're talking apples and
apples.
My test method:
echo -e "GET /legal/tester.php HTTP/1.1\r\nHost: 127.0.0.1\r\n" | nc
127.0.0.1 80 > dump
I wish to eliminate any possible "post-processing" or
browser-variations.
IE: "nc" is netcat, a commonly available network tool.
OK, onto the results of my tests.
I copied and pasted sniper's code *EXACTLY* as presented, with
whitespaces and line spacing as entered. I obtained identical results
with both lynx and my netcat method, though lynx probably doesn't
support HTTP/1.1 because there was an additional header.
With Lynx Version 2.8.3rel.1:
HTTP/1.1 200 OK
Date: Thu, 21 Aug 2003 09:10:16 GMT
Server: Apache/1.3.27 Ben-SSL/1.48
Connection-Type: Keep-Alive
Content-Length: 4
Connection: close <<<<<<<<<<<<< Additional header
Content-Type: text/html
With netcat:
HTTP/1.1 200 OK
Date: Thu, 21 Aug 2003 09:10:55 GMT
Server: Apache/1.3.27 Ben-SSL/1.48
Connection-Type: Keep-Alive
Content-Length: 4
Content-Type: text/html
In comparing the actual bytes sent over the wire against the advertised
content-length, the Content-Length header is correct.
If you wish to inspect my PHP build and setup configuration, you may do
so at: <http://hollywood.paypc.com/config4phpbugmasters>
(I will be removing this after 24 hours.)
And yes, it's pretty loaded. And yes, trans_sid is enabled, but in all
of my test harnesses which employ sessions, I've enabled cookies - and
they are created/used by the browsers involved.
******* AHHHHHHAAAA *******
Arigatoo gozaimashita to Moriyoshi-san for cautioning me to turn on
trans_sid, because when I disable it in my global php.ini, the
discrepancy disappears!
For my "complex" web-application which formerly reported bad sizing, I
received the following header (after turning off trans_sid):
----------------------------
HTTP/1.1 200 OK
Date: Thu, 21 Aug 2003 09:20:47 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=a1c8bfb3f409580e57206d7c19eac473; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Content-Length: 2825
Content-Type: text/html
--------------------------------
And doing a wc -c on the content-portion matches this size exactly
(with my netcat test).
Third-party validation via usage of
<http://www.ircache.net/cgi-bin/cacheability.py>
confirms an exact
match of advertised Content-Length and what's actually received.
And lastly, and most importantly, the IE "hang" bug while accessing
this web application via an intranet is gone.
OK, fine, trans_sid broke it. Why? And should it have? I'm
suspicious that the Esteemed Moriyoshi-san nailed this specific setting
in advance, as if to suspect it being a potential cause for buggage.
Inquiring minds want to know - if it's by design, please add it to the
documentation and FAQ. I know alot of things about the ob_ functions
are unusual and cause some people hardship (of their own making). This
one came out of left field.
=Apollyon=
------------------------------------------------------------------------
[2003-08-21 00:10:00] moriyoshi@php.net
> Set-Cookie: PHPSESSID=2989258979bd07405999448563ef4bfc; path=/
Perhaps you seem to have enabled session.use_trans_sid.
If so, first turn it off before trying the above script provided by
sniper.
------------------------------------------------------------------------
[2003-08-20 22:54:00] sniper@php.net
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
------------------------------------------------------------------------
[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=
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/25175
--
Edit this bug report at http://bugs.php.net/?id=25175&edit=1