Debian Codegraph @

README

raw
1 NAME
2 HTTP::Response::Encoding - Adds encoding() to HTTP::Response
3
4 VERSION
5 $Id: README,v 0.2 2007/05/12 09:24:15 dankogai Exp $
6
7 SYNOPSIS
8 use LWP::UserAgent;
9 use HTTP::Response::Encoding;
10
11 my $ua = LWP::UserAgent->new();
12 my $res = $ua->get("http://www.example.com/");
13 warn $res->encoding;
14
15 EXPORT
16 Nothing.
17
18 METHODS
19 This module adds the following methods to HTTP::Response objects.
20
21 "$res->charset"
22 Tells the charset *exactly as appears* in the "Content-Type:" header.
23 Note that the presence of the charset does not guarantee if the
24 response content is decodable via Encode.
25
26 To normalize this, you should try
27
28 $res->encoder->mime_name; # with Encode 2.21 or above
29
30 or
31
32 use I18N::Charset;
33 # ...
34 mime_charset_name($res->encoding);
35
36 "$res->encoder"
37 Returns the corresponding encoder object or undef if it can't.
38
39 "$res->encoding"
40 Tells the content encoding in the canonical name in Encode. Returns
41 undef if it can't.
42
43 For most cases, you are more likely to successfully find encoding
44 after GET than HEAD. HTTP::Response is smart enough to parse
45
46 <meta http-equiv="Content-Type" content="text/html; charset=whatever"/>
47
48 But you need the content to let HTTP::Response parse it. If you don't
49 want to retrieve the whole content but interested in its encoding, try
50 something like below;
51
52 my $req = HTTP::Request->new(GET => $uri);
53 $req->headers->header(Range => "bytes=0-4095"); # just 1st 4k
54 my $res = $ua->request($req);
55 warn $res->encoding;
56
57 "$res->decoded_content"
58 Discontinued since HTTP::Message already has this method.
59
60 See HTTP::Message for details.
61
62 INSTALLATION
63 To install this module, run the following commands:
64
65 perl Makefile.PL
66 make
67 make test
68 make install
69
70 AUTHOR
71 Dan Kogai, "<dankogai at dan.co.jp>"
72
73 BUGS
74 Please report any bugs or feature requests to
75 "bug-http-response-encoding at rt.cpan.org", or through the web
76 interface at
77 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTTP-Response-Encoding>.
78 I will be notified, and then you'll automatically be notified of
79 progress on your bug as I make changes.
80
81 SUPPORT
82 You can find documentation for this module with the perldoc command.
83
84 perldoc HTTP::Response::Encoding
85
86 You can also look for information at:
87
88 * AnnoCPAN: Annotated CPAN documentation
89
90 <http://annocpan.org/dist/HTTP-Response-Encoding>
91
92 * CPAN Ratings
93
94 <http://cpanratings.perl.org/d/HTTP-Response-Encoding>
95
96 * RT: CPAN's request tracker
97
98 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTTP-Response-Encoding>
99
100 * Search CPAN
101
102 <http://search.cpan.org/dist/HTTP-Response-Encoding>
103
104 ACKNOWLEDGEMENTS
105 GAAS for LWP.
106
107 MIYAGAWA for suggestions.
108
109 COPYRIGHT & LICENSE
110 Copyright 2007 Dan Kogai, all rights reserved.
111
112 This program is free software; you can redistribute it and/or modify it
113 under the same terms as Perl itself.
114