blib/lib/Web/Machine/FSM/States.pm

filter: Statementstmt 98.7% 383 / 388 Branchbran 93.5% 189 / 202 Conditioncond 85.7% 30 / 35 MC/DCmcdc 73.9% 17 / 23 Subroutinesub 98.7% 79 / 80 Podpod 0.0% 0 / 61 totaltotal 88.4% 698 / 789 CC 114 SCAR 12.6
CC
114
Cov
96%
n11
10.0
g7
8.0
f6
8.0
CRAP 3.5
« blib/lib/Web/Machine/Util.pm ↑ Summary blib/lib/Web/Machine/Util/BodyEncoding.pm »
1 package Web::Machine::FSM::States;
2 # ABSTRACT: The States for Web Machine
3  
4 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 19 our $VERSION = '0.17';
8  
9 19 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 19 ▶use Hash::MultiValue;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 19 ▶use Carp qw[ confess ];
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 19 ▶use Web::Machine::Util qw[
Subroutine BEGIN: called CC=1 SCAR=0.0
15 first
16 pair_key
17 pair_value
18 create_header
19 19 ];
20 19 ▶use Web::Machine::Util::BodyEncoding qw[
Subroutine BEGIN: called CC=1 SCAR=0.0
21 encode_body_if_set
22 encode_body
23 19 ];
24 19 ▶use Web::Machine::Util::ContentNegotiation qw[
Subroutine BEGIN: called CC=1 SCAR=0.0
25 choose_media_type
26 match_acceptable_media_type
27 choose_language
28 choose_charset
29 choose_encoding
30 19 ];
31  
32 19 ▶use Sub::Exporter -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
33 exports => [qw[
34 start_state
35 is_status_code
36 is_new_state
37 get_state_name
38 get_state_desc
39 ]]
40 19 };
41  
42 19 my %STATE_DESC;
43  
44 # my exports ...
45  
46 138 ▶sub start_state { \&b13 }
Subroutine start_state: called CC=1 SCAR=0.0
Pod undocumented
47 3076 ▶sub is_status_code { ref $_[0] eq 'SCALAR' }
Subroutine is_status_code: called CC=1 SCAR=0.0
Pod undocumented
48 2728 ▶sub is_new_state { ref $_[0] eq 'CODE' }
Subroutine is_new_state: called CC=1 SCAR=0.0
Pod undocumented
49 1792 ▶sub get_state_name { B::svref_2object( shift )->GV->NAME }
Subroutine get_state_name: called CC=1 SCAR=0.0
Pod undocumented
50 0 ▶sub get_state_desc { $STATE_DESC{ ref $_[0] ? get_state_name( shift ) : shift } }
Subroutine get_state_desc: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
51  
52 # some utilities ...
53  
54 26 ▶sub _unquote_header {
Subroutine _unquote_header: called CC=2 SCAR=7.6
55 26 my $value = shift;
56 26 ▶ if ( $value =~ /^"(.*)"$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^"(.*)"$/) 0 26 26
57 0 return $1;
58 }
59 26 return $value;
60 }
61  
62 10 ▶sub _ensure_quoted_header {
Subroutine _ensure_quoted_header: called CC=2 SCAR=7.1
63 10 my $value = shift;
64 10 ▶ return $value if $value =~ /^"(.*)"$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^"(.*)"$/ 0 10 10
65 10 return '"' . $value . '"';
66 }
67  
68 12 ▶sub _get_acceptable_content_type_handler {
Subroutine _get_acceptable_content_type_handler: called CC=3 SCAR=11.0
69 12 my ($resource, $request) = @_;
70 12 ▶ my $acceptable = match_acceptable_media_type(
Condition100%2/2
$request->header('Content-Type') || 'application/octet-stream'
l!l
75
MC/DC100%1/1
$request->header('Content-Type') || 'application/octet-stream'
$request->header('Content-Type')
Truth table100%2/2
A
A= $request->header('Content-Type')
Aresult
11
00
71 ($request->header('Content-Type') || 'application/octet-stream'),
72 $resource->content_types_accepted
73 );
74 12 ▶ return \415 unless $acceptable;
Branch: 1 branch
BranchTrueFalseTotal
unless $acceptable 2 10 12
75 10 return pair_value( $acceptable );
76 }
77  
78 53 ▶sub _add_caching_headers {
Subroutine _add_caching_headers: called CC=4 SCAR=14.0
79 53 my ($resource, $response) = @_;
80 53 ▶ if ( my $etag = $resource->generate_etag ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $etag = $resource->generate_etag) 10 43 53
81 10 $response->header( 'Etag' => _ensure_quoted_header( $etag ) );
82 }
83 53 ▶ if ( my $expires = $resource->expires ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $expires = $resource->expires) 0 53 53
84 0 $response->header( 'Expires' => $expires );
85 }
86 53 ▶ if ( my $modified = $resource->last_modified ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $modified = $resource->last_modified) 10 43 53
87 10 $response->header( 'Last-Modified' => $modified );
88 }
89 }
90  
91 8 ▶sub _handle_304 {
Subroutine _handle_304: called CC=1 SCAR=0.0
92 8 my ($resource, $response) = @_;
93 8 $response->headers->remove_header('Content-Type');
94 8 $response->headers->remove_header('Content-Encoding');
95 8 $response->headers->remove_header('Content-Language');
96 8 _add_caching_headers($resource, $response);
97 8 return \304;
98 }
99  
100 10 ▶sub _is_redirect {
Subroutine _is_redirect: called CC=2 SCAR=6.9
101 10 my ($response) = @_;
102 # NOTE:
103 # this makes a guess that the user has
104 # told the Plack::Response that they
105 # want to redirect. We do this based
106 # on the fact that the ->redirect method
107 # will set the status, while in almost all
108 # other cases the status of the response
109 # will not be set yet.
110 # - SL
111 10 ▶ return 1 if $response->status;
Branch: 1 branch
BranchTrueFalseTotal
if $response->status 3 7 10
112 7 return;
113 }
114  
115 384 ▶sub _metadata {
Subroutine _metadata: called CC=1 SCAR=0.0
116 384 my ($request) = @_;
117 384 return $request->env->{'web.machine.context'};
118 }
119  
120 ## States
121  
122 19 $STATE_DESC{'b13'} = 'service_available';
123 138 ▶sub b13 {
Subroutine b13: called CC=2 SCAR=6.9
Pod undocumented
124 138 my ($resource, $request, $response) = @_;
125 138 ▶ $resource->service_available ? \&b12 : \503;
Branch: 1 branch
BranchTrueFalseTotal
$resource->service_available ? : 135 2 137
126 }
127  
128 19 $STATE_DESC{'b12'} = 'known_method';
129 135 ▶sub b12 {
Subroutine b12: called CC=2 SCAR=6.9
Pod undocumented
130 135 my ($resource, $request, $response) = @_;
131 135 my $method = $request->method;
132 135 ▶ (grep { $method eq $_ } @{ $resource->known_methods }) ? \&b11 : \501;
Branch: 1 branch
BranchTrueFalseTotal
grep({$method eq $_;} @{$resource->known_methods;}) ? : 134 1 135
133 }
134  
135 19 $STATE_DESC{'b11'} = 'uri_too_long';
136 134 ▶sub b11 {
Subroutine b11: called CC=2 SCAR=6.9
Pod undocumented
137 134 my ($resource, $request, $response) = @_;
138 134 ▶ $resource->uri_too_long( $request->uri ) ? \414 : \&b10;
Branch: 1 branch
BranchTrueFalseTotal
$resource->uri_too_long($request->uri) ? : 1 133 134
139 }
140  
141 19 $STATE_DESC{'b10'} = 'method_allowed';
142 133 ▶sub b10 {
Subroutine b10: called CC=2 SCAR=6.9
Pod undocumented
143 133 my ($resource, $request, $response) = @_;
144 133 my $method = $request->method;
145 133 my @allowed_methods = @{ $resource->allowed_methods };
146 133 ▶ return \&b9 if grep { $method eq $_ } @allowed_methods;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$method eq $_;} @allowed_methods 132 1 133
147 1 $response->header('Allow' => join ", " => @allowed_methods );
148 1 return \405;
149 }
150  
151 19 $STATE_DESC{'b9'} = 'malformed_request';
152 132 ▶sub b9 {
Subroutine b9: called CC=2 SCAR=6.9
Pod undocumented
153 132 my ($resource, $request, $response) = @_;
154 132 ▶ $resource->malformed_request ? \400 : \&b8;
Branch: 1 branch
BranchTrueFalseTotal
$resource->malformed_request ? : 1 131 132
155 }
156  
157 19 $STATE_DESC{'b8'} = 'is_authorized';
158 131 ▶sub b8 {
Subroutine b8: called CC=5 SCAR=16.1
Pod undocumented
159 131 my ($resource, $request, $response) = @_;
160 131 my $result = $resource->is_authorized( $request->header('Authorization') );
161 # if we get back a status, then use it
162 131 ▶ if ( is_status_code( $result ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_status_code($result)) { } 1 130 131
elsif (defined $result and "$result" eq '1') { } 125 5 130
163 1 return $result;
164 }
165 # if we just get back true, then
166 # move onto the next state
167 ▶ elsif ( defined $result && "$result" eq "1" ) {
Condition100%3/3
defined $result and "$result" eq 1
!ll&&!rl&&r
14125
MC/DC100%2/2
defined $result and "$result" eq 1
defined $result "$result" eq 1
Truth table100%3/3
A and B
A= defined $resultB= "$result" eq 1
ABresult
0X0
100
111
168 125 return \&b7
169 }
170 # anything else will either be
171 # a WWW-Authenticate header or
172 # a simple false value
173 else {
174 5 ▶ if ( $result ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 3 2 5
175 3 $response->header( 'WWW-Authenticate' => $result );
176 }
177 5 return \401;
178 }
179 }
180  
181 19 $STATE_DESC{'b7'} = 'forbidden';
182 125 ▶sub b7 {
Subroutine b7: called CC=2 SCAR=6.9
Pod undocumented
183 125 my ($resource, $request, $response) = @_;
184 125 ▶ $resource->forbidden ? \403 : \&b6;
Branch: 1 branch
BranchTrueFalseTotal
$resource->forbidden ? : 2 123 125
185 }
186  
187 19 $STATE_DESC{'b6'} = 'content_headers_okay';
188 123 ▶sub b6 {
Subroutine b6: called CC=2 SCAR=6.9
Pod undocumented
189 123 my ($resource, $request, $response) = @_;
190  
191 # FIX-ME
192 # there is a better way to do this,
193 # also, HTTP::Headers will usually
194 # group things into arrays, so we
195 # can either avoid or better take
196 # advantage of Hash::MultiValue.
197 # But we are almost certainly not
198 # handling that case properly maybe.
199 123 my $content_headers = Hash::MultiValue->new;
200 185 ▶ $request->headers->scan(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
201 185 my ($name, $value) = @_;
202 185 ▶ $content_headers->add( $name, $value ) if (lc $name) =~ /^content-/;
Branch: 1 branch
BranchTrueFalseTotal
if lc($name) =~ /^content-/ 48 137 185
203 123 });
204  
205 123 ▶ $resource->valid_content_headers( $content_headers ) ? \&b5 : \501;
Branch: 1 branch
BranchTrueFalseTotal
$resource->valid_content_headers($content_headers) ? : 122 1 123
206 }
207  
208 19 $STATE_DESC{'b5'} = 'known_content_type';
209 122 ▶sub b5 {
Subroutine b5: called CC=2 SCAR=6.9
Pod undocumented
210 122 my ($resource, $request, $response) = @_;
211 122 ▶ $resource->known_content_type( $request->header('Content-Type') ) ? \&b4 : \415;
Branch: 1 branch
BranchTrueFalseTotal
$resource->known_content_type($request->header('Content-Type')) ? : 121 1 122
212 }
213  
214 19 $STATE_DESC{'b4'} = 'request_entity_too_large';
215 121 ▶sub b4 {
Subroutine b4: called CC=2 SCAR=6.9
Pod undocumented
216 121 my ($resource, $request, $response) = @_;
217 121 ▶ $resource->valid_entity_length( $request->content_length ) ? \&b3 : \413;
Branch: 1 branch
BranchTrueFalseTotal
$resource->valid_entity_length($request->content_length) ? : 120 1 121
218 }
219  
220 19 $STATE_DESC{'b3'} = 'method_is_options';
221 120 ▶sub b3 {
Subroutine b3: called CC=2 SCAR=6.9
Pod undocumented
222 120 my ($resource, $request, $response) = @_;
223 120 ▶ if ( $request->method eq 'OPTIONS' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($request->method eq "OPTIONS") 1 119 120
224 1 $response->headers( $resource->options );
225 1 return \200;
226 }
227 119 return \&c3
228 }
229  
230 19 $STATE_DESC{'c3'} = 'accept_header_exists';
231 119 ▶sub c3 {
Subroutine c3: called CC=2 SCAR=6.9
Pod undocumented
232 119 my ($resource, $request, $response) = @_;
233 119 my $metadata = _metadata($request);
234 119 ▶ if ( !$request->header('Accept') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($request->header("Accept")) 106 13 119
235 106 $metadata->{'Content-Type'} = create_header( MediaType => (
236 pair_key( $resource->content_types_provided->[0] )
237 ));
238 106 return \&d4
239 }
240 13 return \&c4;
241 }
242  
243 19 $STATE_DESC{'c4'} = 'acceptable_media_type_available';
244 13 ▶sub c4 {
Subroutine c4: called CC=2 SCAR=6.9
Pod undocumented
245 13 my ($resource, $request, $response) = @_;
246 13 my $metadata = _metadata($request);
247  
248 13 my @types = map { pair_key( $_ ) } @{ $resource->content_types_provided };
249  
250 13 ▶ if ( my $chosen_type = choose_media_type( \@types, $request->header('Accept') ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $chosen_type = choose_media_type(\@types, $request->header("Accept"))) 12 1 13
251 12 $metadata->{'Content-Type'} = $chosen_type;
252 12 return \&d4;
253 }
254  
255 1 return \406;
256 }
257  
258 19 $STATE_DESC{'d4'} = 'accept_language_header_exists';
259 118 ▶sub d4 {
Subroutine d4: called CC=2 SCAR=6.9
Pod undocumented
260 118 my ($resource, $request, $response) = @_;
261 118 ▶ (not $request->header('Accept-Language')) ? \&e5 : \&d5;
Branch: 1 branch
BranchTrueFalseTotal
!$request->header('Accept-Language') ? : 101 17 118
262 }
263  
264  
265 19 $STATE_DESC{'d5'} = 'accept_language_choice_available';
266 17 ▶sub d5 {
Subroutine d5: called CC=3 SCAR=11.0
Pod undocumented
267 17 my ($resource, $request, $response) = @_;
268 17 my $metadata = _metadata($request);
269  
270 17 ▶ if ( my $language = choose_language( $resource->languages_provided, $request->header('Accept-Language') ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $language = choose_language($resource->languages_provided, $request->header("Accept-Language"))) 15 2 17
271 15 $metadata->{'Language'} = $language;
272 # handle the short circuit here ...
273 15 ▶ $response->header( 'Content-Language' => $language ) if "$language" ne "1";
Branch: 1 branch
BranchTrueFalseTotal
if "$language" ne 1 14 1 15
274 15 return \&e5;
275 }
276  
277 2 return \406;
278 }
279  
280 19 $STATE_DESC{'e5'} = 'accept_charset_exists';
281 116 ▶sub e5 {
Subroutine e5: called CC=2 SCAR=6.9
Pod undocumented
282 116 my ($resource, $request, $response) = @_;
283 116 ▶ (not $request->header('Accept-Charset')) ? \&f6 : \&e6;
Branch: 1 branch
BranchTrueFalseTotal
!$request->header('Accept-Charset') ? : 94 22 116
284 }
285  
286 19 $STATE_DESC{'e6'} = 'accept_charset_choice_available';
287 22 ▶sub e6 {
Subroutine e6: called CC=3 SCAR=11.0
Pod undocumented
288 22 my ($resource, $request, $response) = @_;
289 22 my $metadata = _metadata($request);
290  
291 22 ▶ if ( my $charset = choose_charset( $resource->charsets_provided, $request->header('Accept-Charset') ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $charset = choose_charset($resource->charsets_provided, $request->header("Accept-Charset"))) 20 2 22
292 # handle the short circuit here ...
293 20 ▶ $metadata->{'Charset'} = $charset if "$charset" ne "1";
Branch: 1 branch
BranchTrueFalseTotal
if "$charset" ne 1 20 0 20
294 20 return \&f6;
295 }
296  
297 2 return \406;
298 }
299  
300 19 $STATE_DESC{'f6'} = 'accept_encoding_exists';
301 # (also, set content-type header here, now that charset is chosen)
302 114 ▶sub f6 {
Subroutine f6: called CC=8 SCAR=20.8
Pod undocumented
303 114 my ($resource, $request, $response) = @_;
304 114 my $metadata = _metadata($request);
305  
306 # If the client doesn't provide an Accept-Charset header we should just
307 # encode with the default.
308 114 ▶ if ( $resource->default_charset && !$request->header('Accept-Charset') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resource->default_charset and not $request->header("Accept-Charset")) 4 110 114
Condition100%3/3
$resource->default_charset and not $request->header("Accept-Charset")
!ll&&!rl&&r
100104
MC/DC100%2/2
$resource->default_charset and not $request->header("Accept-Charset")
$resource->default_charset not $request->header("Accept-Charset")
Truth table100%3/3
A and not(B)
A= $resource->default_charsetB= not $request->header("Accept-Charset")
ABresult
0X0
100
111
309 4 my $default = $resource->default_charset;
310 4 ▶ $metadata->{'Charset'} = ref $default ? pair_key($default) : $default;
Branch: 1 branch
BranchTrueFalseTotal
ref $default ? : 2 2 4
311 }
312  
313 114 ▶ if ( my $charset = $metadata->{'Charset'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $charset = $metadata->{"Charset"}) 24 90 114
314 # Add the charset to the content type now ...
315 24 $metadata->{'Content-Type'}->add_param( 'charset' => $charset );
316 }
317 # put the content type in the header now ...
318 114 $response->header( 'Content-Type' => $metadata->{'Content-Type'}->as_string );
319  
320 114 ▶ if ( $request->header('Accept-Encoding') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($request->header('Accept-Encoding')) { } 13 101 114
321 13 return \&f7
322 }
323 else {
324 101 ▶ if ( my $encoding = choose_encoding( $resource->encodings_provided, "identity;q=1.0,*;q=0.5" ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $encoding = choose_encoding($resource->encodings_provided, 'identity;q=1.0,*;q=0.5')) { } 97 4 101
325 97 ▶ $response->header( 'Content-Encoding' => $encoding ) unless $encoding eq 'identity';
Branch: 1 branch
BranchTrueFalseTotal
unless $encoding eq "identity" 19 78 97
326 97 $metadata->{'Content-Encoding'} = $encoding;
327 97 return \&g7;
328 }
329 else {
330 4 return \406;
331 }
332 }
333 }
334  
335 19 $STATE_DESC{'f7'} = 'accept_encoding_choice_available';
336 13 ▶sub f7 {
Subroutine f7: called CC=3 SCAR=11.0
Pod undocumented
337 13 my ($resource, $request, $response) = @_;
338 13 my $metadata = _metadata($request);
339  
340 13 ▶ if ( my $encoding = choose_encoding( $resource->encodings_provided, $request->header('Accept-Encoding') ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $encoding = choose_encoding($resource->encodings_provided, $request->header("Accept-Encoding"))) 9 4 13
341 9 ▶ $response->header( 'Content-Encoding' => $encoding ) unless $encoding eq 'identity';
Branch: 1 branch
BranchTrueFalseTotal
unless $encoding eq "identity" 8 1 9
342 9 $metadata->{'Content-Encoding'} = $encoding;
343 9 return \&g7;
344 }
345  
346 4 return \406;
347 }
348  
349 19 $STATE_DESC{'g7'} = 'resource_exists';
350 106 ▶sub g7 {
Subroutine g7: called CC=8 SCAR=20.8
Pod undocumented
351 106 my ($resource, $request, $response) = @_;
352  
353 # NOTE:
354 # set Vary header here since we are
355 # done with content negotiation
356 # - SL
357 106 my @variances = @{ $resource->variances };
358  
359 106 ▶ push @variances => 'Accept' if scalar @{ $resource->content_types_provided } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$resource->content_types_provided;} > 1 1 105 106
360 106 ▶ push @variances => 'Accept-Encoding' if scalar keys %{ $resource->encodings_provided } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %{$resource->encodings_provided;} > 1 12 94 106
361 106 ▶ push @variances => 'Accept-Charset' if defined $resource->charsets_provided && scalar @{ $resource->charsets_provided } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $resource->charsets_provided and scalar @{$resource->charsets_provided;} > 1 17 89 106
Condition66%2/3
defined $resource->charsets_provided and scalar @{$resource->charsets_provided;} > 1
!ll&&!rl&&r
08917
MC/DC50%1/2
defined $resource->charsets_provided and scalar @{$resource->charsets_provided;} > 1
defined $resource->charsets_provided scalar @{$resource->charsets_provided;} > 1
Truth table66%2/3
A and B
A= defined $resource->charsets_providedB= scalar @{$resource->charsets_provided;} > 1
ABresult
0X0
100
111
362 106 ▶ push @variances => 'Accept-Language' if scalar @{ $resource->languages_provided } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$resource->languages_provided;} > 1 2 104 106
363  
364 106 ▶ $response->header( 'Vary' => join ', ' => @variances ) if @variances;
Branch: 1 branch
BranchTrueFalseTotal
if @variances 19 87 106
365  
366 106 ▶ $resource->resource_exists ? \&g8 : \&h7;
Branch: 1 branch
BranchTrueFalseTotal
$resource->resource_exists ? : 70 36 106
367 }
368  
369 19 $STATE_DESC{'g8'} = 'if_match_exists';
370 70 ▶sub g8 {
Subroutine g8: called CC=2 SCAR=6.9
Pod undocumented
371 70 my ($resource, $request, $response) = @_;
372 70 ▶ $request->header('If-Match') ? \&g9 : \&h10;
Branch: 1 branch
BranchTrueFalseTotal
$request->header('If-Match') ? : 3 67 70
373 }
374  
375 19 $STATE_DESC{'g9'} = 'if_match_is_wildcard';
376 3 ▶sub g9 {
Subroutine g9: called CC=2 SCAR=6.9
Pod undocumented
377 3 my ($resource, $request, $response) = @_;
378 3 ▶ _unquote_header( $request->header('If-Match') ) eq "*" ? \&h10 : \&g11;
Branch: 1 branch
BranchTrueFalseTotal
_unquote_header($request->header('If-Match')) eq '*' ? : 1 2 3
379 }
380  
381 19 $STATE_DESC{'g11'} = 'etag_in_if_match_list';
382 2 ▶sub g11 {
Subroutine g11: called CC=2 SCAR=6.9
Pod undocumented
383 2 my ($resource, $request, $response) = @_;
384 2 my @etags = map { _unquote_header( $_ ) } split /\s*\,\s*/ => $request->header('If-Match');
385 2 my $etag = $resource->generate_etag;
386 2 ▶ (grep { $etag eq $_ } @etags) ? \&h10 : \412;
Branch: 1 branch
BranchTrueFalseTotal
grep({$etag eq $_;} @etags) ? : 1 1 2
387 }
388  
389 19 $STATE_DESC{'h7'} = 'if_match_exists_and_if_match_is_wildcard';
390 36 ▶sub h7 {
Subroutine h7: called CC=3 SCAR=11.0
Pod undocumented
391 36 my ($resource, $request, $response) = @_;
392 36 ▶ ($request->header('If-Match') && _unquote_header( $request->header('If-Match') ) eq "*") ? \412 : \&i7;
Branch: 1 branch
BranchTrueFalseTotal
$request->header('If-Match') && _unquote_header($request->header('If-Match')) eq '*' ? : 6 30 36
Condition100%3/3
$request->header("If-Match") and _unquote_header($request->header("If-Match")) eq "*"
!ll&&!rl&&r
2826
MC/DC100%2/2
$request->header("If-Match") and _unquote_header($request->header("If-Match")) eq "*"
$request->header("If-Match") _unquote_header($request->header("If-Match")) eq "*"
Truth table100%3/3
A and B
A= $request->header("If-Match")B= _unquote_header($request->header("If-Match")) eq "*"
ABresult
0X0
100
111
393 }
394  
395 19 $STATE_DESC{'h10'} = 'if_unmodified_since_exists';
396 69 ▶sub h10 {
Subroutine h10: called CC=2 SCAR=6.9
Pod undocumented
397 69 my ($resource, $request, $response) = @_;
398 69 ▶ $request->header('If-Unmodified-Since') ? \&h11 : \&i12;
Branch: 1 branch
BranchTrueFalseTotal
$request->header('If-Unmodified-Since') ? : 6 63 69
399 }
400  
401 19 $STATE_DESC{'h11'} = 'if_unmodified_since_is_valid_date';
402 6 ▶sub h11 {
Subroutine h11: called CC=2 SCAR=7.2
Pod undocumented
403 6 my ($resource, $request, $response) = @_;
404 6 my $metadata = _metadata($request);
405 6 ▶ if ( my $date = $request->header('If-Unmodified-Since') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $date = $request->header("If-Unmodified-Since")) 6 0 6
406 6 $metadata->{'If-Unmodified-Since'} = $date;
407 6 return \&h12;
408 }
409 0 return \&i12;
410 }
411  
412 19 $STATE_DESC{'h12'} = 'last_modified_is_greater_than_if_unmodified_since';
413 6 ▶sub h12 {
Subroutine h12: called CC=3 SCAR=11.0
Pod undocumented
414 6 my ($resource, $request, $response) = @_;
415 6 my $metadata = _metadata($request);
416 defined $resource->last_modified
417 &&
418 6 ▶ ($resource->last_modified->epoch > $metadata->{'If-Unmodified-Since'}->epoch)
Branch: 1 branch
BranchTrueFalseTotal
defined $resource->last_modified && $resource->last_modified->epoch > $metadata->{'If-Unmodified-Since'}->epoch ? : 3 3 6
Condition66%2/3
defined $resource->last_modified and $resource->last_modified->epoch > $metadata->{"If-Unmodified-Since"}->epoch
!ll&&!rl&&r
033
MC/DC50%1/2
defined $resource->last_modified and $resource->last_modified->epoch > $metadata->{"If-Unmodified-Since"}->epoch
defined $resource->last_modified $resource->last_modified->epoch > $metadata->{"If-Unmodified-Since"}->epoch
Truth table66%2/3
A and B
A= defined $resource->last_modifiedB= $resource->last_modified->epoch > $metadata->{"If-Unmodified-Since"}->epoch
ABresult
0X0
100
111
419 ? \412 : \&i12;
420 }
421  
422 19 $STATE_DESC{'i4'} = 'moved_permanently';
423 8 ▶sub i4 {
Subroutine i4: called CC=3 SCAR=11.0
Pod undocumented
424 8 my ($resource, $request, $response) = @_;
425 8 ▶ if ( my $uri = $resource->moved_permanently ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $uri = $resource->moved_permanently) 2 6 8
426 2 ▶ if ( is_status_code( $uri ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_status_code($uri)) 1 1 2
427 1 return $uri;
428 }
429 1 $response->header('Location' => $uri );
430 1 return \301;
431 }
432 6 return \&p3;
433 }
434  
435 19 $STATE_DESC{'i7'} = 'method_is_put';
436 30 ▶sub i7 {
Subroutine i7: called CC=2 SCAR=6.9
Pod undocumented
437 30 my ($resource, $request, $response) = @_;
438 30 ▶ $request->method eq 'PUT' ? \&i4 : \&k7
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'PUT' ? : 8 22 30
439 }
440  
441 19 $STATE_DESC{'i12'} = 'if_none_match_exists';
442 66 ▶sub i12 {
Subroutine i12: called CC=2 SCAR=6.9
Pod undocumented
443 66 my ($resource, $request, $response) = @_;
444 66 ▶ $request->header('If-None-Match') ? \&i13 : \&l13
Branch: 1 branch
BranchTrueFalseTotal
$request->header('If-None-Match') ? : 19 47 66
445 }
446  
447 19 $STATE_DESC{'i13'} = 'if_none_match_is_wildcard';
448 19 ▶sub i13 {
Subroutine i13: called CC=2 SCAR=6.9
Pod undocumented
449 19 my ($resource, $request, $response) = @_;
450 19 ▶ $request->header('If-None-Match') eq "*" ? \&j18 : \&k13
Branch: 1 branch
BranchTrueFalseTotal
$request->header('If-None-Match') eq '*' ? : 6 13 19
451 }
452  
453 19 $STATE_DESC{'j18'} = 'method_is_get_or_head';
454 9 ▶sub j18 {
Subroutine j18: called CC=3 SCAR=11.0
Pod undocumented
455 9 my ($resource, $request, $response) = @_;
456 9 ▶ $request->method eq 'GET' || $request->method eq 'HEAD'
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'GET' || $request->method eq 'HEAD' ? : 6 3 9
Condition100%3/3
$request->method eq "GET" or $request->method eq "HEAD"
l!l&&r!l&&!r
333
MC/DC100%2/2
$request->method eq "GET" or $request->method eq "HEAD"
$request->method eq "GET" $request->method eq "HEAD"
Truth table100%3/3
A or B
A= $request->method eq "GET"B= $request->method eq "HEAD"
ABresult
1X1
011
000
457 ? _handle_304( $resource, $response )
458 : \412
459 }
460  
461 19 $STATE_DESC{'k5'} = 'moved_permanently';
462 20 ▶sub k5 {
Subroutine k5: called CC=3 SCAR=11.0
Pod undocumented
463 20 my ($resource, $request, $response) = @_;
464 20 ▶ if ( my $uri = $resource->moved_permanently ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $uri = $resource->moved_permanently) 2 18 20
465 2 ▶ if ( is_status_code( $uri ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_status_code($uri)) 1 1 2
466 1 return $uri;
467 }
468 1 $response->header('Location' => $uri );
469 1 return \301;
470 }
471 18 return \&l5;
472 }
473  
474 19 $STATE_DESC{'k7'} = 'previously_existed';
475 22 ▶sub k7 {
Subroutine k7: called CC=2 SCAR=6.9
Pod undocumented
476 22 my ($resource, $request, $response) = @_;
477 22 ▶ $resource->previously_existed ? \&k5 : \&l7;
Branch: 1 branch
BranchTrueFalseTotal
$resource->previously_existed ? : 20 2 22
478 }
479  
480 19 $STATE_DESC{'k13'} = 'etag_in_if_none_match';
481 13 ▶sub k13 {
Subroutine k13: called CC=3 SCAR=11.0
Pod undocumented
482 13 my ($resource, $request, $response) = @_;
483 13 my @etags = map { _unquote_header( $_ ) } split /\s*\,\s*/ => $request->header('If-None-Match');
484 13 my $etag = $resource->generate_etag;
485 13 ▶ $etag && (grep { $etag eq $_ } @etags) ? \&j18 : \&l13;
Branch: 1 branch
BranchTrueFalseTotal
$etag && grep({$etag eq $_;} @etags) ? : 3 10 13
Condition100%3/3
$etag and grep {$etag eq $_;} @etags
!ll&&!rl&&r
193
MC/DC100%2/2
$etag and grep {$etag eq $_;} @etags
$etag grep {$etag eq $_;} @etags
Truth table100%3/3
A and B
A= $etagB= grep {$etag eq $_;} @etags
ABresult
0X0
100
111
486 }
487  
488 19 $STATE_DESC{'l5'} = 'moved_temporarily';
489 18 ▶sub l5 {
Subroutine l5: called CC=3 SCAR=11.0
Pod undocumented
490 18 my ($resource, $request, $response) = @_;
491 18 ▶ if ( my $uri = $resource->moved_temporarily ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $uri = $resource->moved_temporarily) 2 16 18
492 2 ▶ if ( is_status_code( $uri ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_status_code($uri)) 1 1 2
493 1 return $uri;
494 }
495 1 $response->header('Location' => $uri );
496 1 return \307;
497 }
498 16 return \&m5;
499 }
500  
501 19 $STATE_DESC{'l7'} = 'method_is_post';
502 2 ▶sub l7 {
Subroutine l7: called CC=2 SCAR=6.9
Pod undocumented
503 2 my ($resource, $request, $response) = @_;
504 2 ▶ $request->method eq 'POST' ? \&m7 : \404
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'POST' ? : 1 1 2
505 }
506  
507 19 $STATE_DESC{'l13'} = 'if_modified_since_exists';
508 57 ▶sub l13 {
Subroutine l13: called CC=2 SCAR=6.9
Pod undocumented
509 57 my ($resource, $request, $response) = @_;
510 57 ▶ $request->header('If-Modified-Since') ? \&l14 : \&m16
Branch: 1 branch
BranchTrueFalseTotal
$request->header('If-Modified-Since') ? : 11 46 57
511 }
512  
513 19 $STATE_DESC{'l14'} = 'if_modified_since_is_valid_date';
514 11 ▶sub l14 {
Subroutine l14: called CC=2 SCAR=7.2
Pod undocumented
515 11 my ($resource, $request, $response) = @_;
516 11 my $metadata = _metadata($request);
517 11 ▶ if ( my $date = $request->header('If-Modified-Since') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $date = $request->header("If-Modified-Since")) 11 0 11
518 11 $metadata->{'If-Modified-Since'} = $date;
519 11 return \&l15;
520 }
521 0 return \&m16;
522 }
523  
524 19 $STATE_DESC{'l15'} = 'if_modified_since_greater_than_now';
525 11 ▶sub l15 {
Subroutine l15: called CC=2 SCAR=6.9
Pod undocumented
526 11 my ($resource, $request, $response) = @_;
527 11 my $metadata = _metadata($request);
528 11 ▶ ($metadata->{'If-Modified-Since'}->epoch > (scalar time)) ? \&m16 : \&l17;
Branch: 1 branch
BranchTrueFalseTotal
$metadata->{'If-Modified-Since'}->epoch > scalar time ? : 8 3 11
529 }
530  
531 19 $STATE_DESC{'l17'} = 'last_modified_is_greater_than_if_modified_since';
532 3 ▶sub l17 {
Subroutine l17: called CC=3 SCAR=11.0
Pod undocumented
533 3 my ($resource, $request, $response) = @_;
534 3 my $metadata = _metadata($request);
535 defined $resource->last_modified
536 &&
537 3 ▶ ($resource->last_modified->epoch > $metadata->{'If-Modified-Since'}->epoch)
Branch: 1 branch
BranchTrueFalseTotal
defined $resource->last_modified && $resource->last_modified->epoch > $metadata->{'If-Modified-Since'}->epoch ? : 1 2 3
Condition66%2/3
defined $resource->last_modified and $resource->last_modified->epoch > $metadata->{"If-Modified-Since"}->epoch
!ll&&!rl&&r
021
MC/DC50%1/2
defined $resource->last_modified and $resource->last_modified->epoch > $metadata->{"If-Modified-Since"}->epoch
defined $resource->last_modified $resource->last_modified->epoch > $metadata->{"If-Modified-Since"}->epoch
Truth table66%2/3
A and B
A= defined $resource->last_modifiedB= $resource->last_modified->epoch > $metadata->{"If-Modified-Since"}->epoch
ABresult
0X0
100
111
538 ? \&m16 : _handle_304( $resource, $response );
539 }
540  
541 19 $STATE_DESC{'m5'} = 'method_is_post';
542 16 ▶sub m5 {
Subroutine m5: called CC=2 SCAR=6.9
Pod undocumented
543 16 my ($resource, $request, $response) = @_;
544 16 ▶ $request->method eq 'POST' ? \&n5 : \410
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'POST' ? : 15 1 16
545 }
546  
547 19 $STATE_DESC{'m7'} = 'allow_post_to_missing_resource';
548 1 ▶sub m7 {
Subroutine m7: called CC=2 SCAR=7.2
Pod undocumented
549 1 my ($resource, $request, $response) = @_;
550 1 ▶ $resource->allow_missing_post ? \&n11 : \404
Branch: 1 branch
BranchTrueFalseTotal
$resource->allow_missing_post ? : 0 1 1
551 }
552  
553 19 $STATE_DESC{'m16'} = 'method_is_delete';
554 55 ▶sub m16 {
Subroutine m16: called CC=2 SCAR=6.9
Pod undocumented
555 55 my ($resource, $request, $response) = @_;
556 55 ▶ $request->method eq 'DELETE' ? \&m20 : \&n16
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'DELETE' ? : 4 51 55
557 }
558  
559 19 $STATE_DESC{'m20'} = 'delete_enacted_immediately';
560 4 ▶sub m20 {
Subroutine m20: called CC=2 SCAR=6.9
Pod undocumented
561 4 my ($resource, $request, $response) = @_;
562 4 ▶ $resource->delete_resource ? \&m20b : \500
Branch: 1 branch
BranchTrueFalseTotal
$resource->delete_resource ? : 3 1 4
563 }
564  
565 19 $STATE_DESC{'m20b'} = 'did_delete_complete';
566 3 ▶sub m20b {
Subroutine m20b: called CC=2 SCAR=6.9
Pod undocumented
567 3 my ($resource, $request, $response) = @_;
568 3 ▶ $resource->delete_completed ? \&o20 : \202
Branch: 1 branch
BranchTrueFalseTotal
$resource->delete_completed ? : 2 1 3
569 }
570  
571 19 $STATE_DESC{'n5'} = 'allow_post_to_missing_resource';
572 15 ▶sub n5 {
Subroutine n5: called CC=2 SCAR=6.9
Pod undocumented
573 15 my ($resource, $request, $response) = @_;
574 15 ▶ $resource->allow_missing_post ? \&n11 : \410
Branch: 1 branch
BranchTrueFalseTotal
$resource->allow_missing_post ? : 14 1 15
575 }
576  
577 6 ▶sub _n11_create_path {
Subroutine _n11_create_path: called CC=6 SCAR=18.1
578 6 my ($resource, $request, $response) = @_;
579  
580 6 my $uri = $resource->create_path;
581 6 ▶ confess "Create Path Nil" unless $uri;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri 1 5 6
582 5 ▶ my $base_uri = $resource->base_uri || $request->base;
Condition66%2/3
$resource->base_uri || $request->base
l!l&&r!l&&!r
230
MC/DC0%0/2
$resource->base_uri || $request->base
$resource->base_uri $request->base
Truth table66%2/3
A || B
A= $resource->base_uriB= $request->base
ABresult
1X1
011
000
583  
584 # do a little cleanup
585 5 ▶ $base_uri =~ s!/$!! if $uri =~ m!^/!;
Branch: 1 branch
BranchTrueFalseTotal
if $uri =~ m[^/] 0 5 5
586 5 ▶ $base_uri .= '/' if $uri !~ m!^/! && $base_uri !~ m!/$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri =~ m[^/] or $base_uri =~ m[/$] 4 1 5
Condition66%2/3
$uri =~ m[^/] or $base_uri =~ m[/$]
l!l&&r!l&&!r
014
MC/DC50%1/2
$uri =~ m[^/] or $base_uri =~ m[/$]
$uri =~ m[^/] $base_uri =~ m[/$]
Truth table66%2/3
A or B
A= $uri =~ m[^/]B= $base_uri =~ m[/$]
ABresult
1X1
011
000
587 5 my $new_uri = URI->new( $base_uri . $uri )->canonical;
588 # NOTE:
589 # the ruby and JS versions will set the path_info
590 # for the request object here, but since our requests
591 # are immutable, we don't allow that. I don't see
592 # where this ends up being useful so I am going to
593 # skip it and not bother.
594 # - SL
595 5 $response->header( 'Location' => $new_uri->path_query );
596 }
597  
598 19 $STATE_DESC{'n11'} = 'redirect';
599 17 ▶sub n11 {
Subroutine n11: called CC=10 SCAR=23.0
Pod undocumented
600 17 my ($resource, $request, $response) = @_;
601 17 ▶ if ( $resource->post_is_create ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resource->post_is_create) { } 6 11 17
602  
603 # the default behavior as specified by
604 # the Erlang/Ruby versions, however this
605 # is a very unpopular "feature" so we are
606 # allowing it to be bypassed here.
607 6 ▶ _n11_create_path( $resource, $request, $response )
Branch: 1 branch
BranchTrueFalseTotal
unless $resource->create_path_after_handler 6 0 6
608 if not $resource->create_path_after_handler;
609  
610 5 my $handler = _get_acceptable_content_type_handler( $resource, $request );
611 5 ▶ return $handler if is_status_code( $handler );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($handler) 1 4 5
612  
613 4 my $result = $resource->$handler();
614 4 ▶ return $result if is_status_code( $result );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($result) 1 3 4
615  
616 3 ▶ _n11_create_path( $resource, $request, $response )
Branch: 1 branch
BranchTrueFalseTotal
if $resource->create_path_after_handler 0 3 3
617 if $resource->create_path_after_handler;
618 }
619 else {
620 11 my $result = $resource->process_post;
621 11 ▶ if ( $result ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) { } 10 1 11
622 10 ▶ return $result if is_status_code( $result );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($result) 3 7 10
623 7 encode_body_if_set( $resource, $response );
624 }
625 else {
626 1 confess "Process Post Invalid";
627 }
628 }
629  
630 10 ▶ if ( _is_redirect( $response ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_redirect($response)) 3 7 10
631 3 ▶ if ( $response->location ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->location) { } 2 1 3
632 2 return \303;
633 }
634 else {
635 1 confess "Bad Redirect"
636 }
637 }
638  
639 7 return \&p11;
640 }
641  
642 19 $STATE_DESC{'n16'} = 'method_is_post';
643 51 ▶sub n16 {
Subroutine n16: called CC=2 SCAR=6.9
Pod undocumented
644 51 my ($resource, $request, $response) = @_;
645 51 ▶ $request->method eq 'POST' ? \&n11 : \&o16
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'POST' ? : 3 48 51
646 }
647  
648 19 $STATE_DESC{'o14'} = 'in_conflict';
649 3 ▶sub o14 {
Subroutine o14: called CC=4 SCAR=13.9
Pod undocumented
650 3 my ($resource, $request, $response) = @_;
651 3 ▶ return \409 if $resource->is_conflict;
Branch: 1 branch
BranchTrueFalseTotal
if $resource->is_conflict 1 2 3
652  
653 2 my $handler = _get_acceptable_content_type_handler( $resource, $request );
654 2 ▶ return $handler if is_status_code( $handler );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($handler) 0 2 2
655  
656 2 my $result = $resource->$handler();
657  
658 2 ▶ return $result if is_status_code( $result );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($result) 1 1 2
659 1 return \&p11;
660 }
661  
662 19 $STATE_DESC{'o16'} = 'method_is_put';
663 48 ▶sub o16 {
Subroutine o16: called CC=2 SCAR=6.9
Pod undocumented
664 48 my ($resource, $request, $response) = @_;
665 48 ▶ $request->method eq 'PUT' ? \&o14 : \&o18;
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'PUT' ? : 3 45 48
666 }
667  
668 19 $STATE_DESC{'o18'} = 'multiple_representations';
669 49 ▶sub o18 {
Subroutine o18: called CC=6 SCAR=17.9
Pod undocumented
670 49 my ($resource, $request, $response) = @_;
671 49 my $metadata = _metadata($request);
672 49 ▶ if ( $request->method eq 'GET' || $request->method eq 'HEAD' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($request->method eq 'GET' or $request->method eq 'HEAD') { } 45 4 49
Condition100%3/3
$request->method eq "GET" or $request->method eq "HEAD"
l!l&&r!l&&!r
4414
MC/DC100%2/2
$request->method eq "GET" or $request->method eq "HEAD"
$request->method eq "GET" $request->method eq "HEAD"
Truth table100%3/3
A or B
A= $request->method eq "GET"B= $request->method eq "HEAD"
ABresult
1X1
011
000
673 45 _add_caching_headers( $resource, $response );
674  
675 45 my $content_type = $metadata->{'Content-Type'};
676 45 ▶ my $match = first {
Subroutine __ANON__: called CC=1 SCAR=0.0
677 45 my $ct = create_header( MediaType => pair_key( $_ ) );
678 45 $content_type->match( $ct )
679 45 } @{ $resource->content_types_provided };
680  
681 45 my $handler = pair_value( $match );
682 45 my $result = $resource->$handler();
683  
684 45 ▶ return $result if is_status_code( $result );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($result) 2 43 45
685  
686 43 ▶ unless($request->method eq 'HEAD') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($request->method eq "HEAD") 42 1 43
687 42 ▶ if (ref($result) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq 'CODE') { } 5 37 42
688 5 $request->env->{'web.machine.streaming_push'} = $result;
689 }
690 else {
691 37 $response->body( $result );
692 }
693 42 encode_body( $resource, $response );
694 }
695 43 return \&o18b;
696 }
697 else {
698 4 return \&o18b;
699 }
700  
701 }
702  
703 19 $STATE_DESC{'o18b'} = 'multiple_choices';
704 47 ▶sub o18b {
Subroutine o18b: called CC=2 SCAR=6.9
Pod undocumented
705 47 my ($resource, $request, $response) = @_;
706 47 ▶ $resource->multiple_choices ? \300 : \200;
Branch: 1 branch
BranchTrueFalseTotal
$resource->multiple_choices ? : 1 46 47
707 }
708  
709 19 $STATE_DESC{'o20'} = 'response_body_includes_entity';
710 7 ▶sub o20 {
Subroutine o20: called CC=2 SCAR=6.9
Pod undocumented
711 7 my ($resource, $request, $response) = @_;
712 7 ▶ $response->body ? \&o18 : \204;
Branch: 1 branch
BranchTrueFalseTotal
$response->body ? : 4 3 7
713 }
714  
715 19 $STATE_DESC{'p3'} = 'in_conflict';
716 6 ▶sub p3 {
Subroutine p3: called CC=4 SCAR=13.9
Pod undocumented
717 6 my ($resource, $request, $response) = @_;
718 6 ▶ return \409 if $resource->is_conflict;
Branch: 1 branch
BranchTrueFalseTotal
if $resource->is_conflict 1 5 6
719  
720 5 my $handler = _get_acceptable_content_type_handler( $resource, $request );
721 5 ▶ return $handler if is_status_code( $handler );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($handler) 1 4 5
722  
723 4 my $result = $resource->$handler();
724  
725 4 ▶ return $result if is_status_code( $result );
Branch: 1 branch
BranchTrueFalseTotal
if is_status_code($result) 1 3 4
726 3 return \&p11;
727 }
728  
729 19 $STATE_DESC{'p11'} = 'new_resource';
730 11 ▶sub p11 {
Subroutine p11: called CC=2 SCAR=6.9
Pod undocumented
731 11 my ($resource, $request, $response) = @_;
732 11 ▶ (not $response->header('Location')) ? \&o20 : \201
Branch: 1 branch
BranchTrueFalseTotal
!$response->header('Location') ? : 5 6 11
733 }
734  
735 19 1;
736  
737 __END__
« blib/lib/Web/Machine/Util.pm ↑ Summary blib/lib/Web/Machine/Util/BodyEncoding.pm »