| 1 | package Dancer2::Core::Request; | ||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Interface for accessing incoming requests | ||||||||||||||||||||||||||||||||||||||||
| 3 | 191 | $Dancer2::Core::Request::VERSION = '2.3.0'; | |||||||||||||||||||||||||||||||||||||||
| 4 | 191 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 191 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | 191 | ▶ | use parent 'Plack::Request'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||
| 8 | 191 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 191 | ▶ | use Encode qw(decode FB_CROAK LEAVE_SRC); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 191 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 11 | 191 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 12 | 191 | ▶ | use Safe::Isa; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | 191 | ▶ | use Hash::MultiValue; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 191 | ▶ | use Ref::Util qw< is_ref is_arrayref is_hashref is_coderef >; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||
| 16 | 191 | ▶ | use Dancer2::Core::Types; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | 191 | ▶ | use Dancer2::Core::Request::Upload; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 18 | 191 | ▶ | use Dancer2::Core::Cookie; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||
| 20 | # add an attribute for each HTTP_* variables | ||||||||||||||||||||||||||||||||||||||||
| 21 | # (HOST is managed manually) | ||||||||||||||||||||||||||||||||||||||||
| 22 | 191 | my @http_env_keys = (qw/ | |||||||||||||||||||||||||||||||||||||||
| 23 | accept_charset | ||||||||||||||||||||||||||||||||||||||||
| 24 | accept_encoding | ||||||||||||||||||||||||||||||||||||||||
| 25 | accept_language | ||||||||||||||||||||||||||||||||||||||||
| 26 | connection | ||||||||||||||||||||||||||||||||||||||||
| 27 | keep_alive | ||||||||||||||||||||||||||||||||||||||||
| 28 | x_requested_with | ||||||||||||||||||||||||||||||||||||||||
| 29 | /); | ||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||
| 31 | # apparently you can't eval core functions | ||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | sub accept { $_[0]->env->{'HTTP_ACCEPT'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | eval << "_EVAL" or die $@ for @http_env_keys; ## no critic | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept_charset: called CC=1 SCAR=0.0
Subroutine
accept_encoding: called CC=1 SCAR=0.0
Subroutine
accept_language: called CC=1 SCAR=0.0
Subroutine
connection: called CC=1 SCAR=0.0
Subroutine
keep_alive: called CC=1 SCAR=0.0
Subroutine
x_requested_with: called CC=1 SCAR=0.0
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 35 | sub $_ { \$_[0]->env->{ 'HTTP_' . ( uc "$_" ) } } | ||||||||||||||||||||||||||||||||||||||||
| 36 | 1; | ||||||||||||||||||||||||||||||||||||||||
| 37 | _EVAL | ||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||
| 39 | eval { | ||||||||||||||||||||||||||||||||||||||||
| 40 | 191 | require Unicode::UTF8; | |||||||||||||||||||||||||||||||||||||||
| 41 | 191 | ▶ | no warnings qw<redefine once>; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 42 | 34 | ▶ | *__decode = sub { Unicode::UTF8::decode_utf8($_[0]) }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 43 | 39 | ▶ | *__valid = sub { Unicode::UTF8::valid_utf8($_[0]) }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 44 | 191 | 1; | |||||||||||||||||||||||||||||||||||||||
| 45 | 191 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 46 | 191 | ▶ | no warnings qw<redefine once>; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | *__decode = sub { decode( 'UTF-8', $_[0] ) }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | *__valid = sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | eval { decode( 'UTF-8', $_[0], FB_CROAK | LEAVE_SRC ); 1 }; | |||||||||||||||||||||||||||||||||||||||
| 50 | 0 | }; | |||||||||||||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||
| 53 | # check presence of XS module to speedup request | ||||||||||||||||||||||||||||||||||||||||
| 54 | 191 | our $XS_URL_DECODE = eval { require URL::Encode::XS; 1; }; | |||||||||||||||||||||||||||||||||||||||
| 55 | 191 | our $XS_PARSE_QUERY_STRING = eval { require CGI::Deurl::XS; 1; }; | |||||||||||||||||||||||||||||||||||||||
| 56 | 0 | our $XS_HTTP_COOKIES = eval { require HTTP::XSCookies; 1; }; | |||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||
| 58 | 191 | our $_id = 0; | |||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||
| 60 | # self->new( env => {}, serializer => $s, is_behind_proxy => 0|1 ) | ||||||||||||||||||||||||||||||||||||||||
| 61 | 997 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 62 | 997 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||
| 64 | # even sized list | ||||||||||||||||||||||||||||||||||||||||
| 65 | 997 | ▶ | @args % 2 == 0 | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 66 | or croak 'Must provide even sized list'; | ||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||
| 68 | 997 | my %opts = @args; | |||||||||||||||||||||||||||||||||||||||
| 69 | 997 | my $env = $opts{'env'}; | |||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||
| 71 | 997 | my $self = $class->SUPER::new($env); | |||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||
| 73 | 997 | ▶ | if ( my $s = $opts{'serializer'} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 74 | 118 | ▶ | $s->$_does('Dancer2::Core::Role::Serializer') | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 75 | or croak 'Serializer provided not a Serializer object'; | ||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||
| 77 | 117 | $self->{'serializer'} = $s; | |||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||
| 80 | # additionally supported attributes | ||||||||||||||||||||||||||||||||||||||||
| 81 | 996 | $self->{'id'} = ++$_id; | |||||||||||||||||||||||||||||||||||||||
| 82 | 996 | $self->{'vars'} = {}; | |||||||||||||||||||||||||||||||||||||||
| 83 | 996 | $self->{'is_behind_proxy'} = !!$opts{'is_behind_proxy'}; | |||||||||||||||||||||||||||||||||||||||
| 84 | 996 | $self->{'uri_for_route'} = $opts{'uri_for_route'}; | |||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||
| 86 | $opts{'body_params'} | ||||||||||||||||||||||||||||||||||||||||
| 87 | 996 | ▶ | and $self->{'_body_params'} = $opts{'body_params'}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 88 | 996 | $self->{'_strict_utf8'} = !!$opts{'strict_utf8'}; | |||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||
| 90 | # Deserialize/parse body for HMV | ||||||||||||||||||||||||||||||||||||||||
| 91 | 996 | $self->data; | |||||||||||||||||||||||||||||||||||||||
| 92 | 991 | $self->_build_uploads(); | |||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||
| 94 | 990 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||
| 97 | # a buffer for per-request variables | ||||||||||||||||||||||||||||||||||||||||
| 98 | 132 | ▶ | sub vars { $_[0]->{'vars'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
vars: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||
| 100 | 13 | ▶ | sub var { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
var: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 101 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 102 | @_ == 2 | ||||||||||||||||||||||||||||||||||||||||
| 103 | ? $self->vars->{ $_[0] } = $_[1] | ||||||||||||||||||||||||||||||||||||||||
| 104 | 13 | ▶ | : $self->vars->{ $_[0] }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||
| 107 | # I don't like this. I know send_file uses this and I wonder | ||||||||||||||||||||||||||||||||||||||||
| 108 | # if we can remove it. | ||||||||||||||||||||||||||||||||||||||||
| 109 | # -- Sawyer | ||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub set_path_info { $_[0]->env->{'PATH_INFO'} = $_[1] } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_path_info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||
| 112 | # XXX: incompatible with Plack::Request | ||||||||||||||||||||||||||||||||||||||||
| 113 | 49 | ▶ | sub body { $_[0]->raw_body } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||
| 115 | 20 | ▶ | sub id { $_id } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||
| 117 | # Private 'read-only' attributes for request params. See the params() | ||||||||||||||||||||||||||||||||||||||||
| 118 | # method for the public interface. | ||||||||||||||||||||||||||||||||||||||||
| 119 | # | ||||||||||||||||||||||||||||||||||||||||
| 120 | # _body_params, _query_params and _route_params have setter methods that | ||||||||||||||||||||||||||||||||||||||||
| 121 | # decode byte string to characters before setting; If you know you have | ||||||||||||||||||||||||||||||||||||||||
| 122 | # decoded (character) params, such as output from a deserializer, you can | ||||||||||||||||||||||||||||||||||||||||
| 123 | # set these directly in the request object hash to avoid the decode op. | ||||||||||||||||||||||||||||||||||||||||
| 124 | 366 | ▶ | sub _params { $_[0]->{'_params'} ||= $_[0]->_build_params } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_params: called CC=2 SCAR=7.2
Condition66%2/3
$_[0]{"_params"} ||= $_[0]->_build_params
MC/DC0%0/2
$_[0]{"_params"} ||= $_[0]->_build_params
$_[0]{"_params"}
$_[0]->_build_params
Truth table66%2/3
A ||= B
A= $_[0]{"_params"}B= $_[0]->_build_params
| |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||
| 126 | 790 | ▶ | sub _has_params { defined $_[0]->{'_params'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||
| 128 | 1797 | ▶ | sub _body_params { $_[0]->{'_body_params'} ||= $_[0]->body_parameters->as_hashref_mixed } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_body_params: called CC=2 SCAR=7.2
Condition66%2/3
$_[0]{"_body_params"} ||= $_[0]->body_parameters->as_hashref_mixed
MC/DC0%0/2
$_[0]{"_body_params"} ||= $_[0]->body_parameters->as_hashref_mixed
$_[0]{"_body_params"}
$_[0]->body_parameters->as_hashref_mixed
Truth table66%2/3
A ||= B
A= $_[0]{"_body_params"}B= $_[0]->body_parameters->as_hashref_mixed
| |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||
| 130 | 101 | ▶ | sub _query_params { $_[0]->{'_query_params'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_query_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||
| 132 | 46 | ▶ | sub _set_query_params { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_query_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 133 | 46 | my ( $self, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 134 | 46 | $self->{_query_params} = $self->_decode( $params, 'query parameters' ); | |||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||
| 137 | 791 | ▶ | sub _route_params { $_[0]->{'_route_params'} ||= {} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_route_params: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]{"_route_params"} ||= {}
MC/DC100%1/1
$_[0]{"_route_params"} ||= {}
$_[0]{"_route_params"}
Truth table100%2/2
A
A= $_[0]{"_route_params"}
| |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||
| 139 | 753 | ▶ | sub _set_route_params { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_route_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 140 | 753 | my ( $self, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 141 | 753 | $self->{_route_params} = $self->_decode( $params, 'route parameters' ); | |||||||||||||||||||||||||||||||||||||||
| 142 | 753 | $self->_build_params(); | |||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||
| 145 | # XXX: incompatible with Plack::Request | ||||||||||||||||||||||||||||||||||||||||
| 146 | 6 | ▶ | sub uploads { $_[0]->{'uploads'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploads: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||
| 148 | 419 | ▶ | sub is_behind_proxy { $_[0]->{'is_behind_proxy'} || 0 } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_behind_proxy: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||
| 150 | 203 | ▶ | sub host { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 151 | 203 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||
| 153 | 203 | ▶ | if ( $self->is_behind_proxy and exists $self->env->{'HTTP_X_FORWARDED_HOST'} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->is_behind_proxy and exists $self->env->{"HTTP_X_FORWARDED_HOST"}
MC/DC100%2/2
$self->is_behind_proxy and exists $self->env->{"HTTP_X_FORWARDED_HOST"}
$self->is_behind_proxy
exists $self->env->{"HTTP_X_FORWARDED_HOST"}
Truth table100%3/3
A and B
A= $self->is_behind_proxyB= exists $self->env->{"HTTP_X_FORWARDED_HOST"}
| |||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | my @hosts = split /\s*,\s*/, $self->env->{'HTTP_X_FORWARDED_HOST'}, 2; | |||||||||||||||||||||||||||||||||||||||
| 155 | 3 | return $hosts[0]; | |||||||||||||||||||||||||||||||||||||||
| 156 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 157 | 200 | return $self->env->{'HTTP_HOST'}; | |||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||
| 161 | # aliases, kept for backward compat | ||||||||||||||||||||||||||||||||||||||||
| 162 | 17 | ▶ | sub agent { shift->user_agent } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
agent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 163 | 4 | ▶ | sub remote_address { shift->address } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
remote_address: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | ▶ | sub forwarded_for_address { shift->env->{'HTTP_X_FORWARDED_FOR'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
forwarded_for_address: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub forwarded_host { shift->env->{'HTTP_X_FORWARDED_HOST'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
forwarded_host: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||
| 167 | # there are two options | ||||||||||||||||||||||||||||||||||||||||
| 168 | 14 | ▶ | sub forwarded_protocol { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
forwarded_protocol: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 169 | $_[0]->env->{'HTTP_X_FORWARDED_PROTO'} || | ||||||||||||||||||||||||||||||||||||||||
| 170 | $_[0]->env->{'HTTP_X_FORWARDED_PROTOCOL'} || | ||||||||||||||||||||||||||||||||||||||||
| 171 | 14 | ▶ | $_[0]->env->{'HTTP_FORWARDED_PROTO'} | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"} or $_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"}
MC/DC100%2/2
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"} or $_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"}
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"}
$_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"}
Truth table100%3/3
A or B
A= $_[0]->env->{"HTTP_X_FORWARDED_PROTO"}B= $_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"}
| |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||
| 174 | 215 | ▶ | sub scheme { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
scheme: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 175 | 215 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 176 | 215 | ▶ | my $scheme = $self->is_behind_proxy | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 177 | ? $self->forwarded_protocol | ||||||||||||||||||||||||||||||||||||||||
| 178 | : ''; | ||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||
| 180 | 215 | ▶ | return $scheme || $self->env->{'psgi.url_scheme'}; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$scheme || $self->env->{'psgi.url_scheme'}
MC/DC100%2/2
$scheme || $self->env->{'psgi.url_scheme'}
$scheme
$self->env->{'psgi.url_scheme'}
Truth table100%3/3
A || B
A= $schemeB= $self->env->{'psgi.url_scheme'}
| |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||
| 183 | 1083 | ▶ | sub serializer { $_[0]->{'serializer'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
serializer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||
| 185 | 1063 | ▶ | sub data { $_[0]->{'data'} ||= $_[0]->deserialize() } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=2 SCAR=6.9
Pod
documented
Condition100%3/3
$_[0]{"data"} ||= $_[0]->deserialize
MC/DC100%2/2
$_[0]{"data"} ||= $_[0]->deserialize
$_[0]{"data"}
$_[0]->deserialize
Truth table100%3/3
A ||= B
A= $_[0]{"data"}B= $_[0]->deserialize
| |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||
| 187 | 1000 | ▶ | sub deserialize { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
deserialize: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 188 | 1000 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||
| 190 | # don't attempt to deserialize if the form is 'multipart/form-data' | ||||||||||||||||||||||||||||||||||||||||
| 191 | 1000 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->content_type and $self->content_type =~ m[^multipart/form-data]i
MC/DC100%2/2
$self->content_type and $self->content_type =~ m[^multipart/form-data]i
$self->content_type
$self->content_type =~ m[^multipart/form-data]i
Truth table100%3/3
A and B
A= $self->content_typeB= $self->content_type =~ m[^multipart/form-data]i
| |||||||||||||||||||||||||||||||||||||||||
| 192 | $self->content_type | ||||||||||||||||||||||||||||||||||||||||
| 193 | && $self->content_type =~ /^multipart\/form-data/i | ||||||||||||||||||||||||||||||||||||||||
| 194 | ) { | ||||||||||||||||||||||||||||||||||||||||
| 195 | 9 | return; | |||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||
| 199 | 991 | ▶ | my $serializer = $self->serializer | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 200 | or return; | ||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||
| 202 | # The latest draft of the RFC does not forbid DELETE to have content, | ||||||||||||||||||||||||||||||||||||||||
| 203 | # rather the behaviour is undefined. Take the most lenient route and | ||||||||||||||||||||||||||||||||||||||||
| 204 | # deserialize any content on delete as well. | ||||||||||||||||||||||||||||||||||||||||
| 205 | return | ||||||||||||||||||||||||||||||||||||||||
| 206 | 118 | ▶ | unless grep { $self->method eq $_ } qw/ PUT POST QUERY PATCH DELETE /; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||
| 208 | # try to deserialize | ||||||||||||||||||||||||||||||||||||||||
| 209 | 48 | my $body = $self->body; | |||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||
| 211 | 48 | ▶ | $body && length $body > 0 | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$body and length $body > 0
MC/DC50%1/2
$body and length $body > 0
$body
length $body > 0
Truth table66%2/3
A and B
A= $bodyB= length $body > 0
| |||||||||||||||||||||||||||||||||||||||||
| 212 | or return; | ||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||
| 214 | # Catch serializer fails - which is tricky as Role::Serializer | ||||||||||||||||||||||||||||||||||||||||
| 215 | # wraps the deserializaion in an eval and returns undef. | ||||||||||||||||||||||||||||||||||||||||
| 216 | # We want to generate a 500 error on serialization fail (Ref #794) | ||||||||||||||||||||||||||||||||||||||||
| 217 | # to achieve that, override the log callback so we can catch a signal | ||||||||||||||||||||||||||||||||||||||||
| 218 | # that it failed. This is messy (messes with serializer internals), but | ||||||||||||||||||||||||||||||||||||||||
| 219 | # "works". | ||||||||||||||||||||||||||||||||||||||||
| 220 | 45 | my $serializer_fail; | |||||||||||||||||||||||||||||||||||||||
| 221 | 45 | my $serializer_log_cb = $serializer->log_cb; | |||||||||||||||||||||||||||||||||||||||
| 222 | 5 | ▶ | local $serializer->{log_cb} = sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 223 | 5 | $serializer_fail = $_[1]; | |||||||||||||||||||||||||||||||||||||||
| 224 | 5 | $serializer_log_cb->(@_); | |||||||||||||||||||||||||||||||||||||||
| 225 | 45 | }; | |||||||||||||||||||||||||||||||||||||||
| 226 | # work-around to resolve a chicken-and-egg issue when instantiating a | ||||||||||||||||||||||||||||||||||||||||
| 227 | # request object; the serializer needs that request object to deserialize | ||||||||||||||||||||||||||||||||||||||||
| 228 | # the body params. | ||||||||||||||||||||||||||||||||||||||||
| 229 | 45 | Scalar::Util::weaken( my $request = $self ); | |||||||||||||||||||||||||||||||||||||||
| 230 | 45 | ▶ | $self->serializer->has_request || $self->serializer->set_request($request); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 231 | 45 | my $data = $serializer->deserialize($body); | |||||||||||||||||||||||||||||||||||||||
| 232 | 45 | ▶ | die $serializer_fail if $serializer_fail; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||
| 234 | # Set _body_params directly rather than using the setter. Deserializiation | ||||||||||||||||||||||||||||||||||||||||
| 235 | # returns characters and skipping the decode op in the setter ensures | ||||||||||||||||||||||||||||||||||||||||
| 236 | # that numerical data "stays" numerical; decoding an SV that is an IV | ||||||||||||||||||||||||||||||||||||||||
| 237 | # converts that to a PVIV. Some serializers are picky (JSON).. | ||||||||||||||||||||||||||||||||||||||||
| 238 | 40 | $self->{_body_params} = $data; | |||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||
| 240 | # Set body parameters (decoded HMV) | ||||||||||||||||||||||||||||||||||||||||
| 241 | 40 | ▶ | $self->{'body_parameters'} = | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 242 | Hash::MultiValue->from_mixed( is_hashref($data) ? %$data : () ); | ||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||
| 244 | 40 | return $data; | |||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | ▶ | sub uri { $_[0]->request_uri } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | ▶ | sub is_head { $_[0]->method eq 'HEAD' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_head: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 250 | 7 | ▶ | sub is_post { $_[0]->method eq 'POST' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_post: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 251 | 7 | ▶ | sub is_get { $_[0]->method eq 'GET' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | ▶ | sub is_put { $_[0]->method eq 'PUT' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_put: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | ▶ | sub is_delete { $_[0]->method eq 'DELETE' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | ▶ | sub is_patch { $_[0]->method eq 'PATCH' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_patch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | ▶ | sub is_query { $_[0]->method eq 'QUERY' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_query: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub is_options { $_[0]->method eq 'OPTIONS' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_options: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||
| 258 | # public interface compat with CGI.pm objects | ||||||||||||||||||||||||||||||||||||||||
| 259 | 3 | ▶ | sub request_method { $_[0]->method } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_method: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | sub input_handle { $_[0]->env->{'psgi.input'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
input_handle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||
| 262 | 7 | ▶ | sub to_string { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 263 | 7 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 264 | 7 | return "[#" . $self->id . "] " . $self->method . " " . $self->path; | |||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||
| 267 | 41 | ▶ | sub base { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 268 | 41 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 269 | 41 | my $uri = $self->_common_uri; | |||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||
| 271 | 41 | return $uri->canonical; | |||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||
| 274 | 197 | ▶ | sub _common_uri { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_common_uri: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||
| 275 | 197 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||
| 277 | 197 | my $path = $self->env->{SCRIPT_NAME}; | |||||||||||||||||||||||||||||||||||||||
| 278 | 197 | my $port = $self->env->{SERVER_PORT}; | |||||||||||||||||||||||||||||||||||||||
| 279 | 197 | my $server = $self->env->{SERVER_NAME}; | |||||||||||||||||||||||||||||||||||||||
| 280 | 197 | my $host = $self->host; | |||||||||||||||||||||||||||||||||||||||
| 281 | 197 | my $scheme = $self->scheme; | |||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||
| 283 | 197 | my $uri = URI->new; | |||||||||||||||||||||||||||||||||||||||
| 284 | 197 | $uri->scheme($scheme); | |||||||||||||||||||||||||||||||||||||||
| 285 | 197 | ▶ | $uri->authority( $host || "$server:$port" ); | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$host || "${server}:$port"
MC/DC100%1/1
$host || "${server}:$port"
$host
Truth table100%2/2
A
A= $host
| |||||||||||||||||||||||||||||||||||||||||
| 286 | 197 | ▶ | $uri->path( $path || '/' ); | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$path || '/'
MC/DC100%1/1
$path || '/'
$path
Truth table100%2/2
A
A= $path
| |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||
| 288 | 197 | return $uri; | |||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||
| 291 | 156 | ▶ | sub uri_base { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_base: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 292 | 156 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 293 | 156 | my $uri = $self->_common_uri; | |||||||||||||||||||||||||||||||||||||||
| 294 | 156 | my $canon = $uri->canonical; | |||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||
| 296 | 156 | ▶ | if ( $uri->path eq '/' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 297 | 144 | $canon =~ s{/$}{}; | |||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||
| 300 | 156 | return $canon; | |||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||
| 303 | 2187 | ▶ | sub path { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 304 | 2187 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 305 | 2187 | ▶ | my $path = $self->env->{PATH_INFO} || '/'; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->env->{'PATH_INFO'} || '/'
MC/DC100%1/1
$self->env->{'PATH_INFO'} || '/'
$self->env->{'PATH_INFO'}
Truth table100%2/2
A
A= $self->env->{'PATH_INFO'}
| |||||||||||||||||||||||||||||||||||||||||
| 306 | 2187 | return $self->_decode_bytes( $path, 'PATH_INFO' ); | |||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub dispatch_path { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | Carp::croak q{DEPRECATED: request->dispatch_path. Please use request->path instead}; | |||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||
| 313 | 32 | ▶ | sub uri_for { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_for: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 314 | 32 | my ( $self, $part, $params, $dont_escape ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||
| 316 | 32 | ▶ | $part ||= ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$part ||= ""
MC/DC0%0/1
$part ||= ""
$part
Truth table50%1/2
A
A= $part
| |||||||||||||||||||||||||||||||||||||||||
| 317 | 32 | my $uri = $self->base; | |||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||
| 319 | # Make sure there's exactly one slash between the base and the new part | ||||||||||||||||||||||||||||||||||||||||
| 320 | 32 | my $base = $uri->path; | |||||||||||||||||||||||||||||||||||||||
| 321 | 32 | $base =~ s|/$||; | |||||||||||||||||||||||||||||||||||||||
| 322 | 32 | $part =~ s|^/||; | |||||||||||||||||||||||||||||||||||||||
| 323 | 32 | $uri->path("$base/$part"); | |||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||
| 325 | 32 | ▶ | $uri->query_form($params) if $params; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||
| 327 | return $dont_escape | ||||||||||||||||||||||||||||||||||||||||
| 328 | 3 | ? uri_unescape( ${ $uri->canonical } ) | |||||||||||||||||||||||||||||||||||||||
| 329 | 32 | ▶ | : ${ $uri->canonical }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub uri_for_route { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_for_route: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | is_coderef( $self->{'uri_for_route'} ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 336 | or die 'uri_for_route called on a request instance without it'; | ||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return $self->{'uri_for_route'}->(@_); | |||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||
| 341 | 335 | ▶ | sub params { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
params: called CC=12 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 342 | 335 | my ( $self, $source ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||
| 344 | 335 | ▶ | return %{ $self->_params } if wantarray && @_ == 1; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
wantarray and @_ == 1
MC/DC50%1/2
wantarray and @_ == 1
wantarray
@_ == 1
Truth table66%2/3
A and B
A= wantarrayB= @_ == 1
| |||||||||||||||||||||||||||||||||||||||||
| 345 | 305 | ▶ | return $self->_params if @_ == 1; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||
| 347 | 25 | ▶ | if ( $source eq 'query' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | return %{ $self->_query_params || {} } if wantarray; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->_query_params || {}
MC/DC0%0/1
$self->_query_params || {}
$self->_query_params
Truth table0%0/2
A
A= $self->_query_params
| |||||||||||||||||||||||||||||||||||||||||
| 349 | 6 | return $self->_query_params; | |||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||
| 351 | elsif ( $source eq 'body' ) { | ||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | return %{ $self->_body_params || {} } if wantarray; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->_body_params || {}
MC/DC0%0/1
$self->_body_params || {}
$self->_body_params
Truth table0%0/2
A
A= $self->_body_params
| |||||||||||||||||||||||||||||||||||||||||
| 353 | 16 | return $self->_body_params; | |||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | ▶ | if ( $source eq 'route' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | return %{ $self->_route_params } if wantarray; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | return $self->_route_params; | |||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||
| 359 | else { | ||||||||||||||||||||||||||||||||||||||||
| 360 | 1 | croak "Unknown source params \"$source\"."; | |||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||
| 364 | 75 | ▶ | sub query_parameters { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_parameters: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 365 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 366 | 75 | ▶ | $self->{'query_parameters'} ||= do { | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"query_parameters"} ||= do {
if ($Dancer2::Core::Request::XS_PARSE_QUERY_STRING) {
my $query = $self->_decode(CGI::Deurl::XS::parse_query_string($self->env->{"QUERY_STRING"}), "query parameters");
"Hash::MultiValue"->new(map({my $key = $_;
is_arrayref($query->{$key}) ? map(($key, $_), @{$$query{$key};}) : ($key, $query->{$key});} keys %{$query;}));
}
else {
$self->_decode($self->SUPER::query_parameters, "query parameters");
}
}
MC/DC0%0/2
$self->{"query_parameters"} ||= do {
if ($Dancer2::Core::Request::XS_PARSE_QUERY_STRING) {
my $query = $self->_decode(CGI::Deurl::XS::parse_query_string($self->env->{"QUERY_STRING"}), "query parameters");
"Hash::MultiValue"->new(map({my $key = $_;
is_arrayref($query->{$key}) ? map(($key, $_), @{$$query{$key};}) : ($key, $query->{$key});} keys %{$query;}));
}
else {
$self->_decode($self->SUPER::query_parameters, "query parameters");
}
}
$self->{"query_parameters"}
do {
if ($Dancer2::Core::Request::XS_PARSE_QUERY_STRING) {
my $query = $self->_decode(CGI::Deurl::XS::parse_query_string($self->env->{"QUERY_STRING"}), "query parameters");
"Hash::MultiValue"->new(map({my $key = $_;
is_arrayref($query->{$key}) ? map(($key, $_), @{$$query{$key};}) : ($key, $query->{$key});} keys %{$query;}));
}
else {
$self->_decode($self->SUPER::query_parameters, "query parameters");
}
}
Truth table66%2/3
A ||= B
A= $self->{"query_parameters"}B= do {
if ($Dancer2::Core::Request::XS_PARSE_QUERY_STRING) {
my $query = $self->_decode(CGI::Deurl::XS::parse_query_string($self->env->{"QUERY_STRING"}), "query parameters");
"Hash::MultiValue"->new(map({my $key = $_;
is_arrayref($query->{$key}) ? map(($key, $_), @{$$query{$key};}) : ($key, $query->{$key});} keys %{$query;}));
}
else {
$self->_decode($self->SUPER::query_parameters, "query parameters");
}
}
| |||||||||||||||||||||||||||||||||||||||||
| 367 | 61 | ▶ | if ($XS_PARSE_QUERY_STRING) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 368 | my $query = $self->_decode(CGI::Deurl::XS::parse_query_string( | ||||||||||||||||||||||||||||||||||||||||
| 369 | 57 | $self->env->{'QUERY_STRING'} | |||||||||||||||||||||||||||||||||||||||
| 370 | ), 'query parameters'); | ||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||
| 372 | Hash::MultiValue->new( | ||||||||||||||||||||||||||||||||||||||||
| 373 | map {; | ||||||||||||||||||||||||||||||||||||||||
| 374 | 20 | my $key = $_; | |||||||||||||||||||||||||||||||||||||||
| 375 | is_arrayref( $query->{$key} ) | ||||||||||||||||||||||||||||||||||||||||
| 376 | 3 | ? ( map +( $key => $_ ), @{ $query->{$key} } ) | |||||||||||||||||||||||||||||||||||||||
| 377 | 20 | ▶ | : ( $key => $query->{$key} ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 378 | 57 | } keys %{$query} | |||||||||||||||||||||||||||||||||||||||
| 379 | ); | ||||||||||||||||||||||||||||||||||||||||
| 380 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 381 | # defer to Plack::Request | ||||||||||||||||||||||||||||||||||||||||
| 382 | 4 | $self->_decode($self->SUPER::query_parameters, 'query parameters'); | |||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||
| 384 | }; | ||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||
| 387 | # this will be filled once the route is matched | ||||||||||||||||||||||||||||||||||||||||
| 388 | 22 | ▶ | sub route_parameters { $_[0]->{'route_parameters'} ||= Hash::MultiValue->new } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
route_parameters: called CC=2 SCAR=9.2
Pod
undocumented
Condition33%1/3
$_[0]{"route_parameters"} ||= "Hash::MultiValue"->new
MC/DC0%0/2
$_[0]{"route_parameters"} ||= "Hash::MultiValue"->new
$_[0]{"route_parameters"}
"Hash::MultiValue"->new
Truth table33%1/3
A ||= B
A= $_[0]{"route_parameters"}B= "Hash::MultiValue"->new
| |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||
| 390 | 753 | ▶ | sub _set_route_parameters { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_route_parameters: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 391 | 753 | my ( $self, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 392 | # remove reserved splat parameter name | ||||||||||||||||||||||||||||||||||||||||
| 393 | # you should access splat parameters using splat() keyword | ||||||||||||||||||||||||||||||||||||||||
| 394 | 753 | delete @{$params}{qw<splat captures>}; | |||||||||||||||||||||||||||||||||||||||
| 395 | $self->{'route_parameters'} = Hash::MultiValue->from_mixed( | ||||||||||||||||||||||||||||||||||||||||
| 396 | 753 | %{ $self->_decode( $params, 'route parameters' ) } | |||||||||||||||||||||||||||||||||||||||
| 397 | ); | ||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||
| 400 | 978 | ▶ | sub body_parameters { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
body_parameters: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 401 | 978 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 402 | # defer to (the overridden) Plack::Request->body_parameters | ||||||||||||||||||||||||||||||||||||||||
| 403 | 978 | ▶ | $self->{'body_parameters'} ||= $self->_decode( | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"body_parameters"} ||= $self->_decode($self->SUPER::body_parameters, "body parameters")
MC/DC0%0/2
$self->{"body_parameters"} ||= $self->_decode($self->SUPER::body_parameters, "body parameters")
$self->{"body_parameters"}
$self->_decode($self->SUPER::body_parameters, "body parameters")
Truth table66%2/3
A ||= B
A= $self->{"body_parameters"}B= $self->_decode($self->SUPER::body_parameters, "body parameters")
| |||||||||||||||||||||||||||||||||||||||||
| 404 | $self->SUPER::body_parameters(), | ||||||||||||||||||||||||||||||||||||||||
| 405 | 'body parameters', | ||||||||||||||||||||||||||||||||||||||||
| 406 | ); | ||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||
| 409 | 6 | ▶ | sub parameters { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameters: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 410 | 6 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||
| 412 | # handle a specific case | ||||||||||||||||||||||||||||||||||||||||
| 413 | 6 | ▶ | if ($type) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $attr = "${type}_parameters"; | |||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return $self->$attr; | |||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||
| 418 | # merge together the *decoded* parameters | ||||||||||||||||||||||||||||||||||||||||
| 419 | 6 | ▶ | $self->{'merged_parameters'} ||= do { | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"merged_parameters"} ||= do {
my $query = $self->query_parameters;
my $body = $self->body_parameters;
my $route = $self->route_parameters;
"Hash::MultiValue"->new(map($_->flatten, $query, $body, $route))
}
MC/DC0%0/2
$self->{"merged_parameters"} ||= do {
my $query = $self->query_parameters;
my $body = $self->body_parameters;
my $route = $self->route_parameters;
"Hash::MultiValue"->new(map($_->flatten, $query, $body, $route))
}
$self->{"merged_parameters"}
do {
my $query = $self->query_parameters;
my $body = $self->body_parameters;
my $route = $self->route_parameters;
"Hash::MultiValue"->new(map($_->flatten, $query, $body, $route))
}
Truth table66%2/3
A ||= B
A= $self->{"merged_parameters"}B= do {
my $query = $self->query_parameters;
my $body = $self->body_parameters;
my $route = $self->route_parameters;
"Hash::MultiValue"->new(map($_->flatten, $query, $body, $route))
}
| |||||||||||||||||||||||||||||||||||||||||
| 420 | 5 | my $query = $self->query_parameters; | |||||||||||||||||||||||||||||||||||||||
| 421 | 5 | my $body = $self->body_parameters; | |||||||||||||||||||||||||||||||||||||||
| 422 | 5 | my $route = $self->route_parameters; # not in Plack::Request | |||||||||||||||||||||||||||||||||||||||
| 423 | 5 | Hash::MultiValue->new( map $_->flatten, $query, $body, $route ); | |||||||||||||||||||||||||||||||||||||||
| 424 | }; | ||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | ▶ | sub captures { shift->params->{captures} || {} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
captures: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||
| 429 | 33 | ▶ | sub splat { @{ shift->params->{splat} || [] } } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
splat: called CC=2 SCAR=6.9
Pod
undocumented
Condition100%2/2
+(shift())->params->{'splat'} || []
MC/DC100%1/1
+(shift())->params->{'splat'} || []
+(shift())->params->{'splat'}
Truth table100%2/2
A
A= +(shift())->params->{'splat'}
| |||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||
| 431 | # XXX: incompatible with Plack::Request | ||||||||||||||||||||||||||||||||||||||||
| 432 | 10 | ▶ | sub param { shift->params->{ $_[0] } } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
param: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||
| 434 | 25293 | ▶ | sub _decode { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||
| 435 | 25293 | my ( $self, $h, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 436 | 25293 | ▶ | return if not defined $h; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||
| 438 | 25244 | ▶ | if ( !is_ref($h) && !utf8::is_utf8($h) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
is_ref($h) || utf8::is_utf8($h)
MC/DC100%2/2
is_ref($h) || utf8::is_utf8($h)
is_ref($h)
utf8::is_utf8($h)
Truth table100%3/3
A || B
A= is_ref($h)B= utf8::is_utf8($h)
| |||||||||||||||||||||||||||||||||||||||||
| 439 | 21754 | return $self->_decode_bytes( $h, $context ); | |||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||
| 441 | elsif ( ref($h) eq 'Hash::MultiValue' ) { | ||||||||||||||||||||||||||||||||||||||||
| 442 | 894 | return Hash::MultiValue->from_mixed( | |||||||||||||||||||||||||||||||||||||||
| 443 | $self->_decode( $h->as_hashref_mixed, $context ) | ||||||||||||||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||
| 446 | elsif ( is_hashref($h) ) { | ||||||||||||||||||||||||||||||||||||||||
| 447 | 2464 | return { map scalar $self->_decode( $_, $context ), %{$h} }; | |||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||
| 449 | elsif ( is_arrayref($h) ) { | ||||||||||||||||||||||||||||||||||||||||
| 450 | 122 | return [ map $self->_decode( $_, $context ), @{$h} ]; | |||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||
| 453 | 10 | return $h; | |||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||
| 456 | 23941 | ▶ | sub _decode_bytes { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_bytes: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||
| 457 | 23941 | my ( $self, $bytes, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||
| 459 | # If PSGI already gave us characters, avoid re-decoding. | ||||||||||||||||||||||||||||||||||||||||
| 460 | 23941 | ▶ | return $bytes if utf8::is_utf8($bytes); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 461 | 23941 | ▶ | return $bytes if $bytes !~ /[\x80-\xFF]/; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||
| 463 | 39 | ▶ | return __decode($bytes) if __valid($bytes); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 464 | 5 | return $self->_invalid_utf8( $bytes, $context ); | |||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||
| 467 | 5 | ▶ | sub _invalid_utf8 { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invalid_utf8: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||
| 468 | 5 | my ( $self, $bytes, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 469 | 5 | my $strict = $self->{_strict_utf8}; | |||||||||||||||||||||||||||||||||||||||
| 470 | 5 | ▶ | my $where = $context || 'input'; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$context || 'input'
MC/DC0%0/1
$context || 'input'
$context
Truth table50%1/2
A
A= $context
| |||||||||||||||||||||||||||||||||||||||||
| 471 | 5 | my $msg = "Invalid UTF-8 in $where"; | |||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||
| 473 | 5 | ▶ | $strict | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 474 | and Carp::croak($msg); | ||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | ▶ | if ( my $logger = $self->env->{'psgix.logger'} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | $logger->({ | |||||||||||||||||||||||||||||||||||||||
| 478 | level => 'warning', | ||||||||||||||||||||||||||||||||||||||||
| 479 | message => "$msg; leaving bytes unchanged", | ||||||||||||||||||||||||||||||||||||||||
| 480 | }); | ||||||||||||||||||||||||||||||||||||||||
| 481 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 482 | 2 | Carp::carp("$msg; leaving bytes unchanged"); | |||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | return $bytes; | |||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | sub is_ajax { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ajax: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | return 0 unless defined $self->headers; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | return 0 unless defined $self->header('X-Requested-With'); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | return 0 if $self->header('X-Requested-With') ne 'XMLHttpRequest'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||
| 497 | # XXX incompatible with Plack::Request | ||||||||||||||||||||||||||||||||||||||||
| 498 | # context-aware accessor for uploads | ||||||||||||||||||||||||||||||||||||||||
| 499 | 21 | ▶ | sub upload { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 500 | 21 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 501 | 21 | my $res = $self->{uploads}{$name}; | |||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||
| 503 | 21 | ▶ | return $res unless wantarray; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 504 | 9 | ▶ | return () unless defined $res; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 505 | 6 | ▶ | return ( is_arrayref($res) ) ? @$res : $res; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||
| 508 | 790 | ▶ | sub _build_params { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_params: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||
| 509 | 790 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||
| 511 | # params may have been populated by before filters | ||||||||||||||||||||||||||||||||||||||||
| 512 | # _before_ we get there, so we have to save it first | ||||||||||||||||||||||||||||||||||||||||
| 513 | 790 | ▶ | my $previous = $self->_has_params ? $self->_params : {}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||
| 515 | # now parse environment params... | ||||||||||||||||||||||||||||||||||||||||
| 516 | 790 | my $get_params = $self->_parse_get_params(); | |||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||
| 518 | # and merge everything | ||||||||||||||||||||||||||||||||||||||||
| 519 | $self->{_params} = { | ||||||||||||||||||||||||||||||||||||||||
| 520 | 789 | ▶ | map +( is_hashref($_) ? %{$_} : () ), | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 521 | $previous, | ||||||||||||||||||||||||||||||||||||||||
| 522 | $get_params, | ||||||||||||||||||||||||||||||||||||||||
| 523 | $self->_body_params, | ||||||||||||||||||||||||||||||||||||||||
| 524 | $self->_route_params, | ||||||||||||||||||||||||||||||||||||||||
| 525 | }; | ||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||
| 529 | 76 | ▶ | sub _url_decode { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_url_decode: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 530 | 76 | my ( $self, $encoded ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 531 | 76 | ▶ | return URL::Encode::XS::url_decode($encoded) if $XS_URL_DECODE; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 532 | 44 | my $clean = $encoded; | |||||||||||||||||||||||||||||||||||||||
| 533 | 44 | $clean =~ tr/\+/ /; | |||||||||||||||||||||||||||||||||||||||
| 534 | 44 | $clean =~ s/%([a-fA-F0-9]{2})/pack "H2", $1/eg; | |||||||||||||||||||||||||||||||||||||||
| 535 | 44 | return $clean; | |||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||
| 538 | 790 | ▶ | sub _parse_get_params { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_get_params: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||
| 539 | 790 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 540 | 790 | ▶ | return $self->_query_params if defined $self->{_query_params}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||
| 542 | 740 | my $query_params = {}; | |||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||
| 544 | 740 | my $source = $self->env->{QUERY_STRING}; | |||||||||||||||||||||||||||||||||||||||
| 545 | 740 | ▶ | return if !defined $source || $source eq ''; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $source or $source eq ""
MC/DC100%2/2
not defined $source or $source eq ""
not defined $source
$source eq ""
Truth table100%3/3
not(A) or B
A= not defined $sourceB= $source eq ""
| |||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||
| 547 | 46 | ▶ | if ($XS_PARSE_QUERY_STRING) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 548 | 35 | ▶ | $self->_set_query_params( | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
CGI::Deurl::XS::parse_query_string($source) || {}
MC/DC0%0/1
CGI::Deurl::XS::parse_query_string($source) || {}
CGI::Deurl::XS::parse_query_string($source)
Truth table50%1/2
A
A= CGI::Deurl::XS::parse_query_string($source)
| |||||||||||||||||||||||||||||||||||||||||
| 549 | CGI::Deurl::XS::parse_query_string($source) || {} | ||||||||||||||||||||||||||||||||||||||||
| 550 | ); | ||||||||||||||||||||||||||||||||||||||||
| 551 | 34 | return $self->_query_params; | |||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||
| 554 | 11 | foreach my $token ( split /[&;]/, $source ) { | |||||||||||||||||||||||||||||||||||||||
| 555 | 38 | my ( $key, $val ) = split( /=/, $token ); | |||||||||||||||||||||||||||||||||||||||
| 556 | 38 | ▶ | next unless defined $key; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 557 | 38 | ▶ | $val = ( defined $val ) ? $val : ''; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 558 | 38 | $key = $self->_url_decode($key); | |||||||||||||||||||||||||||||||||||||||
| 559 | 38 | $val = $self->_url_decode($val); | |||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||
| 561 | # looking for multi-value params | ||||||||||||||||||||||||||||||||||||||||
| 562 | 38 | ▶ | if ( exists $query_params->{$key} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 563 | 7 | my $prev_val = $query_params->{$key}; | |||||||||||||||||||||||||||||||||||||||
| 564 | 7 | ▶ | if ( is_arrayref($prev_val) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 565 | 2 | push @{ $query_params->{$key} }, $val; | |||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||
| 567 | else { | ||||||||||||||||||||||||||||||||||||||||
| 568 | 5 | $query_params->{$key} = [ $prev_val, $val ]; | |||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||
| 572 | # simple value param (first time we see it) | ||||||||||||||||||||||||||||||||||||||||
| 573 | else { | ||||||||||||||||||||||||||||||||||||||||
| 574 | 31 | $query_params->{$key} = $val; | |||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||
| 577 | 11 | $self->_set_query_params( $query_params ); | |||||||||||||||||||||||||||||||||||||||
| 578 | 11 | return $self->_query_params; | |||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||
| 581 | 991 | ▶ | sub _build_uploads { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_uploads: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||
| 582 | 991 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||
| 584 | # parse body and build body params | ||||||||||||||||||||||||||||||||||||||||
| 585 | 991 | my $body_params = $self->_body_params; | |||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||
| 587 | 990 | my $uploads = $self->SUPER::uploads; | |||||||||||||||||||||||||||||||||||||||
| 588 | 990 | my %uploads; | |||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||
| 590 | 990 | for my $name ( keys %$uploads ) { | |||||||||||||||||||||||||||||||||||||||
| 591 | my @uploads = map Dancer2::Core::Request::Upload->new( | ||||||||||||||||||||||||||||||||||||||||
| 592 | # For back-compatibility, we use a HashRef of headers | ||||||||||||||||||||||||||||||||||||||||
| 593 | 22 | headers => {@{$_->{headers}->psgi_flatten_without_sort}}, | |||||||||||||||||||||||||||||||||||||||
| 594 | tempname => $_->{tempname}, | ||||||||||||||||||||||||||||||||||||||||
| 595 | size => $_->{size}, | ||||||||||||||||||||||||||||||||||||||||
| 596 | 16 | filename => $self->_decode( $_->{filename}, 'upload filename' ), | |||||||||||||||||||||||||||||||||||||||
| 597 | ), $uploads->get_all($name); | ||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||
| 599 | 16 | ▶ | $uploads{$name} = @uploads > 1 ? \@uploads : $uploads[0]; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||
| 601 | # support access to the filename as a normal param | ||||||||||||||||||||||||||||||||||||||||
| 602 | 16 | my @filenames = map $_->{'filename'}, @uploads; | |||||||||||||||||||||||||||||||||||||||
| 603 | 16 | ▶ | $self->{_body_params}{$name} = | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 604 | @filenames > 1 ? \@filenames : $filenames[0]; | ||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||
| 607 | 990 | $self->{uploads} = \%uploads; | |||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||
| 610 | # XXX: incompatible with Plack::Request | ||||||||||||||||||||||||||||||||||||||||
| 611 | 767 | ▶ | sub cookies { $_[0]->{'cookies'} ||= $_[0]->_build_cookies } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
cookies: called CC=2 SCAR=7.2
Pod
documented
Condition66%2/3
$_[0]{"cookies"} ||= $_[0]->_build_cookies
MC/DC0%0/2
$_[0]{"cookies"} ||= $_[0]->_build_cookies
$_[0]{"cookies"}
$_[0]->_build_cookies
Truth table66%2/3
A ||= B
A= $_[0]{"cookies"}B= $_[0]->_build_cookies
| |||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||
| 613 | 649 | ▶ | sub _build_cookies { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_cookies: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||
| 614 | 649 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 615 | 649 | my $cookies = {}; | |||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||
| 617 | 649 | my $http_cookie = $self->header('Cookie'); | |||||||||||||||||||||||||||||||||||||||
| 618 | 649 | ▶ | return $cookies unless defined $http_cookie; # nothing to do | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||
| 620 | 70 | ▶ | if ( $XS_HTTP_COOKIES ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | $cookies = HTTP::XSCookies::crush_cookie($http_cookie); | |||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||
| 623 | else { | ||||||||||||||||||||||||||||||||||||||||
| 624 | # handle via Plack::Request | ||||||||||||||||||||||||||||||||||||||||
| 625 | 70 | $cookies = $self->SUPER::cookies(); | |||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||
| 628 | # convert to objects | ||||||||||||||||||||||||||||||||||||||||
| 629 | 70 | ▶ | while (my ($name, $value) = each %{$cookies}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 630 | 73 | ▶ | $cookies->{$name} = Dancer2::Core::Cookie->new( | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 631 | name => $name, | ||||||||||||||||||||||||||||||||||||||||
| 632 | # HTTP::XSCookies v0.17+ will do the split and return an arrayref | ||||||||||||||||||||||||||||||||||||||||
| 633 | value => is_arrayref($value) ? $value : [split '&', $value ] | ||||||||||||||||||||||||||||||||||||||||
| 634 | ); | ||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||
| 636 | 70 | return $cookies; | |||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||
| 639 | # poor man's clone | ||||||||||||||||||||||||||||||||||||||||
| 640 | 60 | ▶ | sub _shallow_clone { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shallow_clone: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||
| 641 | 60 | my ($self, $params, $options) = @_; | |||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||
| 643 | # shallow clone $env; we don't want to alter the existing one | ||||||||||||||||||||||||||||||||||||||||
| 644 | # in $self, then merge any overridden values | ||||||||||||||||||||||||||||||||||||||||
| 645 | 60 | ▶ | my $env = { %{ $self->env }, %{ $options || {} } }; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options || {}
MC/DC0%0/1
$options || {}
$options
Truth table50%1/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||
| 647 | 60 | my $new_request = __PACKAGE__->new( | |||||||||||||||||||||||||||||||||||||||
| 648 | env => $env, | ||||||||||||||||||||||||||||||||||||||||
| 649 | body_params => {}, | ||||||||||||||||||||||||||||||||||||||||
| 650 | ); | ||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||
| 652 | # Clone and merge query params | ||||||||||||||||||||||||||||||||||||||||
| 653 | 60 | my $new_params = $self->params; | |||||||||||||||||||||||||||||||||||||||
| 654 | 60 | ▶ | $new_request->{_query_params} = { %{ $self->{_query_params} || {} } }; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'_query_params'} || {}
MC/DC100%1/1
$self->{'_query_params'} || {}
$self->{'_query_params'}
Truth table100%2/2
A
A= $self->{'_query_params'}
| |||||||||||||||||||||||||||||||||||||||||
| 655 | 60 | $new_request->{_strict_utf8} = $self->{_strict_utf8}; | |||||||||||||||||||||||||||||||||||||||
| 656 | 60 | $new_request->{query_parameters} = $self->query_parameters->clone; | |||||||||||||||||||||||||||||||||||||||
| 657 | 60 | ▶ | for my $key ( keys %{ $params || {} } ) { | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params || {}
MC/DC100%1/1
$params || {}
$params
Truth table100%2/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||
| 658 | 12 | my $value = $params->{$key}; | |||||||||||||||||||||||||||||||||||||||
| 659 | 12 | $new_params->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||
| 660 | 12 | $new_request->{_query_params}->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||
| 661 | 12 | $new_request->{query_parameters}->add( $key => $value ); | |||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||
| 664 | # Copy params (these are already decoded) | ||||||||||||||||||||||||||||||||||||||||
| 665 | 60 | $new_request->{_params} = $new_params; | |||||||||||||||||||||||||||||||||||||||
| 666 | 60 | $new_request->{_body_params} = $self->{_body_params}; | |||||||||||||||||||||||||||||||||||||||
| 667 | 60 | $new_request->{_route_params} = $self->{_route_params}; | |||||||||||||||||||||||||||||||||||||||
| 668 | 60 | $new_request->{headers} = $self->headers; | |||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||
| 670 | # Copy remaining settings | ||||||||||||||||||||||||||||||||||||||||
| 671 | 60 | $new_request->{is_behind_proxy} = $self->{is_behind_proxy}; | |||||||||||||||||||||||||||||||||||||||
| 672 | 60 | $new_request->{vars} = $self->{vars}; | |||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||
| 674 | # Clone any existing decoded & cached body params. (GH#1116 GH#1269) | ||||||||||||||||||||||||||||||||||||||||
| 675 | 60 | $new_request->{'body_parameters'} = $self->body_parameters->clone; | |||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||
| 677 | # Delete merged HMV parameters, allowing them to be reconstructed on first use. | ||||||||||||||||||||||||||||||||||||||||
| 678 | 60 | delete $new_request->{'merged_parameters'}; | |||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||
| 680 | 60 | return $new_request; | |||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||
| 684 | 751 | ▶ | sub _set_route { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_route: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 685 | 751 | my ( $self, $route ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 686 | 751 | $self->{'route'} = $route; | |||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||
| 689 | 6 | ▶ | sub route { $_[0]->{'route'} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
route: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||
| 691 | 2 | ▶ | sub body_data { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
body_data: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 692 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 693 | 2 | ▶ | return $self->data if $self->serializer; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 694 | 1 | $self->_body_params; | |||||||||||||||||||||||||||||||||||||||
| 695 | 1 | ▶ | return $self->{_body_params} if keys %{ $self->{_body_params} }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 696 | 1 | return $self->body; | |||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||
| 699 | 191 | 1; | |||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||
| 701 | __END__ | ||||||||||||||||||||||||||||||||||||||||