« blib/lib/Plack/Middleware/SimpleLogger.pm
↑ Summary
blib/lib/Plack/Middleware/SimpleContentFilter.pm »
| 1 | package Plack::LWPish; | ||||||||||||||||||||||||||||
| 2 | 52 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 52 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 52 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 52 | ▶ | use HTTP::Response; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 52 | ▶ | use Hash::MultiValue; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 17 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 17 | my $class = shift; | |||||||||||||||||||||||||||
| 10 | 17 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 11 | 17 | ▶ | $self->{http} = @_ == 1 ? $_[0] : HTTP::Tiny->new(verify_SSL => 1, @_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 12 | 17 | $self; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 89 | ▶ | sub request { | ||||||||||||||||||||||||||
|
Subroutine
request: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 89 | my($self, $req) = @_; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 89 | my @headers; | |||||||||||||||||||||||||||
| 19 | 89 | ▶ | $req->headers->scan(sub { push @headers, @_ }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 89 | my $options = { | |||||||||||||||||||||||||||
| 22 | headers => Hash::MultiValue->new(@headers)->mixed, | ||||||||||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||||||||||
| 24 | 89 | ▶ | $options->{content} = $req->content if defined $req->content && length($req->content); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $req->content and length $req->content
MC/DC50%1/2
defined $req->content and length $req->content
defined $req->content
length $req->content
Truth table66%2/3
A and B
A= defined $req->contentB= length $req->content
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 89 | my $response = $self->{http}->request($req->method, $req->url, $options); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | my $res = HTTP::Response->new( | ||||||||||||||||||||||||||||
| 29 | $response->{status}, | ||||||||||||||||||||||||||||
| 30 | $response->{reason}, | ||||||||||||||||||||||||||||
| 31 | [ Hash::MultiValue->from_mixed($response->{headers})->flatten ], | ||||||||||||||||||||||||||||
| 32 | $response->{content}, | ||||||||||||||||||||||||||||
| 33 | 89 | ); | |||||||||||||||||||||||||||
| 34 | 89 | $res->request($req); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 89 | return $res; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 52 | 1; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | __END__ | ||||||||||||||||||||||||||||