develooper Front page | perl.libwww | Postings from April 2012

How to deflate a ':content_file' response saved to a file

Thread Next
From:
Meir Guttman
Date:
April 14, 2012 13:25
Subject:
How to deflate a ':content_file' response saved to a file
Message ID:
!&!AAAAAAAAAAAYAAAAAAAAAKC25OsDcMdGneFIQhy+Pc3CgAAAEAAAANKb1cm7KTdEiLapXDlXIGUBAAAAAA==@guttman.co.il
I would like to download gzip (or similarly encoded) HTML content. If I
keep the response in a variable, I can decode the contents using the
'decoded_content' method, as follows (Just extracted from a working
script, but not tested):

####################################
	use strict;
	use warnings;
	use base 'HTTP::Message';
	use LWP::UserAgent

	my $can_accept = HTTP::Message::decodable;

	my $ua = LWP::UserAgent->new;
	my $response = $ua->get($uri, 'Accept-Encoding' => $can_accept);
	print $response->decoded_content, "\n";
####################################

On the other hand, another variation of the 'get' method can save a
response to a file, as in:

	$ua->get($url, ':content_file' => $filename);

But I couldn't find a way to first deflate the contents that is
saved to file.

Can someone point me to the right part of the LWP package?

Thanks,
Meir


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About