Hi Meir, you can set the reponse content and then use decoded_content. Something like this:
$response = $ua->request($request, $filename); undef $/; open(FH, "<$filename"); binmode(FH); $pageContent = <FH>; close (FH); $/ = "\n"; $response->content($pageContent); my $decoded_pagecontent = $response->decoded_content( raise_error => 1); Regards, Jesper On 14 April 2012 22:25, Meir Guttman <m...@guttman.co.il> wrote: > 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 > >