File Coverage

blib/lib/Plack/Client/Backend/http.pm
Criterion Covered Total %
statement 27 27 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 8 8 100.0
pod 2 2 100.0
total 39 42 92.8


line stmt bran cond sub pod time code
1             package Plack::Client::Backend::http;
2             BEGIN {
3 4     4   9841 $Plack::Client::Backend::http::VERSION = '0.06';
4             }
5 4     4   524 use strict;
  4         19  
  4         468  
6 4     4   40 use warnings;
  4         14  
  4         332  
7             # ABSTRACT: backend for handling HTTP requests
8              
9 4     4   5300 use Plack::App::Proxy;
  4         17828  
  4         243  
10              
11 4     4   53 use base 'Plack::Client::Backend';
  4         10  
  4         4105  
12              
13              
14              
15             sub new {
16 4     4 1 9 my $class = shift;
17 4         10 my %args = @_;
18              
19 4 50 33     116 $args{proxy} ||= Plack::App::Proxy->new(
20             exists $args{proxy_args} ? $args{proxy_args} : ()
21             );
22              
23 4         562 my $self = $class->SUPER::new(@_);
24              
25 4         35 $self->{proxy} = $args{proxy}->to_app;
26              
27 4         649 return $self;
28             }
29              
30 38     38   213 sub _proxy { shift->{proxy} }
31              
32              
33             sub app_from_request {
34 38     38 1 67 my $self = shift;
35 38         208 my ($req) = @_;
36              
37 38         246 my $uri = $req->uri->clone;
38 38         15512 $uri->path('/');
39 38         1271 $uri->query(undef);
40 38         812 $req->env->{'plack.proxy.remote'} = $uri->as_string;
41 38         398 return $self->_proxy;
42             }
43              
44             1;
45              
46             __END__