Monks,
I have a problem. I am using LWP to obtain an HTML page from a remote server, I need to be able to display the content as it arrives so I provide a callback CODE ref to LWP::UserAgent->get(). I am also bandwidth-limited, so I request that the remote server gzips its response.
Example callback sub:
sub HttpContentCallback { my($data,$response,$protocol) = @_; print $data; }
The data comes in one chunk at a time. How do I decompress this data one chunk at a time? I have looked at Compress::Zlib and IO::Uncompress::Gunzip and neither of these seem to do what I want. I tried passing a scalar ref to IO::Uncompress::Gunzip's constructor and on each callback appending the received data to this scalar before calling $gz->read($buffer), but this doesn't work (it tries to read the whole scalar then moans about unexpected end of stream). It also attempts to read the scalar on instantiation meaning I have to defer that until I actually have some data, which is pretty inconvenient.
Surely someone must have managed this before me! Looking forward to any assistance you can provide :)
In reply to uncompress gzip data in a callback by Weevil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |