| 1 | package Furl; | ||||||||||
| 2 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 11 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 11 | ▶ | use Furl::HTTP; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 11 | ▶ | use Furl::Request; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 11 | ▶ | use Furl::Response; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 11 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 11 | our $VERSION = '3.16'; | |||||||||
| 10 | |||||||||||
| 11 | 11 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 11 | $Carp::Internal{+__PACKAGE__} = 1; | |||||||||
| 14 | |||||||||||
| 15 | 5 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 16 | 5 | my $class = shift; | |||||||||
| 17 | 5 | bless \(Furl::HTTP->new(header_format => Furl::HTTP::HEADERS_AS_HASHREF(), @_)), $class; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 2 | ▶ | sub get { | ||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 2 | my ( $self, $url, $headers ) = @_; | |||||||||
| 22 | 2 | $self->request( | |||||||||
| 23 | method => 'GET', | ||||||||||
| 24 | url => $url, | ||||||||||
| 25 | headers => $headers | ||||||||||
| 26 | ); | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 1 | ▶ | sub head { | ||||||||
|
Subroutine
head: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 30 | 1 | my ( $self, $url, $headers ) = @_; | |||||||||
| 31 | 1 | $self->request( | |||||||||
| 32 | method => 'HEAD', | ||||||||||
| 33 | url => $url, | ||||||||||
| 34 | headers => $headers | ||||||||||
| 35 | ); | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 2 | ▶ | sub post { | ||||||||
|
Subroutine
post: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 2 | my ( $self, $url, $headers, $content ) = @_; | |||||||||
| 40 | 2 | $self->request( | |||||||||
| 41 | method => 'POST', | ||||||||||
| 42 | url => $url, | ||||||||||
| 43 | headers => $headers, | ||||||||||
| 44 | content => $content | ||||||||||
| 45 | ); | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | sub put { | ||||||||
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 49 | 1 | my ( $self, $url, $headers, $content ) = @_; | |||||||||
| 50 | 1 | $self->request( | |||||||||
| 51 | method => 'PUT', | ||||||||||
| 52 | url => $url, | ||||||||||
| 53 | headers => $headers, | ||||||||||
| 54 | content => $content | ||||||||||
| 55 | ); | ||||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 1 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 59 | 1 | my ( $self, $url, $headers, $content ) = @_; | |||||||||
| 60 | 1 | $self->request( | |||||||||
| 61 | method => 'DELETE', | ||||||||||
| 62 | url => $url, | ||||||||||
| 63 | headers => $headers, | ||||||||||
| 64 | content => $content | ||||||||||
| 65 | ); | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | 3 | ▶ | sub agent { | ||||||||
|
Subroutine
agent: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 70 | 3 | ▶ | @_ == 2 ? ${$_[0]}->agent($_[1]) : ${$_[0]}->agent; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub env_proxy { | ||||||||
|
Subroutine
env_proxy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | 0 | my $self = shift; | |||||||||
| 75 | 0 | $$self->env_proxy; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 9 | ▶ | sub request { | ||||||||
|
Subroutine
request: called CC=2 SCAR=10.0
Pod
documented
| |||||||||||
| 79 | 9 | my $self = shift; | |||||||||
| 80 | |||||||||||
| 81 | 9 | my %args; | |||||||||
| 82 | 9 | ▶ | if (@_ % 2 == 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 83 | 9 | %args = @_; | |||||||||
| 84 | } else { | ||||||||||
| 85 | # convert HTTP::Request to hash for Furl::HTTP. | ||||||||||
| 86 | |||||||||||
| 87 | 0 | my $req = shift; | |||||||||
| 88 | 0 | %args = @_; | |||||||||
| 89 | 0 | my $req_headers= $req->headers; | |||||||||
| 90 | 0 | $req_headers->remove_header('Host'); # suppress duplicate Host header | |||||||||
| 91 | my $headers = +[ | ||||||||||
| 92 | map { | ||||||||||
| 93 | 0 | my $k = $_; | |||||||||
| 94 | 0 | map { ( $k => $_ ) } $req_headers->header($_); | |||||||||
| 95 | } $req_headers->header_field_names | ||||||||||
| 96 | ]; | ||||||||||
| 97 | |||||||||||
| 98 | 0 | $args{url} = $req->uri; | |||||||||
| 99 | 0 | $args{method} = $req->method; | |||||||||
| 100 | 0 | $args{content} = $req->content; | |||||||||
| 101 | 0 | $args{headers} = $headers; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | my ( | ||||||||||
| 105 | $res_minor_version, | ||||||||||
| 106 | $res_status, | ||||||||||
| 107 | $res_msg, | ||||||||||
| 108 | $res_headers, | ||||||||||
| 109 | $res_content, | ||||||||||
| 110 | $captured_req_headers, | ||||||||||
| 111 | $captured_req_content, | ||||||||||
| 112 | $captured_res_headers, | ||||||||||
| 113 | $captured_res_content, | ||||||||||
| 114 | $request_info, | ||||||||||
| 115 | 9 | ) = ${$self}->request(%args); | |||||||||
| 116 | |||||||||||
| 117 | 3 | my $res = Furl::Response->new($res_minor_version, $res_status, $res_msg, $res_headers, $res_content); | |||||||||
| 118 | 3 | $res->set_request_info(\%args, $captured_req_headers, $captured_req_content); | |||||||||
| 119 | |||||||||||
| 120 | 3 | return $res; | |||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | 11 | 1; | |||||||||
| 124 | __END__ | ||||||||||