It is built into UserAgent and thus Mechanize. One main warning to save you some hair
-To debug, be sure to check the $@ error after calling decoded_content.
$html = $r->decoded_content; die $@ if $@ ;
Better yet, look at the source of HTTP :: Message and make sure all the support packages are there.
In my case, decoded_content returned undef while the content is raw binary, and I went wildly chasing the geese. The UserAgent will set the error flag when decoding fails, but Mechanize will simply ignore it (it does not check or register the incidence as its own error / warning).
In my case $@sez : "Unable to find IO / HTML.pm .. It was rated
After immersing myself in the source, I found that the built-in decoding process is long, thorough and complex, covering almost every scenario and creating a lot of guesswork (Thanks, Gisle!).
if you are paranoid, explicitly set the default header to be used with each request in new ()
$browser = new WWW::Mechanize('default_headers' => HTTP::Headers->new('Accept-Encoding' => scalar HTTP::Message::decodable()));
source share