HTTP gzip-compression and fopen
| From: | Trond Arve Nordheim | Date: | Wed, 17 Apr 2002 23:55:47 +0000 |
| Subject: | HTTP gzip-compression and fopen | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-93444@lists.php.net to get a copy of this message | ||
Hi.
I was writing a slashdot RSS-parser for my homepage, and wrote a simple
function to fetch the slashdot.rdf-file from slashdot, and parse it
using PEAR's XML/RSS.php.
Here's the core reading the remote file:
$fp = @fopen("http://slashdot.org/slashdot.rdf",
"r");
if (!$fp) { return 0; }
$raw = fread($fp, 10000);
fclose($fp);
Now, it seems like slashdot is doing som on-the-fly gzip-compression (it
sends a "Content-Encoding: gzip"-header), and that fopen can't cope with
this, and I'm stuck with some binary data. I've tried using
gzuncompress() on the returned data, but that resulted in an error (not
valid gzip-data).
First of all; shouldn't perhaps fopen support decompression of
gzip-compressed http data? That is, is there any reason why it's not
supported ? ;)
Second; how do I decompress that data? I've been reading the manual and
doing some google-searches, but I can't seem to find an answer anywhere.
--
Trond Arve Nordheim
- "This message is ROT13-encrypted twice for extra security."