L
Leif Wessman
Hi!
If I send the following to in my request
$req->header('Accept-encoding', 'gzip, deflate');
And then the Content-Encoding header in the response is 'gzip' or
'deflate'. How can I uncompress the content? I've tried the following,
but $data becomes empty:
my $data = $response->content;
my $encoding = $response->header('Content-Encoding');
if ($encoding) {
if ($encoding =~ /gzip/i) {
$data = Compress::Zlib::memGunzip($data);
}
if ($encoding =~ /deflate/i) {
my $x = deflateInit() or die "Cannot create a deflation stream\n" ;
my ($output, $status) = $x->deflate($data) ;
$status == Z_OK or die "deflation failed\n" ;
$data = $output;
($output, $status) = $x->flush() ;
$status == Z_OK or die "deflation failed\n" ;
$data .= $output;
}
}
If I send the following to in my request
$req->header('Accept-encoding', 'gzip, deflate');
And then the Content-Encoding header in the response is 'gzip' or
'deflate'. How can I uncompress the content? I've tried the following,
but $data becomes empty:
my $data = $response->content;
my $encoding = $response->header('Content-Encoding');
if ($encoding) {
if ($encoding =~ /gzip/i) {
$data = Compress::Zlib::memGunzip($data);
}
if ($encoding =~ /deflate/i) {
my $x = deflateInit() or die "Cannot create a deflation stream\n" ;
my ($output, $status) = $x->deflate($data) ;
$status == Z_OK or die "deflation failed\n" ;
$data = $output;
($output, $status) = $x->flush() ;
$status == Z_OK or die "deflation failed\n" ;
$data .= $output;
}
}