WWW-Mechanize-GZip-0.14/0000755000000000000000000000000013334476732013404 5ustar rootrootWWW-Mechanize-GZip-0.14/Changes0000755000000000000000000000067013334476662014707 0ustar rootrootRevision history for WWW-Mechanize-GZip 0.14 2018-08-14 - fixed empty META.yml 0.13 2018-07-16 - fixed typo in POD 0.12 2009-06-24 - fixed warning on undefined 'content-encoding' - thanks to Edward Smirnov 0.11 2009-06-16 - added comments to pass POD-Coverage - thanks to Jesse Vincent - added 'use warnings;' - thanks to Jesse Vincent too 0.10 2007-02-18 First version. WWW-Mechanize-GZip-0.14/README0000755000000000000000000000047513323101711014251 0ustar rootrootWWW-Mechanize-GZip INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install COPYRIGHT AND LICENCE Copyright (C) 2018 Peter Giessner This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. WWW-Mechanize-GZip-0.14/t/0000755000000000000000000000000013334476732013647 5ustar rootrootWWW-Mechanize-GZip-0.14/t/boilerplate.t0000755000000000000000000000233110714552276016335 0ustar rootroot#!perl -T use strict; use warnings; use Test::More tests => 3; sub not_in_file_ok { my ($filename, %regex) = @_; open my $fh, "<", $filename or die "couldn't open $filename for reading: $!"; my %violated; while (my $line = <$fh>) { while (my ($desc, $regex) = each %regex) { if ($line =~ $regex) { push @{$violated{$desc}||=[]}, $.; } } } if (%violated) { fail("$filename contains boilerplate text"); diag "$_ appears on lines @{$violated{$_}}" for keys %violated; } else { pass("$filename contains no boilerplate text"); } } not_in_file_ok(README => "The README is used..." => qr/The README is used/, "'version information here'" => qr/to provide version information/, ); not_in_file_ok(Changes => "placeholder date/time" => qr(Date/time) ); sub module_boilerplate_ok { my ($module) = @_; not_in_file_ok($module => 'the great new $MODULENAME' => qr/ - The great new /, 'boilerplate description' => qr/Quick summary of what the module/, 'stub function definition' => qr/function[12]/, ); } module_boilerplate_ok('lib/WWW/Mechanize/GZip.pm'); WWW-Mechanize-GZip-0.14/t/00-load.t0000755000000000000000000000025210714552276015167 0ustar rootroot#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'WWW::Mechanize::GZip' ); } diag( "Testing WWW::Mechanize::GZip $WWW::Mechanize::GZip::VERSION, Perl $], $^X" ); WWW-Mechanize-GZip-0.14/t/pod-coverage.t0000755000000000000000000000025410714552276016410 0ustar rootroot#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); WWW-Mechanize-GZip-0.14/t/pod.t0000755000000000000000000000021410714552276014613 0ustar rootroot#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); WWW-Mechanize-GZip-0.14/META.yml0000644000000000000000000000117413334476732014660 0ustar rootroot--- abstract: 'tries to fetch webpages with gzip-compression' author: - 'Peter Giessner ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: WWW-Mechanize-GZip no_index: directory: - t - inc requires: Compress::Zlib: '0' Test::More: '0' WWW::Mechanize: '0' version: '0.14' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' WWW-Mechanize-GZip-0.14/MANIFEST0000755000000000000000000000036113334476732014540 0ustar rootrootChanges MANIFEST META.yml # Will be created by "make dist" Makefile.PL README lib/WWW/Mechanize/GZip.pm t/00-load.t t/boilerplate.t t/pod-coverage.t t/pod.t META.json Module JSON meta-data (added by MakeMaker) WWW-Mechanize-GZip-0.14/lib/0000755000000000000000000000000013334476732014152 5ustar rootrootWWW-Mechanize-GZip-0.14/lib/WWW/0000755000000000000000000000000013334476732014636 5ustar rootrootWWW-Mechanize-GZip-0.14/lib/WWW/Mechanize/0000755000000000000000000000000013334476732016541 5ustar rootrootWWW-Mechanize-GZip-0.14/lib/WWW/Mechanize/GZip.pm0000755000000000000000000000605313334476716017761 0ustar rootroot=head1 NAME WWW::Mechanize::GZip - tries to fetch webpages with gzip-compression =head1 VERSION Version 0.14 =head1 SYNOPSIS use WWW::Mechanize::GZip; my $mech = WWW::Mechanize::GZip->new(); my $response = $mech->get( $url ); print "x-content-length (before unzip) = ", $response->header('x-content-length'); print "content-length (after unzip) = ", $response->header('content-length'); =head1 DESCRIPTION The L module tries to fetch a URL by requesting gzip-compression from the webserver. If the response contains a header with 'Content-Encoding: gzip', it decompresses the response in order to get the original (uncompressed) content. This module will help to reduce bandwidth fetching webpages, if supported by the webeserver. If the webserver does not support gzip-compression, no decompression will be made. This modules is a direct subclass of L and will therefore support any methods provided by L. The decompression is handled by L::memGunzip. =head2 METHODS =over 2 =item prepare_request Adds 'Accept-Encoding' => 'gzip' to outgoing HTTP-headers before sending. =item send_request Unzips response-body if 'content-encoding' is 'gzip' and corrects 'content-length' to unzipped content-length. =back =head1 SEE ALSO L L =head1 AUTHOR Peter Giessner C =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Peter Giessner C. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package WWW::Mechanize::GZip; our $VERSION = '0.14'; use strict; use warnings; use Compress::Zlib (); use base qw(WWW::Mechanize); ################################################################################ sub prepare_request { my ($self, $request) = @_; # call baseclass-method to prepare request... $request = $self->SUPER::prepare_request($request); # set HTTP-header to request gzip-transfer-encoding at the webserver $request->header('Accept-Encoding' => 'gzip'); return ($request); } ################################################################################ sub send_request { my ($self, $request, $arg, $size) = @_; # call baseclass-method to make the actual request my $response = $self->SUPER::send_request($request, $arg, $size); # check if response is declared as gzipped and decode it if ($response && defined($response->headers->header('content-encoding')) && $response->headers->header('content-encoding') eq 'gzip') { # store original content-length in separate response-header $response->headers->header('x-content-length', length($response->{_content})); # decompress ... $response->{_content} = Compress::Zlib::memGunzip(\($response->{_content})); # store new content-length in response-header $response->{_headers}->{'content-length'} = length($response->{_content}); } return $response; } 1; __END__WWW-Mechanize-GZip-0.14/META.json0000644000000000000000000000201413334476732015022 0ustar rootroot{ "abstract" : "tries to fetch webpages with gzip-compression", "author" : [ "Peter Giessner " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "WWW-Mechanize-GZip", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Compress::Zlib" : "0", "Test::More" : "0", "WWW::Mechanize" : "0" } } }, "release_status" : "stable", "version" : "0.14", "x_serialization_backend" : "JSON::PP version 2.94" } WWW-Mechanize-GZip-0.14/Makefile.PL0000755000004100000410000000107710714552276016715 0ustar www-datawww-datause strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'WWW::Mechanize::GZip', AUTHOR => 'Peter Giessner ', VERSION_FROM => 'lib/WWW/Mechanize/GZip.pm', ABSTRACT_FROM => 'lib/WWW/Mechanize/GZip.pm', PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Compress::Zlib' => 0, 'WWW::Mechanize' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'WWW-Mechanize-GZip-*' }, );