Debian Codegraph @

t/testhelp

raw
1 #!perl -w ## no critic (RequireVersionVar)
2
3 # This is a simple script that is used by t/gzip.t
4
5 use 5.006;
6 use warnings;
7 use strict;
8 use English qw(-no_match_vars);
9
10 use CGI::Compress::Gzip;
11 $CGI::Compress::Gzip::global_give_reason = 1;
12 $OUTPUT_AUTOFLUSH = 0; # aka $|
13
14 # Pull out "-DVAR=val" arguments
15 while (@ARGV && $ARGV[0] =~ m/\A -D([^=]+)=(.+) \z/xms) {
16 $ENV{$1} = $2;
17 shift @ARGV;
18 }
19 my ($op, @msg) = @ARGV;
20 $op ||= q{};
21
22
23 my $cgi = CGI::Compress::Gzip->new(q{});
24
25 if ($op eq 'redirect') { ## no critic (ProhibitCascadingIfElse)
26 print $cgi->redirect(@msg);
27
28 } elsif ($op eq 'charset') {
29 print $cgi->header('text/html; charset=UTF-8');
30 print @msg;
31
32 } elsif ($op eq 'type') {
33 print $cgi->header(-Type => 'foo/bar');
34 print @msg;
35
36 } elsif ($op eq 'mod_perl') {
37 # Deliberately initialize this AFTER creating the $cgi instance
38 $ENV{MOD_PERL} = 1;
39 print $cgi->header();
40 print @msg;
41
42 } elsif ($op eq 'empty') {
43 print $cgi->header();
44
45 } elsif ($op eq 'doublehead') {
46 $CGI::HEADERS_ONCE = 1;
47 print $cgi->header();
48 print $cgi->header();
49 print @msg;
50
51 } elsif ($op eq 'unbuffer') {
52 $OUTPUT_AUTOFLUSH = 1; # aka $|
53 print $cgi->header();
54 print @msg;
55
56 } elsif ($op eq 'fh1') {
57 my $fh = \*STDOUT;
58 $cgi->useFileHandle($fh);
59 print $cgi->header('text/html');
60 print @msg;
61
62 } elsif ($op eq 'fh2') {
63 $cgi->useFileHandle(\*STDOUT);
64 print {*STDOUT} $cgi->header('text/html');
65 print {*STDOUT} @msg;
66
67 } elsif ($op eq 'fh3') {
68 my $fh = \*STDOUT;
69 $cgi->useFileHandle($fh);
70 print {$fh} $cgi->header('text/html');
71 print {$fh} @msg;
72
73 } else {
74 print $cgi->header();
75 print @msg;
76
77 }