WWW::M...::GZip(3pm)

πŸ“¦
version 0.14 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– WWW::Mechanize::GZip β€” the Perl doc page, bestie edition πŸ’–

okay so this is WWW::M...::GZip(3pm), a User Contributed Perl Documentation page, and I am so excited to walk you through it because it's genuinely such a little cutie πŸŽ€


✨ NAME ✨

WWW::Mechanize::GZip β€” it tries to fetch webpages with gzip-compression πŸ¦‹


✨ VERSION ✨

Version 0.14 πŸ’…


✨ SYNOPSIS ✨

bestie here's the whole vibe, copy-paste and go:

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');

like. look at those headers. before the unzip vs after</... ok wait, after the unzip. the glow-up is REAL 😭✨


✨ DESCRIPTION ✨

So the whole thing with WWW::Mechanize::GZip is that it tries to fetch a URL by asking the webserver for gzip-compression. Rude not to ask, honestly. πŸ™ˆ

And if the response comes back with a header saying 'Content-Encoding: gzip', it decompresses that response so you get the original (uncompressed) content back. 🫢

This module is here to help reduce bandwidth when fetching webpages β€” if the webserver supports it. And if the webserver does not support gzip-compression? Then no decompression gets made. Simple as that, no drama. πŸ’…

Also important: this module is a direct subclass of WWW::Mechanize πŸ‘‘ which means it will support any methods provided by WWW::Mechanize. everything. all of them. iconic behaviour fr fr.

The decompression itself is handled by Compress::Zlib::memGunzip. shoutout to them, they're doing the actual heavy lifting. ⭐


🌸 METHODS 🌸

πŸ’« prepare_request

Adds 'Accept-Encoding' => 'gzip' to the outgoing HTTP-headers before sending. it's giving "manifesting the gzip" energy. ✨

πŸ’« send_request

Unzips the response-body if 'content-encoding' is 'gzip', and corrects 'content-length' to the unzipped content-length. so the math is mathing at the end, not the beginning. 🧚


✨ SEE ALSO ✨

  • WWW::Mechanize
  • Compress::Zlib

go read those too bestie, iykyk πŸ’œ


✨ AUTHOR ✨

Peter Giessner "cardb@planet-elektronik.de" 🫢


Copyright (c) 2007, Peter Giessner "cardb@planet-elektronik.de". All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ“œβœ¨

fr fr, "same terms as Perl itself" β€” that's the whole license, no cap. πŸ’–

and that's the page!! perl v5.36.0, dated 2022-12-12, and the whole thing lives under the manual name WWW::M...::GZip(3pm). mwah, slay, go fetch some gzipped pages responsibly πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from