| 1 | package UserAgent::Any::Fake::Request; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.036; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use UserAgent::Any::Impl::Helper 'params_to_hash'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | our $VERSION = 0.01; | |||||||||
| 11 | |||||||||||
| 12 | 1 | has [qw(url method _headers content)] => (is => 'ro',); | |||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||
| 15 | 2 | my ($orig, $class, $method, $url, @args) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 2 | my $content; | |||||||||
| 18 | 2 | ▶ | $content = pop @args if @args % 2; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | |||||||||||
| 20 | return { | ||||||||||
| 21 | 2 | url => $url, | |||||||||
| 22 | method => $method, | ||||||||||
| 23 | _headers => params_to_hash(@args), | ||||||||||
| 24 | content => $content | ||||||||||
| 25 | }; | ||||||||||
| 26 | 1 | }; | |||||||||
| 27 | |||||||||||
| 28 | 2 | ▶ | sub header ($self, $k) { | ||||||||
|
Subroutine
header: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||
| 29 | 2 | my $v = $self->_headers->{$k}; | |||||||||
| 30 | 2 | ▶ | return unless defined $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 2 | ▶ | return $v unless ref($v); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 1 | ▶ | return @{$v} if wantarray; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | return join(',', @{$v}); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 1 | ▶ | sub headers ($self) { | ||||||||
|
Subroutine
headers: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 37 | 1 | my @all_headers; | |||||||||
| 38 | 1 | for my $k (sort keys %{$self->_headers}) { | |||||||||
| 39 | 2 | push @all_headers, map { ($k, $_) } $self->header($k); | |||||||||
| 40 | } | ||||||||||
| 41 | 1 | return @all_headers; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||