FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » header() not being honored?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: header() not being honored? [message #174794 is a reply to message #174792] Sat, 09 July 2011 10:25 Go to previous messageGo to previous message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma:
Senior Member
Billy Mays <noway(at)nohow(dot)com> wrote:

> I am trying to have php output previously gzipped data, but it seems
> like php is ignoring the call altogether.
>
> Code:
>
> #######################################
> /* Trying to prevent the chunked encoding */
> header('Content-Length: ' . filesize($file) );
> header('Content-Encoding: gzip');
>
> readfile($file);
>
> echo "anything";
>
> die();
> ########################################
>
> It seems that the first call header get completely ignored (I watched
> the headers with telnet) and after the readfile() call the the echo is
> never used.
>
> Am I misunderstanding how to use the header function? Is there another
> way to see whats going on? Unfortunately, I'm in a shared hosting
> environment, PHP: 4.4.9

First you have to make sure the browser will accept the format you
intend to send. Look in its "accept-encoding" header field to find
out. Note that some browsers fib, I forget which ones, some old
microsoft crap as I recall.

Aside from that it oughtn't be a problem, I have a crappola site that
runs PHP 4.something and does it just fine, uses deflate or gzip and
smooshes a dynamically generated 50k page down into about 2k.

It could well be that PHP is checking accept-encoding and refusing
your content-encoding, or that something else is going on. But it's
definitely possible to send gzip'ed output under older versions of
PHP.

There are some decent writeups on the web about doing this kind of
thing, try keywords "zip page" and like that. As I recall there's an
apache mod that will do it for you (mod_gzip? don't remember), but I
tend to shy away from things of that sort, prefer being able to debug
code rather than ask questions about mods.

--
no aluminum siding offers today
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: about quality of SAP training videos
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 10:42:12 GMT 2024

Total time taken to generate the page: 0.03988 seconds