Join GitHub today
read from a gzip'ed input file #11
the readme mentioned "read from a gzip'ed input file", do you have any example how the code look like for it?
I would like to read a GZIPPED resource via url in my stream.
with the regular php filter functions one often gets a "stream_filter_append(): Filter failed to process pre-buffered data" error, because the inflate filter cannot work the the additional gzip header.
If this lib is aimed for ease of use, I would expect that it bundles a mechanism which allows to read gzipped content.
Atm I am using
$url = 'http://localhost/dev/fileget_zlib/packages.json'; $fp = fopen($url, 'r', null, $ctx); Filter\append($fp, 'zlib.inflate'); echo stream_get_contents($fp);
which triggers a exception:
thanks for the great lib.
Thanks for the good question @staabm!
As such, using this library doesn't really help much as this can be achieved via PHP's built-in zlib filters:
stream_filter_append($fp, 'zlib.deflate', array('window' => 15|16));
I understand where you're coming from, the README could certainly use a better wording. The referenced text from the README was meant to be an example of what can be achieved via PHP's stream filters, not necessarily what this library can help with.
The zlib filter is one of many available filters and as such this library does not provide any special support for it. Admittedly, one of the key motivations for building this library was exposing the zlib filter. For this reason, I've also built https://github.com/clue/php-zlib-react on top of this library, so perhaps this may help?
If you feel like updating the README to make this information more obvious, I'd be happy to get this in
I hope this helps!