Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05) Standard preamble: ========================================================================
HTTP::Response::Encoding - Adds encoding() to HTTP::Response
$Id: Encoding.pm,v 0.5 2007/05/12 09:24:15 dankogai Exp $
my $ua = LWP::UserAgent->new();
my $res = $ua->get("http://www.example.com/");
This module adds the following methods to HTTP::Response objects.
Tells the charset exactly as appears in the "Content-Type:" header. Note that the presence of the charset does not guarantee if the response content is decodable via Encode.
To normalize this, you should try
$res->encoder->mime_name; # with Encode 2.21 or above
Returns the corresponding encoder object or undef if it can't.
Tells the content encoding in the canonical name in Encode. Returns undef if it can't.
For most cases, you are more likely to successfully find encoding after GET than HEAD. HTTP::Response is smart enough to parse
But you need the content to let HTTP::Response parse it. If you don't want to retrieve the whole content but interested in its encoding, try something like below;
my $req = HTTP::Request->new(GET => $uri);
$req->headers->header(Range => "bytes=0-4095"); # just 1st 4k
my $res = $ua->request($req);
Discontinued since HTTP::Message already has this method.
See HTTP::Message for details.
To install this module, run the following commands:
Dan Kogai, "
Please report any bugs or feature requests to "bug-http-response-encoding at rt.cpan.org", or through the web interface at
You can find documentation for this module with the perldoc command.
You can also look for information at:
o AnnoCPAN: Annotated CPAN documentation
o CPAN Ratings
o RT: CPAN's request tracker
o Search CPAN
GAAS for LWP.
MIYAGAWA for suggestions.
COPYRIGHT & LICENSE
Copyright 2007 Dan Kogai, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.