CGI::C...eHandle(3pm)

πŸ“¦
version 1.03 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– CGI::Compress::Gzip::FileHandle πŸ’–

okay so bestie, welcome to CGI::Compress::Gzip::FileHandle (3pm) β€” yes the name is a whole mouthful, we know, but she's a helper package for CGI::Compress::Gzip and she's lowkey doing the most important job in the whole operation. πŸŽ€


✨ NAME ✨

CGI::Compress::Gzip::FileHandle β€” the CGI::Compress::Gzip helper package πŸ¦‹


πŸ“œ LICENSE πŸ“œ

Copyright 2006-2007 Clotho Advanced Media, Inc., <cpan@clotho.com> πŸ’œ

Copyright 2007-2008 Chris Dolan <cdolan@cpan.org> πŸ’œ

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. periodt. ✨


🌸 SYNOPSIS 🌸

ok so you don't actually use this one directly, but here's the vibe of how the big sister module gets used:

use CGI::Compress::Gzip;

my $cgi = new CGI::Compress::Gzip;
print $cgi->header();
print "<html> ...";

like, that's the whole point. print your stuff, it comes out compressed. iconic. πŸ’…


πŸ’« DESCRIPTION πŸ’«

This is intended for internal use only! Use CGI::Compress::Gzip instead. 🚨 like genuinely bestie, don't touch this one directly, she's not for you, she's for the machine.

This CGI::Compress::Gzip helper class subclasses IO::Zlib. She exists for one very specific reason: to make sure that output is not compressed until the CGI header is emitted. the way that timing matters here… 😭

So this filehandle delays the ignition of the zlib filter until it sees the exact same header generated by CGI::Compress::Gzip::header() pass through its WRITE() method. no cap. it's watching. πŸ‘€

⚠️ and if you change the header before printing it? this class will throw an exception. so don't do that. fr fr. πŸ’€

This class holds one global variable representing the previous default filehandle used before the gzip filter is put in place. That filehandle β€” usually STDOUT β€” is replaced after the gzip stream finishes, which is usually when the CGI object goes out of scope and is destroyed. 🫢


🧚 FUNCTIONS 🧚

πŸ’– OPEN πŸ’–

Overrides IO::Zlib::OPEN. This method doesn't actually do anything β€” she's just storing her arguments for a later call to SUPER::OPEN in WRITE(). πŸ™ˆ

The reason? We may not have seen the header yet, so we don't yet know whether to compress output. main character energy: wait for the signal. ⭐

🌈 WRITE buffer, length, offset 🌈

Emit the uncompressed header followed by the compressed body. slay. πŸ”₯

πŸŽ€ CLOSE πŸŽ€

Flush the compressed output. bye bestie, out it goes. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Clotho Advanced Media, cpan@clotho.com πŸ’Œ

Primary developer: Chris Dolan πŸ§‘β€πŸ’»


and that's the whole page, bestie!! πŸ’– this was perl v5.34.0, dated 2022-06-09, from the CGI::C...eHandle(3pm) manual β€” go forth and let CGI::Compress::Gzip do the actual work, ily, mwah πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from