| 1 | package Linux::Event::HTTP::Server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 19 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 19 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 19 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 19 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 19 | ▶ | use Linux::Event::IO::Sock::Listener; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 19 | ▶ | use Linux::Event::HTTP::Server::Connection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 19 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 67 | ▶ | sub _load_connection_class ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_connection_class: called CC=6 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 67 | ▶ | croak 'new(): connection_class must be a package name' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $class or ref $class or not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
not defined $class or ref $class
MC/DC0%0/3
not defined $class or ref $class or not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
not defined $class
ref $class
not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $classB= ref $classC= not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | if !defined($class) || ref($class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | || $class !~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 67 | ▶ | if (!$class->can('new')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | (my $file = "$class.pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | require $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 67 | ▶ | croak 'new(): connection_class must inherit Linux::Event::HTTP::Server::Connection' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | if !$class->isa('Linux::Event::HTTP::Server::Connection'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 67 | return $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 670 | ▶ | sub _take_callback ($name, $option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_take_callback: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 670 | ▶ | return undef if !exists $option->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 36 | my $callback = delete $option->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 36 | ▶ | croak "new(): $name must be a coderef" if ref($callback) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 35 | return $callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub _http2_available () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http2_available: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return 0 if !eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | require Net::HTTP2::nghttp2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | Net::HTTP2::nghttp2->VERSION('0.011'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | require Linux::Event::HTTP::_HTTP2::Server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | require Linux::Event::HTTP::_HTTP2::ServerConnection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return Net::HTTP2::nghttp2->available ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub _http2_ready ($conn, $user_ready, $max_header_list_size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http2_ready: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (($conn->selected_alpn // '') ne 'h2') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$conn->selected_alpn // ""
MC/DC0%0/1
$conn->selected_alpn // ""
$conn->selected_alpn
Truth table0%0/2
A
A= $conn->selected_alpn
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $user_ready->($conn) if $user_ready; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $conn->pause_read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | $conn->loop->defer(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | return if $conn->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | my $executor = Linux::Event::HTTP::_HTTP2::Server->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | stream => $conn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | connection => $conn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | autostart => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | on_request => $conn->{_http_on_request}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | on_body => $conn->{_http_on_body}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | on_request_end => $conn->{_http_on_request_end}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | max_header_list_size => $max_header_list_size, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $conn->{_http2_executor} = $executor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $conn->transition_to( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 'Linux::Event::HTTP::_HTTP2::ServerConnection', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $executor->start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $user_ready->($conn) if $user_ready; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $conn->resume_read if $conn->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 69 | ▶ | sub new ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=38 SCAR=45.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | croak 'new(): stream_class is internal; use connection_class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 69 | ▶ | if exists $option{stream_class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | croak 'new(): stream is internal; use connection_class, tuning, tls, and callbacks' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 69 | ▶ | if exists $option{stream}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | croak 'new(): HTTP Server owns on_data; use on_request/on_body callbacks' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 69 | ▶ | if exists $option{on_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | croak 'new(): HTTP Server cannot use message framing callbacks' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 68 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | croak 'new(): on_request_final was removed; use on_request and Response->body or Transaction->response_body' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 68 | ▶ | if exists $option{on_request_final}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 67 | my $connection_class_option = delete $option{connection_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 67 | ▶ | my $connection_class = _load_connection_class( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$connection_class_option // "Linux::Event::HTTP::Server::Connection"
MC/DC100%1/1
$connection_class_option // "Linux::Event::HTTP::Server::Connection"
$connection_class_option
Truth table100%2/2
A
A= $connection_class_option
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | $connection_class_option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | // 'Linux::Event::HTTP::Server::Connection', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 67 | ▶ | my $http2 = exists($option{http2}) ? delete($option{http2}) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | my $has_http2_max_header_list_size = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 67 | exists $option{http2_max_header_list_size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | my $http2_max_header_list_size = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $has_http2_max_header_list_size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ? delete($option{http2_max_header_list_size}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 67 | ▶ | : 65_536; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 67 | ▶ | croak 'new(): http2 must be zero or one' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $http2 or ref $http2 or "$http2" ne 0 and "$http2" ne 1
not defined $http2 or ref $http2
"$http2" ne 0 and "$http2" ne 1
MC/DC0%0/4
not defined $http2 or ref $http2 or "$http2" ne 0 and "$http2" ne 1
not defined $http2
ref $http2
"$http2" ne 0
"$http2" ne 1
Truth table20%1/5
not(A) or B or C and D
A= not defined $http2B= ref $http2C= "$http2" ne 0D= "$http2" ne 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | if !defined($http2) || ref($http2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | || ("$http2" ne '0' && "$http2" ne '1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 67 | ▶ | $http2 = $http2 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 67 | ▶ | croak 'new(): http2_max_header_list_size must be a positive integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $http2_max_header_list_size or not "$http2_max_header_list_size" =~ /\A[0-9]+\z/u or $http2_max_header_list_size < 1
ref $http2_max_header_list_size or not "$http2_max_header_list_size" =~ /\A[0-9]+\z/u
MC/DC0%0/3
ref $http2_max_header_list_size or not "$http2_max_header_list_size" =~ /\A[0-9]+\z/u or $http2_max_header_list_size < 1
ref $http2_max_header_list_size
not "$http2_max_header_list_size" =~ /\A[0-9]+\z/u
$http2_max_header_list_size < 1
Truth table25%1/4
A or not(B) or C
A= ref $http2_max_header_list_sizeB= not "$http2_max_header_list_size" =~ /\A[0-9]+\z/uC= $http2_max_header_list_size < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | if ref($http2_max_header_list_size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | || "$http2_max_header_list_size" !~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | || $http2_max_header_list_size < 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 67 | ▶ | croak 'new(): http2_max_header_list_size requires http2 => 1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $http2 and $has_http2_max_header_list_size
MC/DC0%0/2
not $http2 and $has_http2_max_header_list_size
not $http2
$has_http2_max_header_list_size
Truth table33%1/3
not(A) and B
A= not $http2B= $has_http2_max_header_list_size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | if !$http2 && $has_http2_max_header_list_size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 67 | my %callbacks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 67 | for my $name (qw(on_request on_body on_request_end)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 201 | my $callback = _take_callback($name, \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 201 | ▶ | $callbacks{$name} = $callback if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 67 | my %stream_callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 67 | for my $name (qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | on_ready on_transport_ready on_drain on_eof on_error on_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 402 | my $callback = _take_callback($name, \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 402 | ▶ | $stream_callback{$name} = $callback if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 67 | my $listener_error = _take_callback('on_listener_error', \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 66 | ▶ | my $tuning = exists($option{tuning}) ? delete($option{tuning}) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 66 | ▶ | croak 'new(): tuning must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | if ref($tuning) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 66 | my $tls_enabled = exists $option{tls}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 66 | my $tls = delete $option{tls}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 66 | ▶ | croak 'new(): tls must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tls_enabled and ref $tls ne "HASH"
MC/DC0%0/2
$tls_enabled and ref $tls ne "HASH"
$tls_enabled
ref $tls ne "HASH"
Truth table66%2/3
A and B
A= $tls_enabledB= ref $tls ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | if $tls_enabled && ref($tls) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 66 | ▶ | $tls = { %$tls } if $tls_enabled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 66 | ▶ | if ($http2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | croak 'new(): http2 requires tls' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | if !$tls_enabled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | croak 'new(): http2 currently requires the default connection_class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | if defined($connection_class_option); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | croak 'new(): http2 owns TLS ALPN selection; do not supply tls => { alpn => ... }' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if exists $tls->{alpn}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | croak 'new(): HTTP/2 support requires Net::HTTP2::nghttp2 0.011 or newer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | if !_http2_available(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $tls->{alpn} = [ 'h2', 'http/1.1' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $user_on_ready = $stream_callback{on_ready}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $stream_callback{on_ready} = sub ($conn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | _http2_ready( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $conn, $user_on_ready, 0 + $http2_max_header_list_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | croak 'new(): HTTP Server requires on_request callback or connection_class method' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 66 | ▶ | if !$callbacks{on_request} && !$connection_class->can('on_request'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$callbacks{"on_request"} or $connection_class->can("on_request")
MC/DC100%2/2
$callbacks{"on_request"} or $connection_class->can("on_request")
$callbacks{"on_request"}
$connection_class->can("on_request")
Truth table100%3/3
A or B
A= $callbacks{"on_request"}B= $connection_class->can("on_request")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 65 | my $data = delete $option{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 65 | my $state = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | callbacks => \%callbacks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | }, 'Linux::Event::HTTP::Server::_ConnectionState'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 65 | my %stream = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | class => $connection_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | data => $state, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | tuning => $tuning, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | %stream_callback, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 65 | ▶ | $stream{tls} = $tls if $tls_enabled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 65 | ▶ | my $listener = Linux::Event::IO::Sock::Listener->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | %option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | stream => \%stream, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | (defined($listener_error) ? (on_error => $listener_error) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 63 | return bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | listener => $listener, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | connection_class => $connection_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | state => $state, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | http2 => $http2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | http2_max_header_list_size => 0 + $http2_max_header_list_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | sub listener ($self) { $self->{listener} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listener: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | sub connection_class ($self) { $self->{connection_class} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connection_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | sub data ($self) { $self->{data} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub http2 ($self) { !!$self->{http2} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http2: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub http2_max_header_list_size ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http2_max_header_list_size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return $self->{http2_max_header_list_size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub loop ($self) { $self->{listener}->loop } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub fh ($self) { $self->{listener}->fh } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub fd ($self) { $self->{listener}->fd } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fd: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub host ($self) { $self->{listener}->host } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 73 | ▶ | sub port ($self) { $self->{listener}->port } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub path ($self) { $self->{listener}->path } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub family ($self) { $self->{listener}->family } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
family: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub family_number ($self) { $self->{listener}->family_number } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
family_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | sub is_tcp ($self) { $self->{listener}->is_tcp } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_tcp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub is_unix ($self) { $self->{listener}->is_unix } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_unix: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub state ($self) { $self->{listener}->state } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | sub pause ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | $self->{listener}->pause; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub resume ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->{listener}->resume; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 63 | ▶ | sub close ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 63 | $self->{listener}->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 63 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 19 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||