| 1 | package CGI::Application::Plugin::DevPopup::HTTPHeaders; | ||||||||||
| 2 | { | ||||||||||
| 3 | 1 | $CGI::Application::Plugin::DevPopup::HTTPHeaders::VERSION = '1.08'; | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | no warnings 'uninitialized'; # don't care about empty strings | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use base qw/Exporter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | sub import | ||||||||||
| 12 | 1 | ▶ | { | ||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | my $c = scalar caller; | |||||||||
| 14 | 1 | $c->add_callback( 'devpopup_report', \&_header_report ); | |||||||||
| 15 | 1 | goto &Exporter::import; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | sub _header_report | ||||||||||
| 19 | 1 | ▶ | { | ||||||||
|
Subroutine
_header_report: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 1 | my $self = shift; | |||||||||
| 21 | 1 | my $env = _env_report($self); | |||||||||
| 22 | 1 | my $cgi = _cgi_report($self); | |||||||||
| 23 | 1 | my $out = $self->query->header($self->header_props); | |||||||||
| 24 | 1 | $out =~ s/\r//g; | |||||||||
| 25 | |||||||||||
| 26 | 1 | $self->devpopup->add_report( | |||||||||
| 27 | title => 'HTTP Headers', | ||||||||||
| 28 | summary => 'Incoming and outgoing HTTP headers', | ||||||||||
| 29 | report => qq( | ||||||||||
| 30 | <style type="text/css"> | ||||||||||
| 31 | tr.even{background-color:#eee} | ||||||||||
| 32 | </style> | ||||||||||
| 33 | <table><thead><th colspan="2">Incoming HTTP Headers</th></thead><tbody> $cgi </tbody></table> | ||||||||||
| 34 | <table><thead><th colspan="2">Outgoing HTTP Headers</th></thead><tbody><tr><td style="white-space:pre">$out</td></tr></tbody></table> | ||||||||||
| 35 | <table><thead><th colspan="2">Environment Dump</th></thead><tbody><tr><td> $env </td></tr></tbody></table> | ||||||||||
| 36 | ) | ||||||||||
| 37 | ); | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | sub _env_report | ||||||||||
| 41 | 1 | ▶ | { | ||||||||
|
Subroutine
_env_report: called CC=2 SCAR=6.9
| |||||||||||
| 42 | 1 | my $self = shift; | |||||||||
| 43 | 1 | my $r=0; | |||||||||
| 44 | my $report = join $/, map { | ||||||||||
| 45 | 1 | $r=1-$r; | |||||||||
| 46 | 37 | ▶ | qq{<tr class="@{[$r?'odd':'even']}"><td valign="top"> $_ </td><td> $ENV{$_} </td></tr>} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | } | ||||||||||
| 48 | sort keys %ENV; | ||||||||||
| 49 | |||||||||||
| 50 | 1 | return $report; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | sub _cgi_report | ||||||||||
| 54 | 1 | ▶ | { | ||||||||
|
Subroutine
_cgi_report: called CC=5 SCAR=18.0
| |||||||||||
| 55 | 1 | my $self = shift; | |||||||||
| 56 | |||||||||||
| 57 | 1 | my $r=0; | |||||||||
| 58 | 1 | my $q = $self->query; | |||||||||
| 59 | 1 | my $report = ''; | |||||||||
| 60 | |||||||||||
| 61 | 1 | eval { | |||||||||
| 62 | $report = '<tr><th colspan="2">http</th></tr>' . | ||||||||||
| 63 | join $/, map { | ||||||||||
| 64 | 1 | $r=1-$r; | |||||||||
| 65 | 1 | ▶ | qq{<tr class="@{[$r?'odd':'even']}"><td valign="top"> $_ </td><td> @{[$q->http($_)]} </td></tr>} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | } | ||||||||||
| 67 | sort $q->http; | ||||||||||
| 68 | }; | ||||||||||
| 69 | |||||||||||
| 70 | 1 | ▶ | return "<tr><td>Your query object doesn't have a http() method</td></tr>" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | |||||||||||
| 72 | 1 | eval { | |||||||||
| 73 | $report .= '<tr><th colspan="2">https</th></tr>' . | ||||||||||
| 74 | join $/, , map { | ||||||||||
| 75 | 0 | ▶ | $r=1-$r; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 0 | ▶ | qq{<tr class="@{[$r?'odd':'even']}"><td valign="top"> $_ </td><td> @{[$q->https($_)]} </td></tr>} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | } | ||||||||||
| 78 | sort $q->https if $q->https; | ||||||||||
| 79 | }; | ||||||||||
| 80 | |||||||||||
| 81 | 1 | return $report; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 1 | 1; # End of CGI::Application::Plugin::DevPopup::HTTPHeaders | |||||||||
| 85 | |||||||||||
| 86 | __END__ | ||||||||||