1HTTP::Response::EncodinUgs(e3r)Contributed Perl DocumentHaTtTiPo:n:Response::Encoding(3)
2
3
4

NAME

6       HTTP::Response::Encoding - Adds encoding() to HTTP::Response
7

VERSION

9       $Id: Encoding.pm,v 0.6 2009/07/28 21:25:25 dankogai Exp dankogai $
10

SYNOPSIS

12         use LWP::UserAgent;
13         use HTTP::Response::Encoding;
14
15         my $ua = LWP::UserAgent->new();
16         my $res = $ua->get("http://www.example.com/");
17         warn $res->encoding;
18

EXPORT

20       Nothing.
21

METHODS

23       This module adds the following methods to  HTTP::Response objects.
24
25       "$res->charset"
26         Tells the charset exactly as appears in the "Content-Type:" header.
27         Note that the presence of the charset does not guarantee if the
28         response content is decodable via Encode.
29
30         To normalize this, you should try
31
32           $res->encoder->mime_name; # with Encode 2.21 or above
33
34         or
35
36           use I18N::Charset;
37           # ...
38           mime_charset_name($res->encoding);
39
40       "$res->encoder"
41         Returns the corresponding encoder object or undef if it can't.
42
43       "$res->encoding"
44         Tells the content encoding in the canonical name in Encode.  Returns
45         undef if it can't.
46
47         For most cases, you are more likely to successfully find encoding
48         after GET than HEAD.  HTTP::Response is smart enough to parse
49
50           <meta http-equiv="Content-Type" content="text/html; charset=whatever"/>
51
52         But you need the content to let HTTP::Response parse it.  If you
53         don't want to retrieve the whole content but interested in its
54         encoding, try something like below;
55
56           my $req =  HTTP::Request->new(GET => $uri);
57           $req->headers->header(Range => "bytes=0-4095"); # just 1st 4k
58           my $res = $ua->request($req);
59           warn $res->encoding;
60
61       "$res->decoded_content"
62         Discontinued since HTTP::Message already has this method.
63
64         See HTTP::Message for details.
65

INSTALLATION

67       To install this module, run the following commands:
68
69           perl Makefile.PL
70           make
71           make test
72           make install
73

AUTHOR

75       Dan Kogai, "<dankogai at dan.co.jp>"
76

BUGS

78       Please report any bugs or feature requests to
79       "bug-http-response-encoding at rt.cpan.org", or through the web
80       interface at
81       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTTP-Response-Encoding>.
82       I will be notified, and then you'll automatically be notified of
83       progress on your bug as I make changes.
84

SUPPORT

86       You can find documentation for this module with the perldoc command.
87
88           perldoc HTTP::Response::Encoding
89
90       You can also look for information at:
91
92       •   AnnoCPAN: Annotated CPAN documentation
93
94           <http://annocpan.org/dist/HTTP-Response-Encoding>
95
96       •   CPAN Ratings
97
98           <http://cpanratings.perl.org/d/HTTP-Response-Encoding>
99
100       •   RT: CPAN's request tracker
101
102           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTTP-Response-Encoding>
103
104       •   Search CPAN
105
106           <http://search.cpan.org/dist/HTTP-Response-Encoding>
107

ACKNOWLEDGEMENTS

109       GAAS for LWP.
110
111       MIYAGAWA for suggestions.
112
114       Copyright 2007 Dan Kogai, all rights reserved.
115
116       This program is free software; you can redistribute it and/or modify it
117       under the same terms as Perl itself.
118
119
120
121perl v5.32.1                      2021-01-27       HTTP::Response::Encoding(3)
Impressum