« blib/lib/Langertha/Skeid/CapacityProbe/Prometheus.pm
↑ Summary
lib/Langertha/Skeid/Protocol/Rerank.pm »
| 1 | package Langertha::Skeid::Protocol::MCP; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 113 | our $VERSION = '0.004'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: The MCP gateway's wire -- relayed headers, upstream URLs and the server listing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 113 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 113 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 113 | ▶ | use Mojo::URL; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # The transports a server entry can name. Only one of them is relayed; the other is a hint for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # a server on the customer's own machine. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 113 | my %TRANSPORT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 'streamable-http' => { relayed => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 'stdio' => { relayed => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # The client's request headers that travel upstream, beside every Mcp-* one. Nothing else of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # the client's does -- its Authorization least of all. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 113 | my %REQUEST_HEADER = map { $_ => 1 } qw( content-type accept last-event-id ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Header names a server's static `headers:` may not set, and why. A credential in the config | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # would be a secret on disk (ADR 0003); the rest belong to the relay or to the connection. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 113 | my $CREDENTIAL = 'a credential is named by api_key_ref or api_key_env, never written into the config'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 113 | my $RELAYED = 'the relay passes it on from the client'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 113 | my $FRAMING = 'it belongs to the connection'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my %CONFIG_HEADER_PROBLEM = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 452 | (map { $_ => $CREDENTIAL } qw( authorization proxy-authorization x-api-key cookie )), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 339 | (map { $_ => $RELAYED } keys %REQUEST_HEADER), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 113 | (map { $_ => $FRAMING } qw( host content-length transfer-encoding content-encoding accept-encoding | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | connection keep-alive te trailer upgrade expect )), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # The upstream's response headers that reach the client, beside every Mcp-* one. Whatever else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # the server sets -- cookies, Server, CORS, HSTS -- is about the server and its own site, not | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # for a client of this gateway. WWW-Authenticate is not here: it would come only with an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # upstream 401, which is answered 502 and never relayed. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 113 | my %RESPONSE_HEADER = map { $_ => 1 } qw( content-type cache-control retry-after ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 135 | ▶ | sub response_header_allowed { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response_header_allowed: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 135 | my ($class, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 135 | ▶ | my $lc = lc($name // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$name // ""
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 135 | ▶ | return ($RESPONSE_HEADER{$lc} || $lc =~ /\Amcp-/) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$RESPONSE_HEADER{$lc} or $lc =~ /\Amcp-/
MC/DC100%2/2
$RESPONSE_HEADER{$lc} or $lc =~ /\Amcp-/
$RESPONSE_HEADER{$lc}
$lc =~ /\Amcp-/
Truth table100%3/3
A or B
A= $RESPONSE_HEADER{$lc}B= $lc =~ /\Amcp-/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | sub transports { return sort keys %TRANSPORT } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transports: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 128 | ▶ | sub default_transport { 'streamable-http' } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_transport: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 370 | ▶ | sub is_transport { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_transport: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 370 | my ($class, $transport) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 370 | ▶ | return (defined($transport) && !ref($transport) && $TRANSPORT{$transport}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $transport and not ref $transport and $TRANSPORT{$transport}
defined $transport and not ref $transport
MC/DC33%1/3
defined $transport and not ref $transport and $TRANSPORT{$transport}
defined $transport
not ref $transport
$TRANSPORT{$transport}
Truth table50%2/4
A and not(B) and C
A= defined $transportB= not ref $transportC= $TRANSPORT{$transport}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 214 | ▶ | sub is_relayed { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_relayed: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 214 | my ($class, $transport) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 214 | ▶ | return ($class->is_transport($transport) && $TRANSPORT{$transport}{relayed}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class->is_transport($transport) and $TRANSPORT{$transport}{"relayed"}
MC/DC50%1/2
$class->is_transport($transport) and $TRANSPORT{$transport}{"relayed"}
$class->is_transport($transport)
$TRANSPORT{$transport}{"relayed"}
Truth table66%2/3
A and B
A= $class->is_transport($transport)B= $TRANSPORT{$transport}{"relayed"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 65 | ▶ | sub listing_path { '/v1/mcp/servers' } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listing_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 43 | ▶ | sub endpoint { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 43 | my ($class, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 43 | return '/mcp/' . $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 158 | ▶ | sub name_problem { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name_problem: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 158 | my ($class, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 158 | ▶ | return undef if defined($name) && !ref($name) && $name =~ /\A[A-Za-z0-9][A-Za-z0-9._-]{0,63}\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $name and not ref $name and $name =~ /\A[A-Za-z0-9][A-Za-z0-9._-]{0,63}\z/
defined $name and not ref $name
MC/DC33%1/3
defined $name and not ref $name and $name =~ /\A[A-Za-z0-9][A-Za-z0-9._-]{0,63}\z/
defined $name
not ref $name
$name =~ /\A[A-Za-z0-9][A-Za-z0-9._-]{0,63}\z/
Truth table50%2/4
A and not(B) and C
A= defined $nameB= not ref $nameC= $name =~ /\A[A-Za-z0-9][A-Za-z0-9._-]{0,63}\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | return 'a server name must start with a letter or digit and hold only letters, digits, ".", ' | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | . '"_" and "-", at most 64 characters: it is the <name> of /mcp/<name>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 145 | ▶ | sub url_problem { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url_problem: called CC=10 SCAR=25.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 145 | my ($class, $url) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 145 | ▶ | my $parsed = (defined($url) && !ref($url) && length($url)) ? Mojo::URL->new("$url") : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $url and not ref $url and length $url
defined $url and not ref $url
MC/DC0%0/3
defined $url and not ref $url and length $url
defined $url
not ref $url
length $url
Truth table25%1/4
A and not(B) and C
A= defined $urlB= not ref $urlC= length $url
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 145 | ▶ | return 'must be an absolute http or https URL' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition70%7/10
$parsed and ($parsed->scheme // "") =~ /\Ahttps?\z/i and length($parsed->host // "")
$parsed and ($parsed->scheme // "") =~ /\Ahttps?\z/i
$parsed->scheme // ""
$parsed->host // ""
MC/DC33%1/3
$parsed and ($parsed->scheme // "") =~ /\Ahttps?\z/i and length($parsed->host // "")
$parsed
$parsed->scheme
$parsed->host
Truth table50%2/4
A and B and C
A= $parsedB= $parsed->schemeC= $parsed->host
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | unless $parsed && ($parsed->scheme // '') =~ /\Ahttps?\z/i && length($parsed->host // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 142 | ▶ | return 'must not carry credentials: an upstream key is named by api_key_ref or api_key_env' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | if defined $parsed->userinfo; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 141 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 29 | ▶ | sub config_header_problem { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_header_problem: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 29 | my ($class, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 29 | ▶ | my $lc = lc($name // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$name // ""
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 29 | ▶ | return $RELAYED if $lc =~ /\Amcp-/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 28 | return $CONFIG_HEADER_PROBLEM{$lc}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 29 | ▶ | sub request_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_headers: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 29 | my ($class, $headers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 29 | my %out; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 29 | for my $name (@{$headers->names}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 168 | my $lc = lc($name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 168 | ▶ | next unless $REQUEST_HEADER{$lc} || $lc =~ /\Amcp-/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$REQUEST_HEADER{$lc} or $lc =~ /\Amcp-/
MC/DC100%2/2
$REQUEST_HEADER{$lc} or $lc =~ /\Amcp-/
$REQUEST_HEADER{$lc}
$lc =~ /\Amcp-/
Truth table100%3/3
A or B
A= $REQUEST_HEADER{$lc}B= $lc =~ /\Amcp-/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 19 | $out{$name} = $headers->header($name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 29 | return %out; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 37 | ▶ | sub upstream_url { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upstream_url: called CC=13 SCAR=26.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 37 | my ($class, $base, $rest, $query) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 37 | my $url = Mojo::URL->new($base); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 37 | ▶ | if (defined($rest) && length($rest)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $rest and length $rest
MC/DC50%1/2
defined $rest and length $rest
defined $rest
length $rest
Truth table66%2/3
A and B
A= defined $restB= length $rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 7 | my @segments = split m{/}, $rest, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 7 | ▶ | my $trailing = (@segments && $segments[-1] eq '') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@segments and $segments[-1] eq ""
MC/DC0%0/2
@segments and $segments[-1] eq ""
@segments
$segments[-1] eq ""
Truth table33%1/3
A and B
A= @segmentsB= $segments[-1] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | ▶ | pop @segments if $trailing; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 7 | for my $segment (@segments) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 10 | ▶ | return undef if $segment eq '.' || $segment eq '..' || $segment =~ /\\/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$segment eq "." or $segment eq ".." or $segment =~ /\\/
$segment eq "." or $segment eq ".."
MC/DC100%3/3
$segment eq "." or $segment eq ".." or $segment =~ /\\/
$segment eq "."
$segment eq ".."
$segment =~ /\\/
Truth table100%4/4
A or B or C
A= $segment eq "."B= $segment eq ".."C= $segment =~ /\\/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | if (@segments) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | my $path = $url->path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | push @{$path->parts}, @segments; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $path->trailing_slash($trailing); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 31 | ▶ | $url->query->append(@{$query->pairs}) if $query && @{$query->pairs}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$query and @{$query->pairs;}
MC/DC50%1/2
$query and @{$query->pairs;}
$query
@{$query->pairs;}
Truth table66%2/3
A and B
A= $queryB= @{$query->pairs;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 31 | return $url; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 19 | ▶ | sub listing_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listing_entry: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 19 | my ($class, $server, $base) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | my %entry = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | name => $server->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | transport => $server->{transport}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 19 | ▶ | description => ($server->{description} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$server->{"description"} // ""
MC/DC0%0/1
$server->{"description"} // ""
$server->{"description"}
Truth table50%1/2
A
A= $server->{"description"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 19 | ▶ | if ($class->is_relayed($server->{transport})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 14 | ▶ | $entry{url} = ($base // '') . $class->endpoint($server->{name}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$base // ""
MC/DC0%0/1
$base // ""
$base
Truth table50%1/2
A
A= $base
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | $entry{command} = $server->{command}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | ▶ | $entry{args} = [ @{$server->{args} || []} ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$server->{'args'} || []
MC/DC0%0/1
$server->{'args'} || []
$server->{'args'}
Truth table50%1/2
A
A= $server->{'args'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | $entry{env} = { %{$server->{env} || {}} }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$server->{'env'} || {}
MC/DC0%0/1
$server->{'env'} || {}
$server->{'env'}
Truth table50%1/2
A
A= $server->{'env'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 19 | return \%entry; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 21 | ▶ | sub is_event_stream { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_event_stream: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 21 | my ($class, $content_type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 21 | ▶ | return (defined($content_type) && $content_type =~ m{\A\s*text/event-stream\s*(?:;|\z)}i) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $content_type and $content_type =~ m[\A\s*text/event-stream\s*(?:;|\z)]i
MC/DC50%1/2
defined $content_type and $content_type =~ m[\A\s*text/event-stream\s*(?:;|\z)]i
defined $content_type
$content_type =~ m[\A\s*text/event-stream\s*(?:;|\z)]i
Truth table66%2/3
A and B
A= defined $content_typeB= $content_type =~ m[\A\s*text/event-stream\s*(?:;|\z)]i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 113 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||