HTTP::Response::Encoding(3pm) | User Contributed Perl Documentation | HTTP::Response::Encoding(3pm) |
HTTP::Response::Encoding - Adds encoding() to HTTP::Response
$Id: Encoding.pm,v 0.6 2009/07/28 21:25:25 dankogai Exp dankogai $
use LWP::UserAgent; use HTTP::Response::Encoding; my $ua = LWP::UserAgent->new(); my $res = $ua->get("http://www.example.com/"); warn $res->encoding;
Nothing.
This module adds the following methods to HTTP::Response objects.
To normalize this, you should try
$res->encoder->mime_name; # with Encode 2.21 or above
or
use I18N::Charset; # ... mime_charset_name($res->encoding);
For most cases, you are more likely to successfully find encoding after GET than HEAD. HTTP::Response is smart enough to parse
<meta http-equiv="Content-Type" content="text/html; charset=whatever"/>
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); warn $res->encoding;
See HTTP::Message for details.
To install this module, run the following commands:
perl Makefile.PL make make test make install
Dan Kogai, "<dankogai at dan.co.jp>"
Please report any bugs or feature requests to "bug-http-response-encoding at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTTP-Response-Encoding>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc HTTP::Response::Encoding
You can also look for information at:
<http://annocpan.org/dist/HTTP-Response-Encoding>
<http://cpanratings.perl.org/d/HTTP-Response-Encoding>
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTTP-Response-Encoding>
<http://search.cpan.org/dist/HTTP-Response-Encoding>
GAAS for LWP.
MIYAGAWA for suggestions.
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.
2022-12-11 | perl v5.36.0 |