| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Perlbal::Test::WebClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 58 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 58 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 58 | ▶ | use Perlbal::Test; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 58 | ▶ | use HTTP::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 58 | ▶ | use Socket qw(MSG_NOSIGNAL IPPROTO_TCP TCP_NODELAY SOL_SOCKET); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 58 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 58 | ▶ | use vars qw(@ISA @EXPORT $FLAG_NOSIGNAL); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 58 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 58 | @EXPORT = qw(new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 58 | $FLAG_NOSIGNAL = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 58 | eval { $FLAG_NOSIGNAL = MSG_NOSIGNAL; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # create a blank object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 13 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 13 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # get/set what server we should be testing; "ip:port" generally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 | ▶ | sub server { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 13 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 13 | $self->{_sock} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 13 | return $self->{server} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return $self->{server}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # get/set what hostname we send with requests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub host { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $self->{_sock} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return $self->{host} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | return $self->{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # set which HTTP version to emulate; specify '1.0' or '1.1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 13 | ▶ | sub http_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http_version: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 13 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | return $self->{http_version} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return $self->{http_version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # set on or off to enable or disable persistent connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 15 | ▶ | sub keepalive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keepalive: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 15 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 15 | ▶ | $self->{keepalive} = shift() ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 15 | return $self->{keepalive}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # construct and send a request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 150 | ▶ | sub request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: called CC=29 SCAR=36.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 150 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 150 | ▶ | return undef unless $self->{server}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 150 | ▶ | my $opts = ref $_[0] eq "HASH" ? shift : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 150 | my $opt_headers = delete $opts->{'headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 150 | my $opt_host = delete $opts->{'host'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 150 | my $opt_method = delete $opts->{'method'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 150 | my $opt_content = delete $opts->{'content'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 150 | my $opt_extra_rn = delete $opts->{'extra_rn'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 150 | my $opt_return_reader = delete $opts->{'return_reader'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 150 | my $opt_post_header_pause = delete $opts->{'post_header_pause'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 150 | ▶ | die "Bogus options: " . join(", ", keys %$opts) if %$opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 150 | my $cmds = join(',', map { eurl($_) } @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 150 | ▶ | return undef unless $cmds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # keep-alive header if 1.0, also means add content-length header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 150 | my $headers = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 150 | ▶ | if ($self->{keepalive}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 145 | $headers .= "Connection: keep-alive\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | $headers .= "Connection: close\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 150 | ▶ | if ($opt_headers) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 17 | $headers .= $opt_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 150 | ▶ | if (my $hostname = $opt_host || $self->{host}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt_host || $self->{'host'}
MC/DC50%1/2
$opt_host || $self->{'host'}
$opt_host
$self->{'host'}
Truth table66%2/3
A || B
A= $opt_hostB= $self->{'host'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 17 | $headers .= "Host: $hostname\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 150 | ▶ | my $method = $opt_method || "GET"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt_method || 'GET'
MC/DC100%1/1
$opt_method || 'GET'
$opt_method
Truth table100%2/2
A
A= $opt_method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 150 | my $body = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 150 | ▶ | if ($opt_content) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 74 | $headers .= "Content-Length: " . length($opt_content) . "\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 74 | $body = $opt_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 150 | ▶ | if ($opt_extra_rn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 36 | $body .= "\r\n"; # some browsers on POST send an extra \r\n that's not part of content-length | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 150 | my $send = "$method /$cmds HTTP/$self->{http_version}\r\n$headers\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 150 | ▶ | unless ($opt_post_header_pause) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 114 | $send .= $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 150 | my $len = length $send; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # send setup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 150 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 150 | my $sock = delete $self->{_sock}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 150 | ▶ | local $SIG{'PIPE'} = "IGNORE" unless $FLAG_NOSIGNAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ### send it cached | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 150 | ▶ | if ($sock) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 133 | $rv = send($sock, $send, $FLAG_NOSIGNAL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 133 | ▶ | if ($! || ! defined $rv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$! or not defined $rv
MC/DC0%0/2
$! or not defined $rv
$!
not defined $rv
Truth table33%1/3
A or not(B)
A= $!B= not defined $rv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | undef $self->{_sock}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } elsif ($rv != $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # failing that, send it through a new socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 150 | ▶ | unless ($rv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 17 | $self->{_reqdone} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $sock = IO::Socket::INET->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | PeerAddr => $self->{server}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 17 | ▶ | Timeout => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 17 | ▶ | setsockopt($sock, IPPROTO_TCP, TCP_NODELAY, pack("l", 1)) or die "failed to set sockopt: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 17 | $rv = send($sock, $send, $FLAG_NOSIGNAL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 17 | ▶ | if ($! || $rv != $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$! or $rv != $len
MC/DC0%0/2
$! or $rv != $len
$!
$rv != $len
Truth table33%1/3
A or B
A= $!B= $rv != $len
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 150 | ▶ | if ($opt_post_header_pause) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 36 | select undef, undef, undef, $opt_post_header_pause; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 36 | my $len = length $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 36 | ▶ | if ($len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 36 | my $rv = send($sock, $body, $FLAG_NOSIGNAL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 36 | ▶ | if ($! || ! defined $rv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$! or not defined $rv
MC/DC0%0/2
$! or not defined $rv
$!
not defined $rv
Truth table33%1/3
A or not(B)
A= $!B= not defined $rv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | undef $self->{_sock}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } elsif ($rv != $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 150 | ▶ | my $parse_it = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 150 | my ($resp, $firstline) = resp_from_sock($sock); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 150 | ▶ | my $conhdr = $resp->header("Connection") || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$resp->header('Connection') || ''
MC/DC0%0/1
$resp->header('Connection') || ''
$resp->header('Connection')
Truth table50%1/2
A
A= $resp->header('Connection')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 150 | ▶ | if (($firstline =~ m!\bHTTP/1\.1\b! && $conhdr !~ m!\bclose\b!i) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$firstline =~ m[\bHTTP/1\.1\b] and not $conhdr =~ /\bclose\b/i or $firstline =~ m[\bHTTP/1\.0\b] and $conhdr =~ /\bkeep-alive\b/i
$firstline =~ m[\bHTTP/1\.1\b] and not $conhdr =~ /\bclose\b/i
$firstline =~ m[\bHTTP/1\.0\b] and $conhdr =~ /\bkeep-alive\b/i
MC/DC25%1/4
$firstline =~ m[\bHTTP/1\.1\b] and not $conhdr =~ /\bclose\b/i or $firstline =~ m[\bHTTP/1\.0\b] and $conhdr =~ /\bkeep-alive\b/i
$firstline =~ m[\bHTTP/1\.1\b]
not $conhdr =~ /\bclose\b/i
$firstline =~ m[\bHTTP/1\.0\b]
$conhdr =~ /\bkeep-alive\b/i
Truth table28%2/7
A and not(B) or C and D
A= $firstline =~ m[\bHTTP/1\.1\b]B= not $conhdr =~ /\bclose\b/iC= $firstline =~ m[\bHTTP/1\.0\b]D= $conhdr =~ /\bkeep-alive\b/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ($firstline =~ m!\bHTTP/1\.0\b! && $conhdr =~ m!\bkeep-alive\b!i)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 142 | $self->{_sock} = $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 142 | $self->{_reqdone}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 8 | $self->{_reqdone} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 150 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 150 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 150 | ▶ | if ($opt_return_reader) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return $parse_it; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 150 | return $parse_it->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 89 | ▶ | sub reqdone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reqdone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 89 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 89 | return $self->{_reqdone}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # general purpose URL escaping function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 152 | ▶ | sub eurl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eurl: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 152 | my $a = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $a =~ s/([^a-zA-Z0-9_\,\-.\/\\\: ])/uc sprintf("%%%02x",ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 152 | $a =~ tr/ /+/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 152 | return $a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 58 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||