| 1 | package Net::ACME::X::HTTP::Protocol; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Net::ACME::X::HTTP::Protocol | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | This exception class means that an error occurred with an HTTP | ||||||||||||||||||||||||||||
| 12 | request, and the problem had specifically to do with something | ||||||||||||||||||||||||||||
| 13 | that happened on the remote server, not just a general connection | ||||||||||||||||||||||||||||
| 14 | problem. For example, this class would be suitable for use when | ||||||||||||||||||||||||||||
| 15 | you get a 500 Internal Server Error or a 404 Not Found, but it | ||||||||||||||||||||||||||||
| 16 | would not be suitable for use if you get a Connection Refused | ||||||||||||||||||||||||||||
| 17 | error when trying to connect. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use parent qw( Net::ACME::X::HashBase ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # In a normal HTTP response, we don't necessarily know if the body is going | ||||||||||||||||||||||||||||
| 27 | # to be meaningful for display, so only include the first chunk. | ||||||||||||||||||||||||||||
| 28 | # | ||||||||||||||||||||||||||||
| 29 | #(accessed from tests) | ||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use constant BODY_DISPLAY_SIZE => 1_024; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | #named args required: | ||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||
| 34 | # method | ||||||||||||||||||||||||||||
| 35 | # reason | ||||||||||||||||||||||||||||
| 36 | # url | ||||||||||||||||||||||||||||
| 37 | # status | ||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||
| 39 | sub new { | ||||||||||||||||||||||||||||
| 40 | 4 | ▶ | my ( $self, $args_hr ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 4 | my $content = $args_hr->{'content'}; | |||||||||||||||||||||||||||
| 43 | 4 | ▶ | if ( defined($content) && length($content) > BODY_DISPLAY_SIZE() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $content and length $content > 1024
MC/DC100%2/2
defined $content and length $content > 1024
defined $content
length $content > 1024
Truth table100%3/3
A and B
A= defined $contentB= length $content > 1024
| |||||||||||||||||||||||||||||
| 44 | 1 | substr( $content, BODY_DISPLAY_SIZE() ) = '…'; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 4 | ▶ | $content ||= q<>; | ||||||||||||||||||||||||||
|
Condition100%2/2
$content ||= ""
MC/DC100%1/1
$content ||= ""
$content
Truth table100%2/2
A
A= $content
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | return $self->SUPER::new( | |||||||||||||||||||||||||||
| 50 | "The response to the HTTP “$args_hr->{'method'}” request from “$args_hr->{'url'}” indicated an error ($args_hr->{'status'}, $args_hr->{'reason'}): “$content”", | ||||||||||||||||||||||||||||
| 51 | $args_hr, | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | 1; | |||||||||||||||||||||||||||