Re: Send binary files with gzip encoding disabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 4, 2007 9:56 am, strawks wrote:
>     $filesize=filesize($path);
>     $mimetype='application/zip';
>
>     // Make sure there's not anything else left
>     ob_clean_all();
>
>     // Start sending headers
>     header("Pragma: public"); // required
>     header("Expires: 0");
>     header("Cache-Control: must-revalidate, post-check=0,
> pre-check=0");
>     header("Cache-Control: private",false); // required for certain
> browsers
>     header("Content-Transfer-Encoding: binary");
>     header("Content-Description: File Transfer");
>     header("Content-Type: ".$mimetype);
>     header("Content-Disposition: attachment; filename=\"".$name."\";"
> );
>     header("Content-Length: ".$filesize);

All these headers scare me -- I've found that if you add all these,
sooner or later, you run into some browser that didn't do it right
anyway.

You may want to look at an alternative K.I.S.S. approach (rant):
http://richardlynch.blogspot.com
YMMV

> The problem is that Apache process the output throught gzip and so
> drop the Content-Length header replacing it with a chunked transfer.
> This should work fine but Internet Explorer simply save the raw gzip
> compressed data instead of the ZIP archive. However this works fine
> with Firefox.
>
> gzip encoding is unecessary since I'm transfering a ZIP archive, so I
> think just disabling it should solve the problem, but I haven't found
> how to do this.

There was a discussion yesterday on php-internals regarding Apache/PHP
forcing the HTTP response to 1.1 even if the browser asked for 1.0.

Part of that discussion was a sub-discussion about how it ought to be
possible for a PHP developer to FORCE the response to be 1.0

If your response is 1.0, there would be no chunking, as I understand it.

So there may be an "answer" for you buried in that thread, or you may
want to weigh in on a real-world need for this feature.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux