aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Plugin/URL_Title.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/Plugin/URL_Title.pm b/Plugin/URL_Title.pm
index df72f02..4b85a02 100644
--- a/Plugin/URL_Title.pm
+++ b/Plugin/URL_Title.pm
@@ -7,6 +7,7 @@ use HTML::Parser;
use HTML::Entities;
use utf8;
use Encode;
+use IO::Uncompress::Gunzip qw/gunzip/;
# For optional debug page dumping
use IO::Compress::Gzip qw/gzip/;
@@ -72,7 +73,12 @@ sub get_title
# FIXME add more XML-based formats that we can theoretically extract titles from
# FIXME factor out accepted formats and response match into accepted formats array
- my $http = HTTP::Tiny->new((default_headers => {'Range' => "bytes=0-65536", 'Accept' => 'text/html, image/svg+xml'}, timeout => 3));
+ my %headers = (
+ "Range" => "bytes=0-65536",
+ "Accept" => "text/html, image/svg+xml",
+ "Acceot-Encoding" => "gzip"
+ );
+ my $http = HTTP::Tiny->new((default_headers => \%headers, timeout => 3));
my $response = $http->get($url);
@@ -95,6 +101,13 @@ sub get_title
my $html = $response->{content};
+ if ($response->{headers}->{"content-encoding"} &&
+ $response->{headers}->{"content-encoding"} == "gzip") {
+ my $new_html;
+ gunzip \$html => \$new_html or return (undef, undef, "Error: gzip decompression failed: $!");
+ $html = $new_html;
+ }
+
if ($config->{debug_dump}) {
my $zipped;
if (gzip \$html => \$zipped) {