| 1 | package Net::ACME2::HTTP::Response; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use parent qw( HTTP::Tiny::UA::Response ); | ||
| 7 | |||
| 8 | use JSON (); | ||
| 9 | |||
| 10 | use Net::ACME2::X (); | ||
| 11 | |||
| 12 | sub die_because_unexpected { | ||
| 13 | my ($self) = @_; | ||
| 14 | |||
| 15 | die Net::ACME2::X->create( | ||
| 16 | 'UnexpectedResponse', | ||
| 17 | { | ||
| 18 | uri => $self->url(), | ||
| 19 | status => $self->status(), | ||
| 20 | reason => $self->reason(), | ||
| 21 | headers => $self->headers(), | ||
| 22 | }, | ||
| 23 | ); | ||
| 24 | } | ||
| 25 | |||
| 26 | #Useful for everything but certificate issuance, apparently? | ||
| 27 | sub content_struct { | ||
| 28 | my ($self) = @_; | ||
| 29 | |||
| 30 | my $json = ($self->{'_json'} ||= JSON->new()->allow_nonref()); | ||
| 31 | |||
| 32 | return $json->decode( $self->content() ); | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; |