#!/usr/local/bin/perl use warnings; use strict; use Gzip::Faster; # This variable is set to a true value if it is OK to compress the # output. my $gzip_ok; # Check the environment variable HTTP_ACCEPT_ENCODING for the value # "gzip". my $accept_encoding = $ENV{HTTP_ACCEPT_ENCODING}; if ($accept_encoding && $accept_encoding =~ /\bgzip\b/) { $gzip_ok = 1; } # Print the HTTP header print "Content-Type: text/html\n"; if ($gzip_ok) { print "Content-Encoding: gzip\n"; } print "\n"; # Create the contents for the default case where compression is not # possible. my $stuff = <