|Subject:||decoded_content() of "bzip2"|
|Date:||Tue, 20 Sep 2011 08:13:52 +1000|
|To:||bug-HTTP-Message [...] rt.cpan.org|
|From:||Kevin Ryde <user42 [...] zip.com.au>|
The "lighttpd/1.4.19" server at xkcd.com seems to send back Content-Encoding: bzip2 rather than "x-bzip2", even when Accept-Encoding says x-bzip2. HTTP::Message 6.02 doesn't seem to be able to decode that. Sample program foo.pl below fetchesdecodable: gzip, x-gzip, deflate, x-bzip2 GET Accept-Encoding: gzip, x-gzip, deflate, x-bzip2 (no content) HTTP/1.1 200 OK Connection: close Date: Mon, 19 Sep 2011 22:04:00 GMT Accept-Ranges: bytes ETag: "2982766414" Server: lighttpd/1.4.19 Vary: Accept-Encoding Content-Encoding: bzip2 Content-Length: 1024 Content-Type: application/xml Last-Modified: Mon, 19 Sep 2011 06:28:28 GMT Client-Date: Mon, 19 Sep 2011 22:04:11 GMT Client-Peer: 220.127.116.11:80 Client-Response-Num: 1 BZ... decode() false Don't know how to decode Content-Encoding 'bzip2' at /usr/share/perl5/HTTP/Message.pm line 354. at foo.pl line 19 where I hoped that Content-Encoding "bzip2" might be as good as "x-bzip2", even if perhaps the server is doing the wrong thing by sending back an encoding name not among those the request said were acceptable.
use LWP::UserAgent; my $ua = LWP::UserAgent->new; use HTTP::Request; my $req = HTTP::Request->new (GET => '; my $decodable = HTTP::Message::decodable(); print "decodable: $decodable\n"; $req->header ('Accept-Encoding' => $decodable); print $req->dump; print "\n"; my $resp = $ua->request($req); print $resp->dump; print "\n"; $resp->decode() or print "decode() false\n"; $resp->decoded_content(charset => 'none', raise_error => 1);