Subject: | mirror() should decode content and accept headers arguments |
Simple script to show the result when trying to mirror a file which is
content-encoded. The file isn't decoded, so instead of the html file
that was requested, a gzipped version is instead saved to the file. The
only way to get the expected behavior is to unset accept_encoding, but
because mirror doesn't accept headers as arguments, one must first save
the existing value, set it globbaly to undef via the default_headers,
make the request, then restore the original value.
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
$ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable());
$ua->mirror('http://www.yahoo.com/', '/tmp/yahoo.html');