| 1 | package Net::ACME::HTTP::Response; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 8 | ▶ | use parent qw( HTTP::Tiny::UA::Response ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 8 | ▶ | use Call::Context (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 8 | ▶ | use JSON (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 8 | ▶ | use Net::ACME::X (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | sub die_because_unexpected { | ||||||||||||||||||||
| 14 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
die_because_unexpected: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 4 | die Net::ACME::X::create( | |||||||||||||||||||
| 17 | 'UnexpectedResponse', | ||||||||||||||||||||
| 18 | { | ||||||||||||||||||||
| 19 | uri => $self->url(), | ||||||||||||||||||||
| 20 | status => $self->status(), | ||||||||||||||||||||
| 21 | reason => $self->reason(), | ||||||||||||||||||||
| 22 | headers => $self->headers(), | ||||||||||||||||||||
| 23 | }, | ||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | #Useful for everything but certificate issuance, apparently? | ||||||||||||||||||||
| 28 | sub content_struct { | ||||||||||||||||||||
| 29 | 10 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
content_struct: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 10 | return JSON::decode_json( $self->content() ); | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | #A “poor man’s Link header parser” that only knows how to handle | ||||||||||||||||||||
| 35 | #these values as described in the ACME protocol spec: | ||||||||||||||||||||
| 36 | #a single “rel” parameter, and no extra whitespace. | ||||||||||||||||||||
| 37 | # | ||||||||||||||||||||
| 38 | #This returns key/value pairs. They should probably go into a hash, | ||||||||||||||||||||
| 39 | #but I don’t see anything in the spec that says the same “rel” | ||||||||||||||||||||
| 40 | #parameter can’t occur twice. | ||||||||||||||||||||
| 41 | # | ||||||||||||||||||||
| 42 | #If we need something more robust down the line, | ||||||||||||||||||||
| 43 | #HTTP::Link::Parser::parse_single_link() may do the trick. | ||||||||||||||||||||
| 44 | sub links { | ||||||||||||||||||||
| 45 | 8 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
links: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 8 | Call::Context::must_be_list(); | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 8 | my $links_ar = $self->header('link'); | |||||||||||||||||||
| 50 | 8 | ▶ | if ( !ref $links_ar ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 5 | ▶ | $links_ar = [ $links_ar || () ]; | ||||||||||||||||||
|
Condition66%2/3
$links_ar || ()
MC/DC50%1/2
$links_ar || ()
$links_ar
()
Truth table66%2/3
A || B
A= $links_arB= ()
| |||||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 8 | my @resp; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 8 | for my $l (@$links_ar) { | |||||||||||||||||||
| 57 | 8 | ▶ | $l =~ m/\A<([^>]+)>;rel="([^"]+)"\z/ or do { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | 1 | warn "Unrecognized link: “$l”"; | |||||||||||||||||||
| 59 | 1 | next; | |||||||||||||||||||
| 60 | }; | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 7 | push @resp, $2, $1; | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 8 | return @resp; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 8 | 1; | |||||||||||||||||||