| 1 | package Unblock::HTTP2::Transaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 29 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 29 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 29 | ▶ | use Scalar::Util qw(blessed weaken); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 29 | ▶ | use Uniform::HTTP::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 29 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 29 | my %TERMINAL = map { $_ => 1 } qw(complete cancelled error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 94 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=12 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 94 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 94 | my $connection = delete $args{connection}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 94 | my $stream_id = delete $args{stream_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 94 | my $request = delete $args{request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 94 | ▶ | my $callbacks = delete($args{callbacks}) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'callbacks'} || {}
MC/DC0%0/1
delete $args{'callbacks'} || {}
delete $args{'callbacks'}
Truth table50%1/2
A
A= delete $args{'callbacks'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 94 | ▶ | croak 'Transaction requires a connection object' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | unless blessed($connection); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 94 | ▶ | croak 'Transaction stream id must be a positive integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $stream_id and not ref $stream_id and $stream_id =~ /\A[0-9]+\z/ and $stream_id > 0
defined $stream_id and not ref $stream_id and $stream_id =~ /\A[0-9]+\z/
defined $stream_id and not ref $stream_id
MC/DC0%0/4
defined $stream_id and not ref $stream_id and $stream_id =~ /\A[0-9]+\z/ and $stream_id > 0
defined $stream_id
not ref $stream_id
$stream_id =~ /\A[0-9]+\z/
$stream_id > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $stream_idB= not ref $stream_idC= $stream_id =~ /\A[0-9]+\z/D= $stream_id > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | unless defined($stream_id) && !ref($stream_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | && $stream_id =~ /\A[0-9]+\z/ && $stream_id > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 94 | ▶ | croak 'Transaction callbacks must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | unless ref($callbacks) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 94 | ▶ | croak 'unknown Transaction option: ' . join(', ', sort keys %args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | if %args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 94 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | connection => $connection, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | stream_id => 0 + $stream_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | request => $request, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | response => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | callbacks => { %$callbacks }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | state => 'active', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | error => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | error_code => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | reset_by_peer => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | auto_consume => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | unconsumed_bytes => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 94 | $self->{receive_body} = $connection->{receive_body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 94 | $self->{max_buffered_body_bytes} = $connection->{max_buffered_body_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 94 | my $on_data = delete $self->{callbacks}{on_data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 94 | ▶ | $self->on_data($on_data) if $on_data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | croak 'buffered reception cannot be combined with on_body' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 94 | ▶ | if $self->{receive_body} eq 'buffered' && $self->{callbacks}{on_body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"receive_body"} eq "buffered" and $self->{"callbacks"}{"on_body"}
MC/DC0%0/2
$self->{"receive_body"} eq "buffered" and $self->{"callbacks"}{"on_body"}
$self->{"receive_body"} eq "buffered"
$self->{"callbacks"}{"on_body"}
Truth table66%2/3
A and B
A= $self->{"receive_body"} eq "buffered"B= $self->{"callbacks"}{"on_body"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 94 | weaken($self->{connection}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 94 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 266 | ▶ | sub stream_id { return $_[0]{stream_id} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stream_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 188 | ▶ | sub request { return $_[0]{request} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 47 | ▶ | sub response { return $_[0]{response} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 23 | ▶ | sub state { return $_[0]{state} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | sub error { return $_[0]{error} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | sub error_code { return $_[0]{error_code} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_code: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | sub reset_by_peer { return $_[0]{reset_by_peer} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_by_peer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | sub error_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_name: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | return unless defined $self->{error_code}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | require Unblock::HTTP2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | return Unblock::HTTP2->error_name($self->{error_code}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | ▶ | sub unconsumed_bytes { return $_[0]{unconsumed_bytes} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unconsumed_bytes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 13 | ▶ | sub is_complete { return $_[0]{state} eq 'complete' ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_complete: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | ▶ | sub is_cancelled { return $_[0]{state} eq 'cancelled' ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_cancelled: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | ▶ | sub is_error { return $_[0]{state} eq 'error' ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_error: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 582 | ▶ | sub is_terminal { return $TERMINAL{$_[0]{state}} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_terminal: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | ▶ | sub on_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_data: called CC=9 SCAR=24.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | my ($self, $cb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | ▶ | croak 'on_data(): callback must be a coderef' unless ref($cb) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | croak 'on_data(): receive body has already started or finished' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | ▶ | if $self->{receive_started} || $self->{receive_done} || $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->{"receive_started"} or $self->{"receive_done"} or $self->is_terminal
$self->{"receive_started"} or $self->{"receive_done"}
MC/DC33%1/3
$self->{"receive_started"} or $self->{"receive_done"} or $self->is_terminal
$self->{"receive_started"}
$self->{"receive_done"}
$self->is_terminal
Truth table50%2/4
A or B or C
A= $self->{"receive_started"}B= $self->{"receive_done"}C= $self->is_terminal
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | my $owner = $self->{connection}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | croak 'on_data(): cannot be combined with on_body' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | if $self->{callbacks}{on_body} || ($owner && $owner->{callbacks}{on_body}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"callbacks"}{"on_body"} or $owner and $owner->{"callbacks"}{"on_body"}
$owner and $owner->{"callbacks"}{"on_body"}
MC/DC0%0/3
$self->{"callbacks"}{"on_body"} or $owner and $owner->{"callbacks"}{"on_body"}
$self->{"callbacks"}{"on_body"}
$owner
$owner->{"callbacks"}{"on_body"}
Truth table25%1/4
A or B and C
A= $self->{"callbacks"}{"on_body"}B= $ownerC= $owner->{"callbacks"}{"on_body"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | croak 'on_data(): callback is already registered' if $self->{callbacks}{on_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | $self->{callbacks}{on_data} = $cb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | $self->{receive_body} = 'stream'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 13 | ▶ | sub on_finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_finish: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 13 | my ($self, $cb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 13 | ▶ | croak 'on_finish(): callback must be a coderef' unless ref($cb) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 13 | ▶ | croak 'on_finish(): Transaction is terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 13 | ▶ | croak 'on_finish(): callback is already registered' if $self->{callbacks}{on_finish}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 13 | $self->{callbacks}{on_finish} = $cb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 69 | ▶ | sub _receive_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_receive_data: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 69 | my ($self, $message, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 69 | ▶ | return 1 if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 69 | $self->{receive_started} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 69 | ▶ | if ($self->{receive_body} eq 'buffered') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 13 | ▶ | my $size = ($self->{received_bytes} || 0) + length($bytes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'received_bytes'} || 0
MC/DC100%1/1
$self->{'received_bytes'} || 0
$self->{'received_bytes'}
Truth table100%2/2
A
A= $self->{'received_bytes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 13 | ▶ | if ($size > $self->{max_buffered_body_bytes}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | delete $self->{receive_chunks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | delete $self->{received_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | return 'received body exceeds max_buffered_body_bytes'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 11 | push @{ $self->{receive_chunks} }, $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 11 | $self->{received_bytes} = $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 11 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 56 | ▶ | return $self->_invoke('on_data', $bytes) if $self->{callbacks}{on_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 53 | my $owner = $self->{connection}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 53 | ▶ | return $owner->_invoke_callback('on_body', $self, $message, $bytes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$owner and $owner->can("_invoke_callback")
MC/DC50%1/2
$owner and $owner->can("_invoke_callback")
$owner
$owner->can("_invoke_callback")
Truth table66%2/3
A and B
A= $ownerB= $owner->can("_invoke_callback")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | if $owner && $owner->can('_invoke_callback'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 34 | return $self->_invoke('on_body', $message, $bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 67 | ▶ | sub _finish_receive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_receive: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 67 | my ($self, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 67 | $self->{receive_done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 67 | ▶ | if ($self->{receive_body} eq 'buffered' && $message->body_is_mutable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"receive_body"} eq "buffered" and $message->body_is_mutable
MC/DC100%2/2
$self->{"receive_body"} eq "buffered" and $message->body_is_mutable
$self->{"receive_body"} eq "buffered"
$message->body_is_mutable
Truth table100%3/3
A and B
A= $self->{"receive_body"} eq "buffered"B= $message->body_is_mutable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 9 | ▶ | $message->body(join '', @{ delete($self->{receive_chunks}) || [] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $self->{'receive_chunks'} || []
MC/DC0%0/1
delete $self->{'receive_chunks'} || []
delete $self->{'receive_chunks'}
Truth table50%1/2
A
A= delete $self->{'receive_chunks'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 67 | delete $self->{receive_chunks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 67 | delete $self->{received_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 67 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 92 | ▶ | sub _notify_finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_notify_finish: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 92 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 92 | ▶ | return unless $self->is_terminal && !$self->{finish_called}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->is_terminal and not $self->{"finish_called"}
MC/DC0%0/2
$self->is_terminal and not $self->{"finish_called"}
$self->is_terminal
not $self->{"finish_called"}
Truth table33%1/3
A and not(B)
A= $self->is_terminalB= not $self->{"finish_called"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 92 | $self->{finish_pending} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 92 | ▶ | return if $self->{callback_depth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 88 | $self->{finish_called} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 88 | delete $self->{finish_pending}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # Terminal observers cannot undo cleanup or recursively report an error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 88 | $self->_invoke('on_finish'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 88 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 11 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 11 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 11 | ▶ | croak 'write(): Transaction is already terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 11 | ▶ | or croak 'write(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 11 | return $connection->_write_stream_body($self, $bytes, 0, 'write'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 9 | ▶ | sub end { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 9 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 9 | ▶ | croak 'end(): accepts at most one final byte string' if @args > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 9 | ▶ | croak 'end(): Transaction is already terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 9 | ▶ | or croak 'end(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 9 | ▶ | my $bytes = @args ? $args[0] : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 9 | $connection->_write_stream_body($self, $bytes, 1, 'end'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | ▶ | sub send_informational { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_informational: called CC=6 SCAR=18.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | my ($self, @arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | my $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | ▶ | if (@arg == 1 && ref($arg[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@arg == 1 and ref $arg[0]
MC/DC50%1/2
@arg == 1 and ref $arg[0]
@arg == 1
ref $arg[0]
Truth table66%2/3
A and B
A= @arg == 1B= ref $arg[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | $response = $arg[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | croak 'send_informational(): fields must be key/value pairs' if @arg % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | $response = Uniform::HTTP::Response->new(@arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ▶ | croak 'send_informational(): Transaction is already terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | ▶ | or croak 'send_informational(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | $connection->_send_informational_stream($self, $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 32 | ▶ | sub respond { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
respond: called CC=9 SCAR=22.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 32 | my ($self, @arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 32 | my ($response, %option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 32 | ▶ | if (@arg && ref($arg[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@arg and ref $arg[0]
MC/DC50%1/2
@arg and ref $arg[0]
@arg
ref $arg[0]
Truth table66%2/3
A and B
A= @argB= ref $arg[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 23 | $response = shift @arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 23 | ▶ | croak 'respond(): options must be key/value pairs' if @arg % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 23 | %option = @arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 9 | ▶ | croak 'respond(): fields must be key/value pairs' if @arg % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 9 | my %field = @arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 9 | for my $name (qw(stream_body on_drain on_error)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 27 | ▶ | $option{$name} = delete $field{$name} if exists $field{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 9 | $response = Uniform::HTTP::Response->new(%field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 32 | ▶ | croak 'respond(): Transaction is already terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 32 | ▶ | or croak 'respond(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 32 | $connection->_respond_stream($self, $response, %option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 32 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | ▶ | sub update_priority { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_priority: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | my ($self, $field_value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | ▶ | croak 'update_priority(): Transaction is already terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | ▶ | or croak 'update_priority(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 4 | $connection->_update_stream_priority($self, $field_value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 7 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=7 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 7 | my ($self, $error_code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 7 | ▶ | croak 'reset(): Transaction is already terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 7 | ▶ | croak 'reset(): error code must be an unsigned 32-bit integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/
defined $error_code and not ref $error_code
MC/DC25%1/4
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295
defined $error_code
not ref $error_code
"$error_code" =~ /\A[0-9]+\z/
$error_code <= 4294967295
Truth table40%2/5
A and not(B) and C and D
A= defined $error_codeB= not ref $error_codeC= "$error_code" =~ /\A[0-9]+\z/D= $error_code <= 4294967295
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | unless defined($error_code) && !ref($error_code) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | && "$error_code" =~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | && $error_code <= 4_294_967_295; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 6 | ▶ | or croak 'reset(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 6 | $connection->_reset_stream($self, 0 + $error_code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 6 | ▶ | sub cancel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cancel: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 6 | ▶ | return $self if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 5 | ▶ | if (!$self->{connection}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $self->_mark_cancelled(8, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->_notify_finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 5 | return $self->reset(8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 6 | ▶ | sub auto_consume { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_consume: called CC=13 SCAR=27.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 6 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | ▶ | return $self->{auto_consume} ? 1 : 0 unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | ▶ | croak 'auto_consume(): accepts exactly one zero-or-one value' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | ▶ | croak 'auto_consume(): Transaction is already terminal' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | my $value = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | ▶ | croak 'auto_consume(): value must be zero or one' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $value or ref $value or not "$value" =~ /\A[01]\z/
not defined $value or ref $value
MC/DC0%0/3
not defined $value or ref $value or not "$value" =~ /\A[01]\z/
not defined $value
ref $value
not "$value" =~ /\A[01]\z/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $valueB= ref $valueC= not "$value" =~ /\A[01]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | if !defined($value) || ref($value) || "$value" !~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 3 | ▶ | $value = $value ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | ▶ | if ($value && !$self->{auto_consume} && $self->{unconsumed_bytes}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$value and not $self->{"auto_consume"} and $self->{"unconsumed_bytes"}
$value and not $self->{"auto_consume"}
MC/DC33%1/3
$value and not $self->{"auto_consume"} and $self->{"unconsumed_bytes"}
$value
not $self->{"auto_consume"}
$self->{"unconsumed_bytes"}
Truth table50%2/4
A and not(B) and C
A= $valueB= not $self->{"auto_consume"}C= $self->{"unconsumed_bytes"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | ▶ | or croak 'auto_consume(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | my $bytes = $self->{unconsumed_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | $connection->_consume_stream_body($self, $bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | $self->{unconsumed_bytes} -= $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | $self->{auto_consume} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 6 | ▶ | sub consume { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consume: called CC=8 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 6 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 6 | ▶ | croak 'consume(): Transaction is already terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 6 | ▶ | croak 'consume(): bytes must be a non-negative integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $bytes and not ref $bytes and "$bytes" =~ /\A[0-9]+\z/
defined $bytes and not ref $bytes
MC/DC0%0/3
defined $bytes and not ref $bytes and "$bytes" =~ /\A[0-9]+\z/
defined $bytes
not ref $bytes
"$bytes" =~ /\A[0-9]+\z/
Truth table25%1/4
A and not(B) and C
A= defined $bytesB= not ref $bytesC= "$bytes" =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | unless defined($bytes) && !ref($bytes) && "$bytes" =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 6 | $bytes = 0 + $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | croak 'consume(): cannot consume more bytes than have been delivered' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 6 | ▶ | if $bytes > $self->{unconsumed_bytes}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 5 | ▶ | return $self unless $bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 5 | ▶ | or croak 'consume(): HTTP/2 connection is no longer available'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 5 | $connection->_consume_stream_body($self, $bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | $self->{unconsumed_bytes} -= $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 69 | ▶ | sub _receive_body_bytes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_receive_body_bytes: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 69 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 69 | ▶ | $self->{unconsumed_bytes} += $bytes if $bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 69 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 67 | ▶ | sub _auto_consume_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_auto_consume_body: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 67 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 67 | ▶ | return $self unless $self->{auto_consume}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 60 | ▶ | return $self unless $self->{unconsumed_bytes}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 60 | ▶ | return $self if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 59 | ▶ | my $connection = $self->{connection} or return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 59 | my $bytes = $self->{unconsumed_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 59 | $connection->_consume_stream_body($self, $bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 59 | $self->{unconsumed_bytes} -= $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 59 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | ▶ | sub _set_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_callback: called CC=4 SCAR=15.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | my ($self, $name, $callback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 2 | ▶ | croak "_set_callback(): callback must be a coderef" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $callback and ref $callback ne "CODE"
MC/DC0%0/2
defined $callback and ref $callback ne "CODE"
defined $callback
ref $callback ne "CODE"
Truth table33%1/3
A and B
A= defined $callbackB= ref $callback ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | if defined($callback) && ref($callback) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | ▶ | if ($callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | $self->{callbacks}{$name} = $callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | delete $self->{callbacks}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 64 | ▶ | sub _set_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_response: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 64 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 64 | ▶ | croak 'Transaction already has a Response' if $self->{response}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 64 | $self->{response} = $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 64 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 63 | ▶ | sub _mark_complete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_complete: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 63 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 63 | ▶ | return $self if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 63 | $self->{state} = 'complete'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 63 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | ▶ | sub _mark_cancelled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_cancelled: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 6 | my ($self, $error_code, $by_peer) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 6 | ▶ | return $self if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 6 | delete $self->{receive_chunks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 6 | delete $self->{received_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 6 | $self->{state} = 'cancelled'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 6 | ▶ | if (defined $error_code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 6 | $self->{error_code} = 0 + $error_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 6 | ▶ | $self->{reset_by_peer} = $by_peer ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 19 | ▶ | sub _fail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 19 | my ($self, $error, $error_code, $by_peer) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 19 | ▶ | return $self if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 19 | ▶ | $error = 'HTTP/2 stream failed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $error and length $error
MC/DC0%0/2
defined $error and length $error
defined $error
length $error
Truth table33%1/3
A and B
A= defined $errorB= length $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | unless defined($error) && length($error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 19 | delete $self->{receive_chunks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 19 | delete $self->{received_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 19 | $self->{state} = 'error'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 19 | $self->{error} = "$error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 19 | ▶ | if (defined $error_code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 13 | $self->{error_code} = 0 + $error_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 13 | ▶ | $self->{reset_by_peer} = $by_peer ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 19 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 213 | ▶ | sub _invoke { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invoke: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 213 | my ($self, $name, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 213 | ▶ | my $callback = $self->{callbacks}{$name} or return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 99 | $self->{callback_depth}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 99 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 99 | $callback->($self, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 99 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 99 | my $error = "$@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 99 | $self->{callback_depth}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 99 | ▶ | $self->_notify_finish if $self->{finish_pending}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 99 | ▶ | return $ok ? 1 : $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 3 | ▶ | sub _drain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_drain: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 3 | my $result = $self->_invoke('on_drain'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 3 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 29 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||