Re: Content-Length
| From: | Richard Lynch | Date: | Thu, 04 Jul 2002 22:45:03 +0000 |
| Subject: | Re: Content-Length | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105533@lists.php.net to get a copy of this message | ||
>I am currently having problems with a custom written
>web-authentication-proxy. The proxy works fine with standard html pages but
>not with php pages. After doing a bit of digging I have found that the
>proxy does a HEAD request and checks the Content-Length to see if the page
>if valid.
>
>I have been able to use
>
>Header( "Content-Length: 100" )
>
>to fool the proxy into loading the php page.
>
>My question is how do I go about calculating the correct Content-Length for
>each and every php page on my site.
>
>I have done some digging and presume I need to do "Output buffering" and
>calculate the strlen of the response the php returns, but how do I reference
>the result of a php page to get a strlen from it??
If I am reading
http://www.php.net/manual/en/function.ob-start.php
correctly, your answer is staring you in the face :-)
--------- file: buffer.inc ----------------------
<?php
# Untested code.
ob_start('send_content_length');
function send_content_length($text){
header("Content-length: " . strlen($text));
return $text;
}
?>
-------------------------------------------------
Auto-prepend that in php.ini and go have a beer. :-)
--
Like Music? http://l-i-e.com/artists.htm