| 1 | package Pod::Webserver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use parent 'Pod::Simple::HTMLBatch'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use vars qw( $VERSION @ISA ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Pod::Webserver::Daemon; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Pod::Webserver::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Pod::Simple::HTMLBatch; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Pod::Simple::TiedOutFH; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Pod::Simple; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use File::Spec::Unix (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | our $VERSION = '3.11'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | if(defined &DEBUG) { } # no-op | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | elsif( defined &Pod::Simple::DEBUG ) { *DEBUG = \&Pod::Simple::DEBUG } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ▶ | elsif( ($ENV{'PODWEBSERVERDEBUG'} || '') =~ m/^(\d+)$/ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'PODWEBSERVERDEBUG'} || ''
MC/DC0%0/1
$ENV{'PODWEBSERVERDEBUG'} || ''
$ENV{'PODWEBSERVERDEBUG'}
Truth table0%0/2
A
A= $ENV{'PODWEBSERVERDEBUG'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | { my $x = $1; *DEBUG = sub(){$x} } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | else { *DEBUG = sub () {0}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } # End of BEGIN. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | #sub Pod::Simple::HTMLBatch::DEBUG () {5} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 15 | ▶ | sub add_to_fs { # add an item to my virtual in-memory filesystem | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_to_fs: called CC=11 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 15 | my($self,$file,$type,$content) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 15 | ▶ | die "Missing filespec\n" unless defined $file and length $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $file and length $file
MC/DC0%0/2
defined $file and length $file
defined $file
length $file
Truth table33%1/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 15 | $file = "/$file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 15 | $file =~ s{/+}{/}s; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 15 | ▶ | $type ||= | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition66%2/3
$type ||= $file eq "/" ? "text/html" : ($file =~ /\.dat?/ ? "application/octet-stream" : ($file =~ /\.html?/ ? "text/html" : ($file =~ /\.txt/ ? "text/plain" : ($file =~ /\.gif/ ? "image/gif" : ($file =~ /\.jpe?g/ ? "image/jpeg" : ($file =~ /\.png/ ? "image/png" : "text/plain"))))))
MC/DC0%0/2
$type ||= $file eq "/" ? "text/html" : ($file =~ /\.dat?/ ? "application/octet-stream" : ($file =~ /\.html?/ ? "text/html" : ($file =~ /\.txt/ ? "text/plain" : ($file =~ /\.gif/ ? "image/gif" : ($file =~ /\.jpe?g/ ? "image/jpeg" : ($file =~ /\.png/ ? "image/png" : "text/plain"))))))
$type
$file eq "/" ? "text/html" : ($file =~ /\.dat?/ ? "application/octet-stream" : ($file =~ /\.html?/ ? "text/html" : ($file =~ /\.txt/ ? "text/plain" : ($file =~ /\.gif/ ? "image/gif" : ($file =~ /\.jpe?g/ ? "image/jpeg" : ($file =~ /\.png/ ? "image/png" : "text/plain"))))))
Truth table66%2/3
A ||= B
A= $typeB= $file eq "/" ? "text/html" : ($file =~ /\.dat?/ ? "application/octet-stream" : ($file =~ /\.html?/ ? "text/html" : ($file =~ /\.txt/ ? "text/plain" : ($file =~ /\.gif/ ? "image/gif" : ($file =~ /\.jpe?g/ ? "image/jpeg" : ($file =~ /\.png/ ? "image/png" : "text/plain"))))))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $file eq '/' ? 'text/html' # special case | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | : $file =~ m/\.dat?/ ? 'application/octet-stream' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | : $file =~ m/\.html?/ ? 'text/html' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | : $file =~ m/\.txt/ ? 'text/plain' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | : $file =~ m/\.gif/ ? 'image/gif' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | : $file =~ m/\.jpe?g/ ? 'image/jpeg' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | : $file =~ m/\.png/ ? 'image/png' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | : 'text/plain' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 15 | $content = '' unless defined ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 15 | $self->{'__daemon_fs'}{"\e$file"} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 15 | \( $self->{'__daemon_fs'}{$file} = $content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } # End of add_to_fs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub _arg_h { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arg_h: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | my $class = ref($_[0]) || $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $_[0]->_arg_V; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | print join "\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | "Usage:", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | " podwebserver = Start podwebserver on localhost:8020. Search \@INC", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | " podwebserver -p 1234 = Start podwebserver on localhost:1234", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | " podwebserver -p 1234 -H blorp = Start podwebserver on blorp:1234", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | " podwebserver -t 3600 = Auto-exit in 1 hour. Default => 18000 (5 hours). 0 => No timeout", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | " podwebserver -d /path/to/lib = Ignore \@INC, and only search within /path/to/lib", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | " podwebserver -e /path/to/skip = Exclude /path/to/skip files", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | " podwebserver -q = Quick startup (but no Table of Contents)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | " podwebserver -v = Run with verbose output to STDOUT", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | " podwebserver -h = See this message", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | " podwebserver -V = Show version information", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | "\nRun 'perldoc $class' for more information.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } # End of _arg_h. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub _arg_V { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arg_V: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $class = ref($_[0]) || $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # Anything else particularly useful to report here? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | print '', __PACKAGE__, " version $VERSION", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # and report if we're running a subclass: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | (__PACKAGE__ eq $class) ? () : (" ($class)"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | print " Running under perl version $] for $^O", | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | (chr(65) eq 'A') ? "\n" : " in a non-ASCII world\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | print " Win32::BuildNumber ", &Win32::BuildNumber(), "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &Win32::BuildNumber and defined &Win32::BuildNumber()
MC/DC0%0/2
defined &Win32::BuildNumber and defined &Win32::BuildNumber()
defined &Win32::BuildNumber
defined &Win32::BuildNumber()
Truth table0%0/3
A and B
A= defined &Win32::BuildNumberB= defined &Win32::BuildNumber()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | if defined(&Win32::BuildNumber) and defined &Win32::BuildNumber(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | print " MacPerl verison $MacPerl::Version\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | if defined $MacPerl::Version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } # End of _arg_V. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | sub _contents_filespec { return '/' } # overriding the superclass's | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_contents_filespec: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 12 | ▶ | sub filespecsys { $_[0]{'_filespecsys'} || 'File::Spec::Unix' } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filespecsys: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub _get_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_options: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->verbose(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return unless @ARGV; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | require Getopt::Std; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my %o; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | Getopt::Std::getopts( "d:e:H:hp:qt:Vv" => \%o ) || die "Failed to parse options\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # The 2 switches that shortcut the run: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | $o{'h'} and exit( $self->_arg_h || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->_arg_h || 0
MC/DC0%0/1
$self->_arg_h || 0
$self->_arg_h
Truth table0%0/2
A
A= $self->_arg_h
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $o{'V'} and exit( $self->_arg_V || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->_arg_V || 0
MC/DC0%0/1
$self->_arg_V || 0
$self->_arg_V
Truth table0%0/2
A
A= $self->_arg_V
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $self->_arg_h, exit(0) if ($o{p} and ($o{p} !~ /^\d+$/) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$o{"p"} and not $o{"p"} =~ /^\d+$/
MC/DC0%0/2
$o{"p"} and not $o{"p"} =~ /^\d+$/
$o{"p"}
not $o{"p"} =~ /^\d+$/
Truth table0%0/3
A and not(B)
A= $o{"p"}B= not $o{"p"} =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $self->_arg_h, exit(0) if ($o{t} and ($o{t} !~ /^\d+$/) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$o{"t"} and not $o{"t"} =~ /^\d+$/
MC/DC0%0/2
$o{"t"} and not $o{"t"} =~ /^\d+$/
$o{"t"}
not $o{"t"} =~ /^\d+$/
Truth table0%0/3
A and not(B)
A= $o{"t"}B= not $o{"t"} =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $self->dir_exclude( [ map File::Spec->canonpath($_), split(/:|;/, $o{'e'}) ] ) if ($o{'e'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $self->dir_include( [ map File::Spec->canonpath($_), split(/:|;/, $o{'d'}) ] ) if ($o{'d'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | $self->httpd_host( $o{'H'} ) if $o{'H'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $self->httpd_port( $o{'p'} ) if $o{'p'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $self->httpd_timeout( $o{'t'} ) if $o{'t'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $self->skip_indexing(1) if $o{'q'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | $self->verbose(4) if $o{'v'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } # End of _get_options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Run me as: perl -MPod::HTTP -e Pod::Webserver::httpd | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # or (assuming you have it installed), just run "podwebserver" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub httpd { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
httpd: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my $self = @_ ? shift(@_) : __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $self = $self->new unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $self->{'_batch_start_time'} = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $self->_init_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->_get_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $self->contents_file('/'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $self->prep_for_daemon; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $daemon = $self->new_daemon || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->new_daemon || (return)
MC/DC0%0/1
$self->new_daemon || (return)
$self->new_daemon
Truth table0%0/2
A
A= $self->new_daemon
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $url = $daemon->url; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $url =~ s{//default\b}{//localhost} if $^O =~ m/Win32/; # lame hack | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | DEBUG > -1 and print "You can now open your browser to $url\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return $self->run_daemon($daemon); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } # End of httpd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | sub _init_options | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_options: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $self->dir_exclude([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->dir_include([@INC]); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } # End of _init_options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub makepath { return } # overriding the superclass's | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makepath: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | #sub muse { return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | ▶ | sub new_daemon { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_daemon: called CC=6 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | my @opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | push @opts, LocalHost => $self->httpd_host if (defined $self->httpd_host); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | push @opts, LocalPort => $self->httpd_port || 8020; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->httpd_port || 8020
MC/DC0%0/1
$self->httpd_port || 8020
$self->httpd_port
Truth table50%1/2
A
A= $self->httpd_port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | if (defined $self->httpd_timeout) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | if ($self->httpd_timeout > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | push @opts, Timeout => $self->httpd_timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | push @opts, Timeout => 24 * 3600; # Default to exit after 24 hours of idle time. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | $self->muse( "Starting daemon with options {@opts}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | ▶ | Pod::Webserver::Daemon->new(@opts) || die "Can't start a daemon: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } # End of _new_daemon. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | ▶ | sub prep_for_daemon { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prep_for_daemon: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | DEBUG > -1 and print "I am process $$ = perl ", __PACKAGE__, " v$VERSION\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | $self->{'__daemon_fs'} = {}; # That's where we keep the bodies!!!! | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | $self->{'__expires_as_http_date'} = time2str(24*3600+time); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | $self->{ '__start_as_http_date'} = time2str( time); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | $self->add_to_fs( 'robots.txt', 'text/plain', join "\cm\cj", | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | "User-agent: *", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | "Disallow: /", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | "", "", "# I am " . __PACKAGE__ . " v$VERSION", "", "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | $self->add_to_fs( '/', 'text/html', | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # We get this only when we start up in -q mode: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | "* Perl Pod server *\n<p>Example URL: http://whatever/Getopt/Std\n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | $self->_spray_css( '/' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $self->_spray_javascript( '/' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | DEBUG > 5 and print "In FS: ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | join(' ', map qq{"$_"}, sort grep !m/^\e/, keys %{ $self->{'__daemon_fs'} }), | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | $self->prep_lookup_table(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } # End of prep_for_daemon. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | ▶ | sub prep_lookup_table { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prep_lookup_table: called CC=13 SCAR=29.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | my $m2p; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | if( $self->skip_indexing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->muse("Skipping \@INC indexing."); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | if($self->progress) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | DEBUG and print "Using existing progress object\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ▶ | } elsif( DEBUG or ($self->verbose() >= 1 and $self->verbose() <= 5) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->verbose >= 1 and $self->verbose <= 5
MC/DC0%0/2
$self->verbose >= 1 and $self->verbose <= 5
$self->verbose >= 1
$self->verbose <= 5
Truth table33%1/3
A and B
A= $self->verbose >= 1B= $self->verbose <= 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | require Pod::Simple::Progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->progress( Pod::Simple::Progress->new(4) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | my $search = $Pod::Simple::HTMLBatch::SEARCH_CLASS->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | my $dir_include = $self->dir_include; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | if(DEBUG > -1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | ▶ | if ($#{$self->dir_include} >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | print " Indexing all of @$dir_include -- this might take a minute.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | print " Indexing all of \@INC -- this might take a minute.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | DEBUG > 1 and print "\@INC = [ @INC ]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | $self->{'httpd_has_noted_inc_already'} ++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | $m2p = $self->modnames2paths($dir_include ? $dir_include : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | $self->progress(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # Filter out excluded folders | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | while ( my ($key, $value) = each %$m2p ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1834 | DEBUG > 1 and print "-e $value, ", (grep $value =~ /^\Q$_\E/, @{ $self->dir_exclude }), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1834 | ▶ | delete $m2p->{$key} if grep $value =~ /^\Q$_\E/, @{ $self->dir_exclude }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | ▶ | die "Missing path\n" unless $m2p and keys %$m2p; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$m2p and keys %$m2p
MC/DC0%0/2
$m2p and keys %$m2p
$m2p
keys %$m2p
Truth table33%1/3
A and B
A= $m2pB= keys %$m2p
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | DEBUG > -1 and print " Done scanning \n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | foreach my $modname (sort keys %$m2p) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1834 | my @namelets = split '::', $modname; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1834 | $self->note_for_contents_file( \@namelets, 'crunkIn', 'crunkOut' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $self->write_contents_file('crunkBase'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | ▶ | $self->{'__modname2path'} = $m2p || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$m2p || {}
MC/DC0%0/1
$m2p || {}
$m2p
Truth table50%1/2
A
A= $m2p
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } # End of prep_lookup_table. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub run_daemon { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_daemon: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my($self, $daemon) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | while( my $conn = $daemon->accept ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if( my $req = $conn->get_request ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | #^^ That used to be a while(... instead of an if( ..., but the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # keepalive wasn't working so great, so let's just leave it for now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # It's not like our server here is streaming GIFs or anything. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | DEBUG and print "Answering connection at ", localtime()."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $self->_serve_thing($conn, $req); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $conn->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | undef($conn); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->muse("HTTP Server terminated"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } # End of run_daemon. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | sub _serve_pod { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serve_pod: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my($self, $modname, $filename, $resp) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | unless( -e $filename and -r _ and -s _ ) { # sanity | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
-e $filename and -r _ and -s _
-e $filename and -r _
MC/DC0%0/3
-e $filename and -r _ and -s _
-e $filename
-r _
-s _
Truth table0%0/4
A and B and C
A= -e $filenameB= -r _C= -s _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $self->muse( "But filename $filename is no good!" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $modtime = (stat(_))[9]; # use my own modtime whynot! | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $resp->content(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $contr = $resp->content_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $Pod::Simple::HTMLBatch::HTML_EXTENSION | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | = $Pod::Simple::HTML::HTML_EXTENSION = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $resp->header('Last-Modified' => time2str($modtime) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # This is totally gross and hacky. So unless your name rhymes | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # with "Pawn Lurk", you have to cover your eyes right now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | $retval = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | $self->_do_one_batch_conversion( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | $modname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | { $modname => $filename }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | '/', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | Pod::Simple::TiedOutFH->handle_on($contr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $self->muse( "$modname < $filename" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $self->muse( "Ugh, couldn't convert $modname" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } # End of _serve_pod. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub _serve_thing { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serve_thing: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my($self, $conn, $req) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | return $conn->send_error(405) unless $req->method eq 'GET'; # sanity | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $path = $req->url; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $path .= substr( ($ENV{PATH} ||''), 0, 0); # to force-taint it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'PATH'} || ''
MC/DC0%0/1
$ENV{'PATH'} || ''
$ENV{'PATH'}
Truth table0%0/2
A
A= $ENV{'PATH'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $fs = $self->{'__daemon_fs'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $pods = $self->{'__modname2path'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $resp = Pod::Webserver::Response->new(200); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | $resp->content_type( $fs->{"\e$path"} || 'text/html' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$fs{"\e$path"} || 'text/html'
MC/DC0%0/1
$$fs{"\e$path"} || 'text/html'
$$fs{"\e$path"}
Truth table0%0/2
A
A= $$fs{"\e$path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $path =~ s{:+}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $modname = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $modname =~ s{/+}{::}g; $modname =~ s{^:+}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $modname =~ s{:+$}{}; $modname =~ s{:+$}{::}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | if( $modname =~ m{^([a-zA-Z0-9_]+(?:::[a-zA-Z0-9_]+)*)$}s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $modname = $1; # thus untainting | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $modname = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | DEBUG > 1 and print "Modname $modname ($path)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | if( $fs->{$path} ) { # Is it in our mini-filesystem? | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $resp->content( $fs->{$path} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $resp->header( 'Last-Modified' => $self->{ '__start_as_http_date'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $resp->header( 'Expires' => $self->{'__expires_as_http_date'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $self->muse("Serving pre-cooked $path"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } elsif( $modname eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $resp = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # After here, it's only untainted module names | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } elsif( $pods->{$modname} ) { # Is it known pod? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | #$self->muse("I know $modname as ", $pods->{$modname}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | $self->_serve_pod( $modname, $pods->{$modname}, $resp ) or $resp = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # If it's not known, look for it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # This is necessary for indexless mode, and also useful just in case | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # the user has just installed a new module (after the index was generated) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $fspath = $Pod::Simple::HTMLBatch::SEARCH_CLASS->new->find($modname); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if( defined($fspath) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | #$self->muse("Found $modname as $fspath"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->_serve_pod( $modname, $fspath, $resp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $resp = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $self->muse("Can't find $modname in \@INC"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | unless( $self->{'httpd_has_noted_inc_already'} ++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $self->muse(" \@INC = [ @INC ]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | $resp ? $conn->send_response( $resp ) : $conn->send_error(404); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } # End of _serve_thing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 13 | ▶ | sub _wopen { # overriding the superclass's | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wopen: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 13 | my($self, $outpath) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 13 | return Pod::Simple::TiedOutFH->handle_on( $self->add_to_fs($outpath) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } # End of _wopen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | ▶ | sub write_contents_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_contents_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | $Pod::Simple::HTMLBatch::HTML_EXTENSION | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | = $Pod::Simple::HTML::HTML_EXTENSION = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | return $self->SUPER::write_contents_file(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } # End of write_contents_file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | sub url_up_to_contents { return '/' } # overriding the superclass's | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url_up_to_contents: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # Inlined from HTTP::Date to avoid a dependency | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | my @DoW = qw(Sun Mon Tue Wed Thu Fri Sat); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 3 | my @MoY = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 7 | ▶ | sub time2str (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time2str: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 7 | my $time = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 7 | my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 7 | sprintf("%s, %02d %s %04d %02d:%02d:%02d GMT", | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | $DoW[$wday], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | $mday, $MoY[$mon], $year+1900, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | $hour, $min, $sec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 3 | __PACKAGE__->Pod::Simple::_accessorize( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 3 | 'dir_include', | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 'dir_exclude', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 'httpd_port', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 'httpd_host', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 'httpd_timeout', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 'skip_indexing', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 3 | ▶ | httpd() unless caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||