Subject: | Invalid Content-Encoding headers not gracefully handled |
Date: | Wed, 4 Jun 2008 17:36:39 +0100 |
To: | bug-test-www-mechanize-catalyst [...] rt.cpan.org |
From: | "Edmund von der Burg" <evdb [...] ecclestoad.co.uk> |
Hello,
If a request has a bad Content-Encoding value the
HTTP::Response->decoded_content will return undef. This is confusing
and unexpected as it causes tests like $mech->content_contains(...) to
fail.
Granted - the encoding type is wrong - but that should be reported as
a different failure.
I'd suggest changing the code from:
$response->content( $response->decoded_content );
to:
if ( my $decoded_content = $response->decoded_content ) {
$response->content($decoded_content);
} else {
diag "no decoded_content - check that your Content-Encoding header
is valid";
}
It is annoying that Test::WWW::Mechanize does not use decoded_content
- perhaps that should be fixed upstream?
Cheers,
Edmund.
To test use: $c->res->content_encoding('duff');
--
evdb@ecclestoad.co.uk - http://ecclestoad.co.uk