[libnet-openid-common-perl] 01/04: use HTTP::Response to decode content (closes #78218)
gregor herrmann
gregoa at debian.org
Sun Feb 7 21:50:40 UTC 2016
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to annotated tag v1.16
in repository libnet-openid-common-perl.
commit a09b91e75637a2dc72a3fdccb0bb9fee14952d04
Author: Vernon Lyon <vernonlyon at hotmail.com>
Date: Wed Aug 22 16:35:56 2012 +0100
use HTTP::Response to decode content (closes #78218)
---
lib/Net/OpenID/URIFetch.pm | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/lib/Net/OpenID/URIFetch.pm b/lib/Net/OpenID/URIFetch.pm
index 909c30a..62f4e08 100644
--- a/lib/Net/OpenID/URIFetch.pm
+++ b/lib/Net/OpenID/URIFetch.pm
@@ -24,12 +24,7 @@ use HTTP::Request;
use HTTP::Status;
use strict;
use warnings;
-use Carp;
-
-our $HAS_ZLIB;
-BEGIN {
- $HAS_ZLIB = eval "use Compress::Zlib (); 1;";
-}
+use Carp();
use constant URI_OK => 200;
use constant URI_MOVED_PERMANENTLY => 301;
@@ -88,9 +83,7 @@ sub fetch {
}
my $req = HTTP::Request->new(GET => $uri);
- if ($HAS_ZLIB) {
- $req->header('Accept-Encoding', 'gzip');
- }
+ $req->header('Accept-Encoding', scalar HTTP::Message::decodable());
if ($ref) {
if (my $etag = ($ref->{Headers}->{etag})) {
$req->header('If-None-Match', $etag);
@@ -112,13 +105,12 @@ sub fetch {
return $cached_response->();
}
else {
- my $content = $res->content;
my $final_uri = $res->request->uri->as_string();
my $final_cache_key = "URIFetch:${prefix}:${final_uri}";
- if ($res->content_encoding && $res->content_encoding eq 'gzip') {
- $content = Compress::Zlib::memGunzip($content);
- }
+ my $content = $res->decoded_content # Decode content-encoding and charset
+ || $res->decoded_content(charset => 'none') # Decode content-encoding
+ || $res->content; # Undecoded content
if ($content_hook) {
$content_hook->(\$content);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libnet-openid-common-perl.git
More information about the Pkg-perl-cvs-commits
mailing list