line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ACME2::HTTP_Tiny; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Net::ACME2::HTTP_Tiny - Synchronous HTTP client for Net::ACME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Net::ACME2::HTTP_Tiny; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $http = Net::ACME2::HTTP_Tiny->new(); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#NOTE: Unlike HTTP::Tiny’s method, this will die() if the HTTP |
16
|
|
|
|
|
|
|
#session itself fails--for example, if the network connection was |
17
|
|
|
|
|
|
|
#interrupted. These will be Net::ACME2::X::HTTP::Network instances. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
#This also fails on HTTP errors (4xx and 5xx). The errors are |
20
|
|
|
|
|
|
|
#instances of Net::ACME2::X::HTTP::Protocol. |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
my $resp_obj = $http->post_form( $the_url, \%the_form_post ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module wraps L, thus: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item * Duplicate the work of C without the |
31
|
|
|
|
|
|
|
dependency on L (which brings in a mess of other undesirables). |
32
|
|
|
|
|
|
|
Thus, the returns from C and related methods |
33
|
|
|
|
|
|
|
are instances of C rather than simple hashes. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * Verify remote SSL connections, and always C if |
36
|
|
|
|
|
|
|
either the network connection fails or the protocol indicates an error |
37
|
|
|
|
|
|
|
(4xx or 5xx). |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=back |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
3
|
|
333889
|
use strict; |
|
3
|
|
|
|
|
25
|
|
|
3
|
|
|
|
|
89
|
|
44
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
83
|
|
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
3
|
|
28
|
use parent qw( HTTP::Tiny ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
20
|
|
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
3
|
|
135706
|
use HTTP::Tiny::UA::Response (); |
|
3
|
|
|
|
|
8532
|
|
|
3
|
|
|
|
|
63
|
|
49
|
|
|
|
|
|
|
|
50
|
3
|
|
|
3
|
|
960
|
use Net::ACME2::X (); |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
60
|
|
51
|
3
|
|
|
3
|
|
1383
|
use Net::ACME2::HTTP::Convert (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
79
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# This circular dependency is unfortunate, but PAUSE needs to see a static |
54
|
|
|
|
|
|
|
# $Net::ACME2::VERSION. (Thanks to Dan Book for pointing it out.) |
55
|
3
|
|
|
3
|
|
1329
|
use Net::ACME2 (); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
222
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
our $VERSION; |
58
|
|
|
|
|
|
|
BEGIN { |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# HTTP::Tiny gets upset if there’s anything non-numeric |
61
|
|
|
|
|
|
|
# (e.g., “-TRIAL1”) in VERSION(). So weed it out here. |
62
|
3
|
|
|
3
|
|
15
|
$VERSION = $Net::ACME2::VERSION; |
63
|
3
|
|
|
|
|
533
|
$VERSION =~ s<[^0-9.].*><>; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#Use this to tweak SSL config, e.g., if you want to cache PublicSuffix. |
67
|
|
|
|
|
|
|
our @SSL_OPTIONS; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new { |
70
|
19
|
|
|
19
|
1
|
81
|
my ( $class, %args ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$args{'SSL_options'} = { |
73
|
19
|
50
|
|
|
|
89
|
( $args{'SSL_options'} ? (%{ $args{'SSL_options'} }) : () ), |
|
0
|
|
|
|
|
0
|
|
74
|
|
|
|
|
|
|
@SSL_OPTIONS, |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
19
|
|
|
|
|
144
|
my $self = $class->SUPER::new( |
78
|
|
|
|
|
|
|
verify_SSL => 1, |
79
|
|
|
|
|
|
|
%args, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
19
|
|
|
|
|
2347
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#mocked in tests |
86
|
|
|
|
|
|
|
*_base_request = HTTP::Tiny->can('request'); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub request { |
89
|
54
|
|
|
54
|
1
|
154
|
my ( $self, $method, $url, $args_hr ) = @_; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# NB: HTTP::Tiny clobbers $@. The clobbering is useless since the |
92
|
|
|
|
|
|
|
# error is in the $resp variable already. Clobbering also risks |
93
|
|
|
|
|
|
|
# action-at-a-distance problems. |
94
|
|
|
|
|
|
|
|
95
|
54
|
|
66
|
|
|
391
|
my $resp = _base_request( $self, $method, $url, $args_hr || () ); |
96
|
|
|
|
|
|
|
|
97
|
54
|
|
|
|
|
387253428
|
return Net::ACME2::HTTP::Convert::http_tiny_to_net_acme2($method, $resp); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|