#!perl -w

# This is a simple script that is used by test.pl

use warnings;
use strict;
use Carp;
$SIG{__WARN__} = \&Carp::confess;
$SIG{__DIE__} = \&Carp::cluck;

use CGI::Compress::Gzip;

my $cgi = CGI::Compress::Gzip->new("");
my $op = shift || "";
if ($op eq "redirect")
{
   print $cgi->redirect(@ARGV);
}
elsif ($op eq "charset")
{
   print $cgi->header("text/html; charset=UTF-8");
   print @ARGV;
}
elsif ($op eq "type")
{
   print $cgi->header(-Type => "foo/bar");
   print @ARGV;
}
elsif ($op eq "mod_perl")
{
   # Deliberately initialize this AFTER creating the $cgi instance
   $ENV{MOD_PERL} = 1;
   print $cgi->header();
   print @ARGV;
}
elsif ($op eq "empty")
{
   print $cgi->header();
}
elsif ($op eq "doublehead")
{
   $CGI::HEADERS_ONCE = 1;
   print $cgi->header();
   print $cgi->header();
   print @ARGV;
}
elsif ($op eq "unbuffer")
{
   $| = 1;
   print $cgi->header();
   print @ARGV;
}
elsif ($op eq "fh1")
{
   my $fh = \*STDOUT;
   $cgi->useFileHandle($fh);
   print $cgi->header("text/html");
   print @ARGV;
}
elsif ($op eq "fh2")
{
   $cgi->useFileHandle(\*STDOUT);
   print STDOUT $cgi->header("text/html");
   print STDOUT @ARGV;
}
elsif ($op eq "fh3")
{
   my $fh = \*STDOUT;
   $cgi->useFileHandle($fh);
   print $fh $cgi->header("text/html");
   print $fh @ARGV;
}
else
{
   print $cgi->header();
   print @ARGV;
}
