| 1 | package Linux::Event::HTTP::Server::Connection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 25 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 25 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 25 | ▶ | use parent 'Linux::Event::IO::Sock::Stream'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 25 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 25 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 25 | ▶ | use utf8 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 25 | ▶ | use Linux::Event::Framer (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 25 | ▶ | use Linux::Event::HTTP::_HTTP1 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 25 | ▶ | use Linux::Event::HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 25 | ▶ | use Linux::Event::HTTP::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 25 | ▶ | use Linux::Event::HTTP::Transaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 25 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 25 | Linux::Event::Framer->declare_native_consumer( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | Linux::Event::HTTP::_HTTP1->_raw_consumer_definition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 25 | my $PARSER = 'Linux::Event::HTTP::_HTTP1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 25 | my $CHUNKED = 'Linux::Event::HTTP::_HTTP1::Chunked'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 25 | my $MAX_REQUEST_HEAD = 65_536; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 25 | my $MAX_HEADERS = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 25 | my %CLASS_HANDLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 374 | ▶ | sub _class_handler ($class, $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_class_handler: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 374 | my $key = "$class\0$name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 374 | ▶ | return $CLASS_HANDLER{$key} if exists $CLASS_HANDLER{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 180 | return $CLASS_HANDLER{$key} = $class->can($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 440 | ▶ | sub _take_http_handler ($class, $name, $option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_take_http_handler: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 440 | ▶ | if (exists $option->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 66 | my $handler = delete $option->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 66 | ▶ | croak "new(): $name must be a coderef" if ref($handler) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 66 | return $handler; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 374 | return _class_handler($class, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 89 | ▶ | sub new ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 89 | my $server_state = $option{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 89 | ▶ | if (ref($server_state) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | eq 'Linux::Event::HTTP::Server::_ConnectionState') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 76 | $option{data} = $server_state->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 76 | my $callbacks = $server_state->{callbacks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 76 | for my $name (qw(on_request on_body on_request_end)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $option{$name} = $callbacks->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 228 | ▶ | if exists $callbacks->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | croak 'new(): Connection owns on_data; use on_request for HTTP requests' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 89 | ▶ | if exists $option{on_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | croak 'new(): Connection cannot use message framing callbacks' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 89 | ▶ | if exists($option{on_message}) || exists($option{on_messages}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $option{"on_message"} or exists $option{"on_messages"}
MC/DC0%0/2
exists $option{"on_message"} or exists $option{"on_messages"}
exists $option{"on_message"}
exists $option{"on_messages"}
Truth table33%1/3
A or B
A= exists $option{"on_message"}B= exists $option{"on_messages"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | croak 'new(): on_request_final was removed; use on_request and Response->body or Transaction->response_body' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 89 | ▶ | if exists $option{on_request_final}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 88 | my $loop = delete $option{loop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 88 | my $on_request = _take_http_handler($class, 'on_request', \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 88 | my $on_body = _take_http_handler($class, 'on_body', \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 88 | my $on_request_end = _take_http_handler($class, 'on_request_end', \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 88 | my $user_on_drain = _take_http_handler($class, 'on_drain', \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 88 | my $user_on_close = _take_http_handler($class, 'on_close', \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 88 | ▶ | croak 'new(): HTTP Connection requires on_request callback or method' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | if !$on_request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 88 | $option{on_drain} = \&_http_transport_drain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 88 | $option{on_close} = \&_http_transport_close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 88 | my $self = $class->SUPER::new(%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 87 | $self->{_http_on_request} = $on_request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 87 | $self->{_http_on_body} = $on_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 87 | $self->{_http_on_request_end} = $on_request_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 87 | $self->{_http_user_on_drain} = $user_on_drain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 87 | $self->{_http_user_on_close} = $user_on_close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 87 | $self->{_http_input} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 87 | $self->{_http_active_transaction} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 87 | $self->{_http_active_request} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 87 | $self->{_http_active_response} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 87 | $self->{_http_request_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 87 | $self->{_http_response_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 87 | $self->{_http_response_output_started} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 87 | $self->{_http_response_output_complete} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 87 | $self->{_http_driving} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 87 | $self->{_http_dispatching} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 87 | $self->{_http_closing} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 87 | ▶ | $self->_attach_to_loop($loop) if $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 87 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub connect ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | croak 'connect(): HTTP client support is not implemented by Linux::Event::HTTP::Server::Connection'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 37 | ▶ | sub transaction ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transaction: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 37 | my $transaction = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 37 | ▶ | return $transaction if $transaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 31 | ▶ | my $request = $self->{_http_active_request} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 31 | ▶ | my $response = $self->{_http_active_response} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 31 | $transaction = Linux::Event::HTTP::Transaction | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ->_new_server_active($request, $response, $self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | $transaction->{response_output_started} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 31 | ▶ | if $self->{_http_response_output_started}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | $transaction->{response_output_complete} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 31 | ▶ | if $self->{_http_response_output_complete}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 31 | $self->{_http_active_transaction} = $transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 31 | return $transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub _http_native_protocol_400 ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_protocol_400: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->_protocol_error(400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub _http_native_protocol_431 ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_protocol_431: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->_protocol_error(431); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub _http_native_protocol_501 ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_protocol_501: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->_protocol_error(501); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub _http_native_fallback_input ($self, $bytes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_fallback_input: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $self->{_http_input} .= $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->_drive_http1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | return 1 if length($self->{_http_input}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $state = $self->{_http_request_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | return 1 if $self->{_http_active_request} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | && $state && !$state->{body_done}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"_http_active_request"} and $state and not $state->{"body_done"}
$self->{"_http_active_request"} and $state
MC/DC0%0/3
$self->{"_http_active_request"} and $state and not $state->{"body_done"}
$self->{"_http_active_request"}
$state
not $state->{"body_done"}
Truth table0%0/4
A and B and not(C)
A= $self->{"_http_active_request"}B= $stateC= not $state->{"body_done"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 122 | ▶ | sub _http_native_request ($self, $request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_request: called CC=9 SCAR=23.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 122 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | croak 'raw HTTP input delivered a new Request while another Request is active' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 122 | ▶ | if $self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 122 | my $consumed = $request->_consumed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 122 | ▶ | if ($consumed > $MAX_REQUEST_HEAD) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->_protocol_error(431, $request->version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 122 | my $action = $self->_activate_native_http_request($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 122 | ▶ | return 0 if $action != 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 28 | ▶ | return $self->{_http_on_body} ? 5 : 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | if $request->_http1_body_mode eq 'chunked'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 18 | ▶ | return $self->{_http_on_body} ? 3 : 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 15 | ▶ | sub _http_native_chunked_body ($self, $bytes, $done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_chunked_body: called CC=14 SCAR=30.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 15 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 15 | ▶ | my $request = $self->{_http_active_request} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 15 | ▶ | my $response = $self->{_http_active_response} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 15 | ▶ | my $state = $self->{_http_request_state} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | croak 'raw chunked body delivery has wrong request state' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 15 | ▶ | if $state->{body_done} || $state->{mode} ne 'chunked'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$state->{"body_done"} or $state->{"mode"} ne "chunked"
MC/DC0%0/2
$state->{"body_done"} or $state->{"mode"} ne "chunked"
$state->{"body_done"}
$state->{"mode"} ne "chunked"
Truth table33%1/3
A or B
A= $state->{"body_done"}B= $state->{"mode"} ne "chunked"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 15 | ▶ | if (length($bytes) && !$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $bytes and not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
MC/DC0%0/2
length $bytes and not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
length $bytes
not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
Truth table66%2/3
A and not(B)
A= length $bytesB= not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | $self->{_http_on_body}, $request, $response, $bytes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 15 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_http_closing"} or $self->is_closed
MC/DC50%1/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table66%2/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 14 | ▶ | return 0 if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 14 | ▶ | if ($done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | sub _http_native_chunked_complete ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_chunked_complete: called CC=7 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | my $state = $self->{_http_request_state} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | croak 'raw chunked drain has wrong request state' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | if $state->{body_done} || $state->{mode} ne 'chunked'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$state->{"body_done"} or $state->{"mode"} ne "chunked"
MC/DC0%0/2
$state->{"body_done"} or $state->{"mode"} ne "chunked"
$state->{"body_done"}
$state->{"mode"} ne "chunked"
Truth table33%1/3
A or B
A= $state->{"body_done"}B= $state->{"mode"} ne "chunked"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | croak 'raw chunked drain cannot bypass an on_body callback' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | if $self->{_http_on_body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | sub _http_native_chunked_error ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_chunked_error: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | ▶ | my $request = $self->{_http_active_request} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | my $response = $self->{_http_active_response} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | $self->_fail_active_transaction(400, $request, $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 17 | ▶ | sub _http_native_content_length_body ($self, $bytes, $done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_content_length_body: called CC=18 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 17 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 17 | ▶ | my $request = $self->{_http_active_request} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 17 | ▶ | my $response = $self->{_http_active_response} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 17 | ▶ | my $state = $self->{_http_request_state} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | croak 'raw Content-Length body delivery has wrong request state' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 17 | ▶ | if $state->{body_done} || $state->{mode} ne 'content-length'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$state->{"body_done"} or $state->{"mode"} ne "content-length"
MC/DC0%0/2
$state->{"body_done"} or $state->{"mode"} ne "content-length"
$state->{"body_done"}
$state->{"mode"} ne "content-length"
Truth table33%1/3
A or B
A= $state->{"body_done"}B= $state->{"mode"} ne "content-length"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 17 | my $length = length($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 17 | ▶ | my $remaining = $state->{remaining} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$state->{"remaining"} // 0
MC/DC0%0/1
$state->{"remaining"} // 0
$state->{"remaining"}
Truth table50%1/2
A
A= $state->{"remaining"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 17 | ▶ | croak 'raw Content-Length body delivery exceeds remaining body' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | if $length > $remaining; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 17 | $state->{remaining} = $remaining - $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | ▶ | if ($length && !$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$length and not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
MC/DC0%0/2
$length and not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
$length
not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
Truth table33%1/3
A and not(B)
A= $lengthB= not $self->_invoke_http_callback($self->{"_http_on_body"}, $request, $response, $bytes)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | $self->{_http_on_body}, $request, $response, $bytes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 17 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_http_closing"} or $self->is_closed
MC/DC50%1/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table66%2/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 16 | ▶ | return 0 if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 16 | ▶ | if ($done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | croak 'raw Content-Length body completed before declared length' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 15 | ▶ | if $state->{remaining} != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 15 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 15 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | croak 'raw Content-Length body reached zero without completion' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ▶ | if $state->{remaining} == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | sub _http_native_content_length_complete ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_native_content_length_complete: called CC=7 SCAR=22.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | ▶ | my $state = $self->{_http_request_state} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | croak 'raw Content-Length drain has wrong request state' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | ▶ | if $state->{body_done} || $state->{mode} ne 'content-length'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$state->{"body_done"} or $state->{"mode"} ne "content-length"
MC/DC0%0/2
$state->{"body_done"} or $state->{"mode"} ne "content-length"
$state->{"body_done"}
$state->{"mode"} ne "content-length"
Truth table33%1/3
A or B
A= $state->{"body_done"}B= $state->{"mode"} ne "content-length"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | croak 'raw Content-Length drain cannot bypass an on_body callback' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | if $self->{_http_on_body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | $state->{remaining} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub _http_transport_drain ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_transport_drain: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if (my $executor = $self->{_http2_executor}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $executor->transport_drain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } elsif (my $transaction = $self->{_http_active_transaction}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (my $body = $transaction->_response_body_object) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $body->_drain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if (my $callback = $self->{_http_user_on_drain}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $callback->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 5 | ▶ | sub _http_transport_close ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_transport_close: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 5 | ▶ | if (my $executor = delete $self->{_http2_executor}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $executor->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 5 | ▶ | if (my $transaction = $self->{_http_active_transaction}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | ▶ | $transaction->_mark_cancelled if !$transaction->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | Linux::Event::HTTP::Server::Connection::_clear_transaction($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 5 | my $callback = delete $self->{_http_user_on_close}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5 | delete $self->{_http_user_on_drain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | ▶ | $callback->($self) if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 20 | ▶ | sub _new_request_state ($request, $mode = $request->_http1_body_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_request_state: called CC=5 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 20 | my $state = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | mode => $mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | body_done => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 20 | ▶ | if ($mode eq 'content-length') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 20 | ▶ | $state->{remaining} = $request->content_length // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$request->content_length // 0
MC/DC0%0/1
$request->content_length // 0
$request->content_length
Truth table50%1/2
A
A= $request->content_length
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } elsif ($mode eq 'chunked') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $state->{decoder} = $CHUNKED->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 20 | return $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 29 | ▶ | sub _body_pending ($state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_body_pending: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 29 | ▶ | return 0 if $state->{body_done}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 29 | ▶ | return 0 if $state->{mode} eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 29 | ▶ | return $state->{remaining} > 0 if $state->{mode} eq 'content-length'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 10 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub _expect_continue ($request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expect_continue: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my @values = $request->_header_values_list('Expect'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | return 0 if !@values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | return -1 if $request->version ne '1.1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | for my $value (@values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | for my $member (split /,/, $value, -1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $member =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $member =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | return -1 if $member eq '' || lc($member) ne '100-continue'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$member eq "" or lc $member ne "100-continue"
MC/DC0%0/2
$member eq "" or lc $member ne "100-continue"
$member eq ""
lc $member ne "100-continue"
Truth table0%0/3
A or B
A= $member eq ""B= lc $member ne "100-continue"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ++$count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | return $count ? 1 : -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 202 | ▶ | sub _invoke_http_callback ($self, $handler, $request, $response, @extra) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invoke_http_callback: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 202 | ▶ | return 1 if !$handler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 198 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 198 | local $self->{_http_dispatching} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 198 | $handler->($self, $request, $response, @extra); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 183 | $self->_response_body_ready($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 182 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 198 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 16 | $self->_fail_active_transaction(500, $request, $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 16 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 182 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 183 | ▶ | sub _response_body_ready ($self, $response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_response_body_ready: called CC=14 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 183 | ▶ | return if !$response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 183 | ▶ | return if $self->{_http_dispatching}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 183 | ▶ | my $active_response = $self->{_http_active_response} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 174 | ▶ | return if refaddr($active_response) != refaddr($response); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 174 | ▶ | return if $self->{_http_response_output_complete}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 138 | my $transaction = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 138 | ▶ | if ((($response->{_server_flags} // 0) & 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition85%6/7
($response->{"_server_flags"} // 0) & 1 and ($response->{"body_kind"} // "") eq "scalar"
$response->{"_server_flags"} // 0
$response->{"body_kind"} // ""
MC/DC50%1/2
($response->{"_server_flags"} // 0) & 1 and ($response->{"body_kind"} // "") eq "scalar"
$response->{"_server_flags"}
$response->{"body_kind"}
Truth table66%2/3
A and B
A= $response->{"_server_flags"}B= $response->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | && ($response->{body_kind} // '') eq 'scalar') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | return if $self->_try_native_default_final( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | $transaction, $response->{body}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 36 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 109 | ▶ | return if ($response->{body_kind} // '') ne 'scalar'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$response->{"body_kind"} // ""
MC/DC100%1/1
$response->{"body_kind"} // ""
$response->{"body_kind"}
Truth table100%2/2
A
A= $response->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 56 | my $body = $response->{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 56 | ▶ | return if $self->_try_simple_scalar_final($response, $body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 18 | $self->_write_response( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | $response, $body, 1, 'send_response', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 58 | ▶ | sub _try_simple_scalar_final ($self, $response, $body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_try_simple_scalar_final: called CC=13 SCAR=29.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 58 | ▶ | my $request = $self->{_http_active_request} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 58 | ▶ | return 0 if $self->{_http_response_state}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 58 | my $wire = Linux::Event::HTTP::_HTTP1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ->build_simple_scalar_final($request, $response, $body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 58 | ▶ | return 0 if !defined $wire; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 38 | my $request_state = $self->{_http_request_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # The ordinary synchronous bodyless response has no materialized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # Transaction and no later request-body phase that needs output state. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Keep only the started bit across write() for exception safety, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # retire the three live exchange references directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 38 | ▶ | if ($request_state && $request_state->{body_done} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$request_state and $request_state->{"body_done"} and not $self->{"_http_active_transaction"}
$request_state and $request_state->{"body_done"}
MC/DC33%1/3
$request_state and $request_state->{"body_done"} and not $self->{"_http_active_transaction"}
$request_state
$request_state->{"body_done"}
not $self->{"_http_active_transaction"}
Truth table50%2/4
A and B and not(C)
A= $request_stateB= $request_state->{"body_done"}C= not $self->{"_http_active_transaction"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | && !$self->{_http_active_transaction}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 21 | $self->{_http_response_output_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 21 | $self->write($wire); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 21 | $self->{_http_active_request} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 21 | $self->{_http_active_response} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 21 | $self->{_http_request_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 21 | $self->{_http_response_output_started} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 21 | ▶ | $self->resume_read if $self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 21 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 17 | $self->{_http_response_output_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 17 | $self->{_http_response_output_complete} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 17 | ▶ | if (my $transaction = $self->{_http_active_transaction}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $transaction->{response_output_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $transaction->{response_output_complete} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 17 | $self->write($wire); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 17 | ▶ | if ($request_state && $request_state->{body_done}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$request_state and $request_state->{"body_done"}
MC/DC0%0/2
$request_state and $request_state->{"body_done"}
$request_state
$request_state->{"body_done"}
Truth table33%1/3
A and B
A= $request_stateB= $request_state->{"body_done"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | if (my $transaction = $self->{_http_active_transaction}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $transaction->{state} = 'complete'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $self->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 17 | ▶ | $self->resume_read if $self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 17 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 2 | ▶ | sub _send_http_response ($self, $transaction) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_send_http_response: called CC=11 SCAR=28.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | croak 'send_response(): connection is closing or closed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 2 | ▶ | if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | my $active = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2 | ▶ | croak 'send_response(): Transaction is not active on this HTTP connection' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
MC/DC0%0/2
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
not $active
builtin::refaddr($active) != builtin::refaddr($transaction)
Truth table33%1/3
not(A) or B
A= not $activeB= builtin::refaddr($active) != builtin::refaddr($transaction)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | if !$active || refaddr($active) != refaddr($transaction); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | ▶ | croak 'send_response(): response output has already started' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | if $transaction->is_response_started; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | ▶ | my $response = $transaction->response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | or croak 'send_response(): Transaction has no Response'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | croak 'send_response(): Response does not have a complete scalar body' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | ▶ | if ($response->{body_kind} // '') ne 'scalar'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$response->{"body_kind"} // ""
MC/DC0%0/1
$response->{"body_kind"} // ""
$response->{"body_kind"}
Truth table50%1/2
A
A= $response->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 2 | my $body = $response->{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | ▶ | return 1 if $self->_try_native_default_final($transaction, $body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | ▶ | return 1 if $self->_try_simple_scalar_final($response, $body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | $self->_write_response($response, $body, 1, 'send_response'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 38 | ▶ | sub _try_native_default_final ($self, $transaction, $body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_try_native_default_final: called CC=21 SCAR=34.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | my $response = $transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ? $transaction->{response} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 38 | ▶ | : $self->{_http_active_response}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 38 | ▶ | return 0 if !$response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 38 | ▶ | return 0 if !(($response->{_server_flags} // 0) & 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$response->{"_server_flags"} // 0
MC/DC0%0/1
$response->{"_server_flags"} // 0
$response->{"_server_flags"}
Truth table50%1/2
A
A= $response->{"_server_flags"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 37 | ▶ | return 0 if (($response->{status} // 200) != 200); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$response->{"status"} // 200
MC/DC0%0/1
$response->{"status"} // 200
$response->{"status"}
Truth table50%1/2
A
A= $response->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 37 | ▶ | return 0 if defined $response->{reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 37 | my $headers = $response->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 37 | ▶ | return 0 if defined($headers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
defined $headers and ref $headers ne "ARRAY" || @$headers
ref $headers ne "ARRAY" or @$headers
MC/DC0%0/3
defined $headers and ref $headers ne "ARRAY" || @$headers
defined $headers
ref $headers ne "ARRAY"
@$headers
Truth table25%1/4
A and B or C
A= defined $headersB= ref $headers ne "ARRAY"C= @$headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | && (ref($headers) ne 'ARRAY' || @$headers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 37 | ▶ | return 0 if $self->{_http_response_state}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 37 | ▶ | my $request_state = $self->{_http_request_state} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 37 | ▶ | my $body_done = $request_state->{body_done} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | my $request = $transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ? $transaction->{request} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 37 | ▶ | : $self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 37 | ▶ | return 0 if !$request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 37 | my $wire = Linux::Event::HTTP::_HTTP1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | ->build_default_final($request, $body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 37 | ▶ | return 0 if !defined $wire; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 29 | $response->{committed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 29 | $self->{_http_response_output_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 29 | $self->{_http_response_output_complete} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 29 | ▶ | if ($transaction) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $transaction->{response_output_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $transaction->{response_output_complete} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 29 | $self->{_http_response_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 29 | $self->write($wire); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 29 | ▶ | if ($body_done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 22 | ▶ | $transaction->{state} = 'complete' if $transaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 22 | $self->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 29 | ▶ | $self->resume_read if $self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 29 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 4 | ▶ | sub _upgrade_http_transaction ($self, $transaction, $target_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upgrade_http_transaction: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 4 | require Linux::Event::HTTP::_Upgrade; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 4 | Linux::Event::HTTP::_Upgrade->schedule( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | $self, $transaction, $target_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | return $transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 13 | ▶ | sub _tunnel_http_transaction ($self, $transaction, $target_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tunnel_http_transaction: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 13 | require Linux::Event::HTTP::_ServerConnect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 13 | Linux::Event::HTTP::_ServerConnect->schedule( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | $self, $transaction, $target_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | return $transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 54 | ▶ | sub _complete_active_transaction_state ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_complete_active_transaction_state: called CC=7 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 54 | ▶ | my $transaction = $self->{_http_active_transaction} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 17 | ▶ | return if $transaction->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 17 | ▶ | croak 'cannot complete server Transaction before Request body completion' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | if !$transaction->request->is_complete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 17 | my $response = $transaction->response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 17 | ▶ | croak 'cannot complete server Transaction before Response body completion' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$response and $response->is_complete
MC/DC0%0/2
$response and $response->is_complete
$response
$response->is_complete
Truth table33%1/3
A and B
A= $responseB= $response->is_complete
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | if !$response || !$response->is_complete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 17 | ▶ | croak 'cannot complete server Transaction before Response output completion' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | if !$transaction->_is_response_output_complete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 17 | $transaction->_mark_complete; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 38 | ▶ | sub _fail_active_transaction_state ($self, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail_active_transaction_state: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 38 | ▶ | my $transaction = $self->{_http_active_transaction} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 26 | ▶ | return if $transaction->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 13 | $transaction->_fail($error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 13 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 101 | ▶ | sub _clear_transaction ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clear_transaction: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 101 | $self->{_http_active_transaction} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 101 | $self->{_http_active_request} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 101 | $self->{_http_active_response} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 101 | $self->{_http_request_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 101 | $self->{_http_response_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 101 | $self->{_http_response_output_started} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 101 | $self->{_http_response_output_complete} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 101 | delete $self->{_http_pending_upgrade}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 101 | delete $self->{_http_pending_tunnel}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 101 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | sub _cancel_http_transaction ($self, $transaction) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cancel_http_transaction: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | return if $transaction->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $active = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | croak 'cancel(): Transaction is not active on this HTTP connection' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
MC/DC0%0/2
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
not $active
builtin::refaddr($active) != builtin::refaddr($transaction)
Truth table0%0/3
not(A) or B
A= not $activeB= builtin::refaddr($active) != builtin::refaddr($transaction)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | if !$active || refaddr($active) != refaddr($transaction); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $transaction->_mark_cancelled; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $self->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $self->{_http_input} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $self->{_http_closing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $self->end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | sub _abort_started_response ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_abort_started_response: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | return if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $self->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $self->{_http_input} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $self->{_http_closing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $self->end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 18 | ▶ | sub _fail_active_transaction ($self, $status, $request, $response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail_active_transaction: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 18 | ▶ | return if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 18 | my $transaction = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 18 | ▶ | my $started = $self->{_http_response_output_started} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 18 | $self->_fail_active_transaction_state("HTTP server transaction failed ($status)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 18 | ▶ | if ($started) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $self->_abort_started_response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 18 | $self->_protocol_error($status, $request->version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 18 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 23 | ▶ | sub _finish_request_body ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_request_body: called CC=11 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 23 | ▶ | my $request = $self->{_http_active_request} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 23 | ▶ | my $response = $self->{_http_active_response} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 23 | ▶ | my $state = $self->{_http_request_state} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 23 | ▶ | return if $state->{body_done}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 23 | $state->{body_done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 23 | $request->_mark_complete; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 23 | delete $state->{decoder}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 23 | delete $state->{remaining}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | return if !$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 23 | ▶ | $self->{_http_on_request_end}, $request, $response, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 23 | ▶ | return if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_http_closing"} or $self->is_closed
MC/DC50%1/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table66%2/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 20 | ▶ | return if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 6 | ▶ | if ($self->{_http_response_output_complete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 6 | $self->_finalize_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | sub _consume_request_body ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_consume_request_body: not called CC=29 SCAR=67.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | my $request = $self->{_http_active_request} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | my $response = $self->{_http_active_response} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | my $state = $self->{_http_request_state} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | return 0 if $state->{body_done}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | if ($state->{mode} eq 'content-length') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | if (($state->{remaining} // 0) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$state->{"remaining"} // 0
MC/DC0%0/1
$state->{"remaining"} // 0
$state->{"remaining"}
Truth table0%0/2
A
A= $state->{"remaining"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | return 0 if !length($self->{_http_input}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $available = length($self->{_http_input}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | my $take = $available < $state->{remaining} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | ? $available : $state->{remaining}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | my $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if ($self->{_http_on_body}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $chunk = substr($self->{_http_input}, 0, $take, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | substr($self->{_http_input}, 0, $take, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | $state->{remaining} -= $take; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | if (defined($chunk) && length($chunk)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $chunk and length $chunk
MC/DC0%0/2
defined $chunk and length $chunk
defined $chunk
length $chunk
Truth table0%0/3
A and B
A= defined $chunkB= length $chunk
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | return 1 if !$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | $self->{_http_on_body}, $request, $response, $chunk, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | return 1 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | return 1 if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | $self->_finish_request_body if $state->{remaining} == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if ($state->{mode} eq 'chunked') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | return 0 if !length($self->{_http_input}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my ($done, $decoded); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | ($done, $decoded) = $state->{decoder}->feed( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | $self->{_http_input}, $self->{_http_on_body} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $self->_fail_active_transaction(400, $request, $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | if (defined($decoded) && length($decoded)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $decoded and length $decoded
MC/DC0%0/2
defined $decoded and length $decoded
defined $decoded
length $decoded
Truth table0%0/3
A and B
A= defined $decodedB= length $decoded
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | return 1 if !$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | $self->{_http_on_body}, $request, $response, $decoded, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | return 1 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | return 1 if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | $self->_finish_request_body if $done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 38 | ▶ | sub _finalize_transaction ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finalize_transaction: called CC=10 SCAR=23.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 38 | ▶ | return if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 38 | my $request_state = $self->{_http_request_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | my $close_after = $request_state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 38 | ▶ | && $request_state->{close_after_response} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$request_state and $request_state->{"close_after_response"}
MC/DC50%1/2
$request_state and $request_state->{"close_after_response"}
$request_state
$request_state->{"close_after_response"}
Truth table66%2/3
A and B
A= $request_stateB= $request_state->{"close_after_response"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 38 | $self->_complete_active_transaction_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 38 | $self->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 38 | ▶ | if ($close_after) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 5 | $self->{_http_input} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 5 | $self->{_http_closing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 5 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 5 | $self->end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 33 | ▶ | $self->resume_read if $self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | $self->_drive_http1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 33 | ▶ | if !$self->{_http_driving} && !$self->{_http_dispatching}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_http_driving"} or $self->{"_http_dispatching"}
MC/DC50%1/2
$self->{"_http_driving"} or $self->{"_http_dispatching"}
$self->{"_http_driving"}
$self->{"_http_dispatching"}
Truth table66%2/3
A or B
A= $self->{"_http_driving"}B= $self->{"_http_dispatching"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 33 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 122 | ▶ | sub _activate_native_http_request ($self, $request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_activate_native_http_request: called CC=30 SCAR=36.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 122 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | croak 'cannot activate a new HTTP Request while another Request is active' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 122 | ▶ | if $self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 122 | my $expect = $request->_expect_continue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 122 | ▶ | if ($expect < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 2 | $self->_protocol_error(417, $request->version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 120 | my $body_mode = $request->_http1_body_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 120 | my $bodyless = $body_mode eq 'none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 120 | my $response = Linux::Event::HTTP::Response | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | ->_new_server_default($request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 120 | my $request_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 120 | ▶ | if ($bodyless) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 89 | $request_state = $self->{_http_bodyless_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 89 | ▶ | if (!$request_state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | $request_state = $self->{_http_bodyless_state} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | mode => 'none', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 64 | ▶ | body_done => $self->{_http_on_request_end} ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } elsif ($self->{_http_on_request_end}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 7 | $request_state->{body_done} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } elsif ($body_mode eq 'chunked') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 11 | $request_state = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | mode => 'chunked', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | body_done => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 20 | $request_state = _new_request_state($request, $body_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 120 | $self->{_http_active_request} = $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 120 | $self->{_http_active_response} = $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 120 | $self->{_http_request_state} = $request_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 120 | ▶ | if ($expect && _body_pending($request_state)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$expect and _body_pending($request_state)
MC/DC50%1/2
$expect and _body_pending($request_state)
$expect
_body_pending($request_state)
Truth table66%2/3
A and B
A= $expectB= _body_pending($request_state)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 1 | $self->write("HTTP/1.1 100 Continue\r\n\r\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 120 | ▶ | if (!$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | $self->{_http_on_request}, $request, $response, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 16 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 104 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"_http_closing"} or $self->is_closed
MC/DC100%2/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table100%3/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 97 | ▶ | return 1 if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 63 | ▶ | if ($bodyless) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 35 | ▶ | if ($self->{_http_on_request_end}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 32 | $request_state->{body_done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | return 0 if !$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 32 | ▶ | $self->{_http_on_request_end}, $request, $response, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 32 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_http_closing"} or $self->is_closed
MC/DC50%1/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table66%2/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 31 | ▶ | return 1 if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 32 | ▶ | if ($self->{_http_response_output_complete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 25 | $self->_finalize_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 25 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_http_closing"} or $self->is_closed
MC/DC50%1/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table66%2/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 20 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 7 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 7 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 28 | ▶ | if (!_body_pending($request_state)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | return 0 if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | return 1 if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 28 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 29 | ▶ | sub _drive_http1 ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_drive_http1: called CC=37 SCAR=69.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | return if $self->{_http_driving} || $self->{_http_closing} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 29 | ▶ | || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"_http_driving"} or $self->{"_http_closing"} or $self->is_closed
$self->{"_http_driving"} or $self->{"_http_closing"}
MC/DC0%0/3
$self->{"_http_driving"} or $self->{"_http_closing"} or $self->is_closed
$self->{"_http_driving"}
$self->{"_http_closing"}
$self->is_closed
Truth table25%1/4
A or B or C
A= $self->{"_http_driving"}B= $self->{"_http_closing"}C= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 29 | local $self->{_http_driving} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 29 | ▶ | while (!$self->{_http_closing} && !$self->is_closed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 29 | ▶ | if (my $request = $self->{_http_active_request}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | my $response = $self->{_http_active_response}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | my $state = $self->{_http_request_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | my $transaction = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ▶ | if (!$state->{body_done}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | ▶ | if (!_body_pending($state)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | last if !length($self->{_http_input}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $self->_consume_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | if ($self->{_http_response_output_complete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | $self->_finalize_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | $self->pause_read if $response && !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$response and not $self->is_read_paused
MC/DC0%0/2
$response and not $self->is_read_paused
$response
not $self->is_read_paused
Truth table0%0/3
A and not(B)
A= $responseB= not $self->is_read_paused
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 29 | ▶ | last if !length($self->{_http_input}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | my $request = $PARSER->_parse_server_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | $self->{_http_input}, $MAX_REQUEST_HEAD, $MAX_HEADERS, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | if (!defined $request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | if (!ref $request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | $self->_protocol_error(0 + $request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | my $consumed = $request->_consumed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | if ($consumed > $MAX_REQUEST_HEAD) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | $self->_protocol_error(431, $request->version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | substr($self->{_http_input}, 0, $consumed, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my $expect = $request->_expect_continue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | if ($expect < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | $self->_protocol_error(417, $request->version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | my $body_mode = $request->_http1_body_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | my $bodyless = $body_mode eq 'none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | my $response = Linux::Event::HTTP::Response | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | ->_new_server_default($request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my $request_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | if ($bodyless) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | $request_state = $self->{_http_bodyless_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | if (!$request_state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | $request_state = $self->{_http_bodyless_state} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | mode => 'none', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | body_done => $self->{_http_on_request_end} ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } elsif ($self->{_http_on_request_end}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | $request_state->{body_done} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | # Native bodyless Requests are intrinsically complete: Request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | # derives this from the parser's body mode. Do not create a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | # fieldhash completion override for every ordinary request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $request_state = _new_request_state($request, $body_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | # A new request is reached only after the previous exchange was | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | # cleared (or on a freshly initialized Connection), so transaction, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | # response-state, and output-progress fields are already neutral. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | $self->{_http_active_request} = $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $self->{_http_active_response} = $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | $self->{_http_request_state} = $request_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | if ($expect && _body_pending($request_state)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$expect and _body_pending($request_state)
MC/DC0%0/2
$expect and _body_pending($request_state)
$expect
_body_pending($request_state)
Truth table0%0/3
A and B
A= $expectB= _body_pending($request_state)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $self->write("HTTP/1.1 100 Continue\r\n\r\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | if (!$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | $self->{_http_on_request}, $request, $response, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | last if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | ▶ | next if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | ▶ | if ($bodyless) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | if ($self->{_http_on_request_end}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | $request_state->{body_done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | last if !$self->_invoke_http_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | $self->{_http_on_request_end}, $request, $response, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | last if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table0%0/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | next if !$self->{_http_active_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if ($self->{_http_response_output_complete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | $self->_finalize_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | if (!_body_pending($request_state)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | $self->_finish_request_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 29 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 38 | ▶ | sub _body_bytes ($operation, $body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_body_bytes: called CC=5 SCAR=20.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 38 | ▶ | croak "$operation(): body must be a scalar byte string" if ref($body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 38 | ▶ | my $bytes = defined($body) ? "$body" : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 38 | ▶ | if (utf8::is_utf8($bytes)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | croak "$operation(): body contains wide characters; encode it to bytes first" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | if !utf8::downgrade($bytes, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 38 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 21 | ▶ | sub _canonical_decimal ($value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_canonical_decimal: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 21 | ▶ | return undef if !defined($value) || $value !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $value and $value =~ /\A\d+\z/u
MC/DC0%0/2
defined $value and $value =~ /\A\d+\z/u
defined $value
$value =~ /\A\d+\z/u
Truth table33%1/3
A and B
A= defined $valueB= $value =~ /\A\d+\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 21 | my $decimal = "$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 21 | $decimal =~ s/\A0+(?=\d)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 21 | return $decimal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 23 | ▶ | sub _compare_count ($count, $decimal) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare_count: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 23 | my $actual = "$count"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 23 | ▶ | return length($actual) <=> length($decimal) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
length $actual <=> length $decimal || $actual cmp $decimal
MC/DC100%2/2
length $actual <=> length $decimal || $actual cmp $decimal
length $actual <=> length $decimal
$actual cmp $decimal
Truth table100%3/3
A || B
A= length $actual <=> length $decimalB= $actual cmp $decimal
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | || $actual cmp $decimal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 12 | ▶ | sub _chunk_wire ($bytes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_chunk_wire: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 12 | ▶ | return '' if !length($bytes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 11 | return sprintf('%x', length($bytes)) . "\r\n" . $bytes . "\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 28 | ▶ | sub _chunked_transfer_encoding ($operation, $version, $values) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_chunked_transfer_encoding: called CC=9 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 28 | ▶ | return 0 if !@$values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | croak "$operation(): Transfer-Encoding is not valid for HTTP/1.0 responses" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | if $version ne '1.1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | my @coding; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | for my $value (@$values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | for my $member (split /,/, $value, -1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | $member =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $member =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | croak "$operation(): invalid Transfer-Encoding response value" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$member eq "" or $member =~ /;/u
MC/DC0%0/2
$member eq "" or $member =~ /;/u
$member eq ""
$member =~ /;/u
Truth table0%0/3
A or B
A= $member eq ""B= $member =~ /;/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | if $member eq '' || $member =~ /;/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | push @coding, lc $member; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | croak "$operation(): only chunked response Transfer-Encoding is supported" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@coding != 1 or $coding[0] ne "chunked"
MC/DC0%0/2
@coding != 1 or $coding[0] ne "chunked"
@coding != 1
$coding[0] ne "chunked"
Truth table0%0/3
A or B
A= @coding != 1B= $coding[0] ne "chunked"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | if @coding != 1 || $coding[0] ne 'chunked'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 28 | ▶ | sub _response_start ($self, $response, $bytes, $final, $operation = undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_response_start: called CC=44 SCAR=42.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 28 | my $transaction = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | my $request = $self->{_http_active_request} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 28 | ▶ | or croak 'response output requires an active HTTP Request'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 28 | my $version = $request->version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 28 | my $method = $request->method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 28 | my $status = $response->status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 28 | ▶ | $operation //= $final ? 'complete' : 'write'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$operation //= $final ? "complete" : "write"
MC/DC0%0/2
$operation //= $final ? "complete" : "write"
$operation
$final ? "complete" : "write"
Truth table33%1/3
A //= B
A= $operationB= $final ? "complete" : "write"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 28 | ▶ | croak "$operation(): informational responses require a future interim-response API" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$status >= 100 and $status < 200
MC/DC0%0/2
$status >= 100 and $status < 200
$status >= 100
$status < 200
Truth table33%1/3
A and B
A= $status >= 100B= $status < 200
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | if $status >= 100 && $status < 200; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 28 | ▶ | my $body_forbidden = $status == 204 || $status == 304; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$status == 204 || $status == 304
MC/DC0%0/2
$status == 204 || $status == 304
$status == 204
$status == 304
Truth table33%1/3
A || B
A= $status == 204B= $status == 304
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 28 | ▶ | croak "$operation(): this response status cannot carry a message body" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$body_forbidden and length $bytes
MC/DC0%0/2
$body_forbidden and length $bytes
$body_forbidden
length $bytes
Truth table33%1/3
A and B
A= $body_forbiddenB= length $bytes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | if $body_forbidden && length($bytes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 28 | my @transfer_encoding = $response->_header_values_list('Transfer-Encoding'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 28 | my @content_length = $response->_header_values_list('Content-Length'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 28 | my $head_request = $method eq 'HEAD'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 28 | ▶ | croak "$operation(): response cannot contain both Transfer-Encoding and Content-Length" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@transfer_encoding and @content_length
MC/DC0%0/2
@transfer_encoding and @content_length
@transfer_encoding
@content_length
Truth table33%1/3
A and B
A= @transfer_encodingB= @content_length
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | if @transfer_encoding && @content_length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 28 | ▶ | croak "$operation(): HEAD responses cannot use a streaming body" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $final and $head_request
MC/DC0%0/2
not $final and $head_request
not $final
$head_request
Truth table66%2/3
not(A) and B
A= not $finalB= $head_request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | if !$final && $head_request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 28 | ▶ | croak "$operation(): this response status cannot use body streaming" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $final and $body_forbidden
MC/DC0%0/2
not $final and $body_forbidden
not $final
$body_forbidden
Truth table66%2/3
not(A) and B
A= not $finalB= $body_forbidden
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | if !$final && $body_forbidden; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 28 | my $chunked = _chunked_transfer_encoding( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | $operation, $version, \@transfer_encoding, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 28 | my $close_delimited = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 28 | ▶ | if (!@content_length && !$body_forbidden && !$chunked) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@content_length or $body_forbidden or $chunked
@content_length or $body_forbidden
MC/DC33%1/3
@content_length or $body_forbidden or $chunked
@content_length
$body_forbidden
$chunked
Truth table50%2/4
A or B or C
A= @content_lengthB= $body_forbiddenC= $chunked
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 26 | ▶ | if ($final) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 19 | $response->header('Content-Length', length($bytes)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 19 | @content_length = $response->_header_values_list('Content-Length'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } elsif ($version eq '1.1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 5 | $response->header('Transfer-Encoding', 'chunked'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 5 | $chunked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 2 | $close_delimited = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 28 | my $expected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 28 | ▶ | if (@content_length == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 21 | $expected = _canonical_decimal($content_length[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 21 | ▶ | croak "$operation(): Content-Length must be a decimal number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | if !defined $expected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 28 | ▶ | if ($final && !$head_request && !$body_forbidden && defined $expected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$final and not $head_request and not $body_forbidden and defined $expected
$final and not $head_request and not $body_forbidden
$final and not $head_request
MC/DC25%1/4
$final and not $head_request and not $body_forbidden and defined $expected
$final
not $head_request
not $body_forbidden
defined $expected
Truth table40%2/5
A and not(B) and not(C) and D
A= $finalB= not $head_requestC= not $body_forbiddenD= defined $expected
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 20 | ▶ | croak "$operation(): Content-Length does not match scalar body length" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | if _compare_count(length($bytes), $expected) != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 27 | ▶ | if (!$final && defined $expected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $final and defined $expected and _compare_count(length $bytes, $expected) > 0
not $final and defined $expected
MC/DC0%0/3
not $final and defined $expected and _compare_count(length $bytes, $expected) > 0
not $final
defined $expected
_compare_count(length $bytes, $expected) > 0
Truth table75%3/4
not(A) and B and C
A= not $finalB= defined $expectedC= _compare_count(length $bytes, $expected) > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | && _compare_count(length($bytes), $expected) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | croak "$operation(): response body exceeds Content-Length"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 27 | my @connection = $response->_header_values_list('Connection'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 27 | my $keep_alive = $request->_http1_keep_alive; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 27 | ▶ | my $close_after = !$keep_alive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
!$keep_alive || _has_connection_token(\@connection, 'close') || $close_delimited
not $keep_alive or _has_connection_token(\@connection, "close")
MC/DC100%3/3
!$keep_alive || _has_connection_token(\@connection, 'close') || $close_delimited
not $keep_alive
_has_connection_token(\@connection, "close")
$close_delimited
Truth table100%4/4
not(A) or B || C
A= not $keep_aliveB= _has_connection_token(\@connection, "close")C= $close_delimited
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | || _has_connection_token(\@connection, 'close') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | || $close_delimited; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 27 | ▶ | if (!$keep_alive && $version eq '1.1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
not $keep_alive and $version eq "1.1"
MC/DC100%2/2
not $keep_alive and $version eq "1.1"
not $keep_alive
$version eq "1.1"
Truth table100%3/3
not(A) and B
A= not $keep_aliveB= $version eq "1.1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 12 | $response->header('Connection', 'close'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 12 | $close_after = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | ▶ | } elsif ($keep_alive && $version eq '1.0' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition77%7/9
$keep_alive and $version eq "1.0" and not @connection and not $close_after
$keep_alive and $version eq "1.0" and not @connection
$keep_alive and $version eq "1.0"
MC/DC0%0/4
$keep_alive and $version eq "1.0" and not @connection and not $close_after
$keep_alive
$version eq "1.0"
not @connection
not $close_after
Truth table60%3/5
A and B and not(C) and not(D)
A= $keep_aliveB= $version eq "1.0"C= not @connectionD= not $close_after
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | && !@connection && !$close_after) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | $response->header('Connection', 'keep-alive'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 27 | my $head = $response->_serialize_head($version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 27 | $response->_commit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 27 | $self->{_http_response_output_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 27 | ▶ | $transaction->_mark_response_started if $transaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 27 | ▶ | expected => $expected, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$head_request or $body_forbidden
MC/DC0%0/2
$head_request or $body_forbidden
$head_request
$body_forbidden
Truth table33%1/3
A or B
A= $head_requestB= $body_forbidden
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | sent => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | suppress_body => $head_request || $body_forbidden ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | close_after => $close_after ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | chunked => $chunked ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | $head, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 18 | ▶ | sub _write_http_response_body ($self, $transaction, $body, $final, $operation) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_http_response_body: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 18 | my $active = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 18 | ▶ | croak "$operation(): Transaction is not active on this HTTP connection" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
MC/DC0%0/2
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
not $active
builtin::refaddr($active) != builtin::refaddr($transaction)
Truth table33%1/3
not(A) or B
A= not $activeB= builtin::refaddr($active) != builtin::refaddr($transaction)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | if !$active || refaddr($active) != refaddr($transaction); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 18 | ▶ | my $response = $transaction->response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | or croak "$operation(): Transaction has no Response"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 18 | return $self->_write_response( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | $response, $body, $final, $operation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 38 | ▶ | sub _write_response ($self, $response, $body, $final, $operation = undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_response: called CC=22 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 38 | ▶ | $operation //= $final ? 'complete' : 'write'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$operation //= $final ? "complete" : "write"
MC/DC0%0/2
$operation //= $final ? "complete" : "write"
$operation
$final ? "complete" : "write"
Truth table33%1/3
A //= B
A= $operationB= $final ? "complete" : "write"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | croak "$operation(): connection is closing or closed" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 38 | ▶ | if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 38 | my $active = $self->{_http_active_response}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 38 | ▶ | croak "$operation(): this Response is not the active HTTP transaction" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $active or builtin::refaddr($active) != builtin::refaddr($response)
MC/DC0%0/2
not $active or builtin::refaddr($active) != builtin::refaddr($response)
not $active
builtin::refaddr($active) != builtin::refaddr($response)
Truth table33%1/3
not(A) or B
A= not $activeB= builtin::refaddr($active) != builtin::refaddr($response)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | if !$active || refaddr($active) != refaddr($response); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 38 | my $bytes = _body_bytes($operation, $body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 38 | my $state = $self->{_http_response_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 38 | ▶ | if (!$state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 28 | my ($created, $head) = $self->_response_start( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | $response, $bytes, $final, $operation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 27 | $state = $self->{_http_response_state} = $created; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 27 | ▶ | if ($final) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 19 | my $wire_body = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 19 | ▶ | if (!$state->{suppress_body}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | $wire_body = $state->{chunked} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 19 | ▶ | ? _chunk_wire($bytes) . "0\r\n\r\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | : $bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | return $self->_complete_response( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | $response, $head . $wire_body, $state->{close_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 19 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 8 | $state->{sent} = length($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 8 | ▶ | my $wire_body = $state->{chunked} ? _chunk_wire($bytes) : $bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 8 | return $self->write($head . $wire_body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 10 | my $new_sent = $state->{sent} + length($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 10 | ▶ | if (defined($state->{expected}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $state->{"expected"} and _compare_count($new_sent, $state->{"expected"}) > 0
MC/DC0%0/2
defined $state->{"expected"} and _compare_count($new_sent, $state->{"expected"}) > 0
defined $state->{"expected"}
_compare_count($new_sent, $state->{"expected"}) > 0
Truth table66%2/3
A and B
A= defined $state->{"expected"}B= _compare_count($new_sent, $state->{"expected"}) > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | && _compare_count($new_sent, $state->{expected}) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | croak "$operation(): response body exceeds Content-Length"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 10 | ▶ | if ($final && defined($state->{expected}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$final and defined $state->{"expected"} and _compare_count($new_sent, $state->{"expected"}) != 0
$final and defined $state->{"expected"}
MC/DC0%0/3
$final and defined $state->{"expected"} and _compare_count($new_sent, $state->{"expected"}) != 0
$final
defined $state->{"expected"}
_compare_count($new_sent, $state->{"expected"}) != 0
Truth table75%3/4
A and B and C
A= $finalB= defined $state->{"expected"}C= _compare_count($new_sent, $state->{"expected"}) != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | && _compare_count($new_sent, $state->{expected}) != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | croak "$operation(): response body length does not match Content-Length"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 10 | $state->{sent} = $new_sent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 10 | ▶ | if ($final) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | my $wire = $state->{chunked} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 8 | ▶ | ? _chunk_wire($bytes) . "0\r\n\r\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | : $bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | return $self->_complete_response( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | $response, $wire, $state->{close_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 2 | ▶ | my $wire = $state->{chunked} ? _chunk_wire($bytes) : $bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 2 | ▶ | return length($wire) ? $self->write($wire) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 27 | ▶ | sub _complete_response ($self, $response, $wire, $close_after) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_complete_response: called CC=13 SCAR=25.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 27 | my $transaction = $self->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 27 | $self->{_http_response_output_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 27 | $self->{_http_response_output_complete} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 27 | ▶ | $transaction->_mark_response_output_complete if $transaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 27 | $self->{_http_response_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 27 | my $request_state = $self->{_http_request_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 27 | ▶ | if ($close_after && $request_state && !$request_state->{body_done}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$close_after and $request_state and not $request_state->{"body_done"}
$close_after and $request_state
MC/DC66%2/3
$close_after and $request_state and not $request_state->{"body_done"}
$close_after
$request_state
not $request_state->{"body_done"}
Truth table75%3/4
A and B and not(C)
A= $close_afterB= $request_stateC= not $request_state->{"body_done"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 5 | $request_state->{close_after_response} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 5 | ▶ | my $accepted = length($wire) ? $self->write($wire) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 5 | ▶ | $self->resume_read if $self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 5 | return $accepted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 22 | ▶ | if ($close_after) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 12 | $self->_complete_active_transaction_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 12 | $self->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 12 | $self->{_http_closing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 12 | $self->{_http_input} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 12 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 12 | $self->end($wire); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 12 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 10 | ▶ | my $accepted = length($wire) ? $self->write($wire) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 10 | ▶ | if ($request_state && $request_state->{body_done}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$request_state and $request_state->{"body_done"}
MC/DC50%1/2
$request_state and $request_state->{"body_done"}
$request_state
$request_state->{"body_done"}
Truth table66%2/3
A and B
A= $request_stateB= $request_state->{"body_done"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 7 | $self->_finalize_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 3 | ▶ | $self->resume_read if $self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 10 | return $accepted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 13 | ▶ | sub _has_connection_token ($values, $wanted) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_connection_token: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 13 | for my $value (@$values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 2 | for my $token (split /,/, $value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 2 | $token =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 2 | $token =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 2 | ▶ | return 1 if lc($token) eq $wanted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 11 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 20 | ▶ | sub _protocol_error ($self, $status, $version = '1.1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_protocol_error: called CC=7 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 20 | ▶ | return if $self->{_http_closing} || $self->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_http_closing"} or $self->is_closed
MC/DC0%0/2
$self->{"_http_closing"} or $self->is_closed
$self->{"_http_closing"}
$self->is_closed
Truth table33%1/3
A or B
A= $self->{"_http_closing"}B= $self->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 20 | ▶ | $version = '1.1' if $version ne '1.0' && $version ne '1.1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$version ne "1.0" and $version ne "1.1"
MC/DC0%0/2
$version ne "1.0" and $version ne "1.1"
$version ne "1.0"
$version ne "1.1"
Truth table66%2/3
A and B
A= $version ne "1.0"B= $version ne "1.1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 20 | my $response = Linux::Event::HTTP::Response->_new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | status => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | headers => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | [ 'Content-Length', '0' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | [ 'Connection', 'close' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 20 | my $head = $response->_serialize_head($version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 20 | $self->_fail_active_transaction_state("HTTP protocol error ($status)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 20 | $self->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 20 | $self->{_http_input} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 20 | $self->{_http_closing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 20 | ▶ | $self->pause_read if !$self->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 20 | $self->end($head); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | ▶ | sub CLONE ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | %CLASS_HANDLER = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | Linux::Event::_Socket::Stream::CLONE($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | sub CLONE_SKIP ($class) { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 25 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||