Reputation: 283355
In PHP you can open a gzipped resource either like this:
$fp = fopen('compress.zlib://http://httpbin.org/gzip','rb')
or
$fp = gzopen('http://httpbin.org/gzip','rb')
How can I open a deflated resource? (such as http://httpbin.org/deflate)
N.B. I do not want to read the entire stream into memory so that I can run gzinflate
on it.
Upvotes: 1
Views: 151
Reputation: 32402
You can use stream_filter_append
to apply an inflation filter on read.
$fp = fopen('http://httpbin.org/deflate','rb');
$params = array('level' => 6, 'window' => 15, 'memory' => 9);
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ, $params);
print fread($fp,8192);
Upvotes: 1