File Coverage

blib/lib/Plack/Middleware/Proxy/Requests.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package Plack::Middleware::Proxy::Requests;
2              
3             =head1 NAME
4              
5             Plack::Middleware::Proxy::Requests - Forward proxy server
6              
7             =head1 SYNOPSIS
8              
9             # In app.psgi
10             use Plack::Builder;
11             use Plack::App::Proxy;
12              
13             builder {
14             enable "Proxy::Connect";
15             enable "Proxy::AddVia";
16             enable "Proxy::Requests";
17             Plack::App::Proxy->new->to_app;
18             };
19              
20             # From shell
21             plackup -s Twiggy -E Proxy -e 'enable q{AccessLog}' app.psgi
22              
23             # or
24             twiggy -MPlack::App::Proxy \
25             -e 'enable q{AccessLog}; enable q{Proxy::Connect}; \
26             enable q{Proxy::AddVia}; enable q{Proxy::Requests}; \
27             Plack::App::Proxy->new->to_app'
28              
29             =head1 DESCRIPTION
30              
31             This module handles HTTP requests as a forward proxy server.
32              
33             Its job is to set a C environment variable based on
34             C variable.
35              
36             The HTTP responses from the Internet might be invalid. In that case it
37             is required to run the server without L module.
38             This module is started by default and disabled if C<-E> or
39             C<--no-default-middleware> option is used when starting L
40             script. Note that this disable also L so
41             it have to be enabled explicitly if needed.
42              
43             The default server L alias C can hang
44             up on stalled connection. It is better to run proxy server with
45             L, L or L.
46              
47             =for readme stop
48              
49             =cut
50              
51              
52 2     2   25359 use 5.006;
  2         8  
  2         160  
53              
54 2     2   15 use strict;
  2         6  
  2         82  
55 2     2   12 use warnings;
  2         8  
  2         118  
56              
57             our $VERSION = '0.0102';
58              
59              
60 2     2   8804 use parent qw(Plack::Middleware);
  2         425  
  2         16  
61              
62              
63             sub call {
64 1     1 1 144 my ($self, $env) = @_;
65              
66 1         4 $env->{'plack.proxy.url'} = $env->{REQUEST_URI};
67              
68 1         8 return $self->app->($env);
69             };
70              
71              
72             1;
73              
74              
75             =for readme continue
76              
77             =head1 SEE ALSO
78              
79             L, L, L,
80             L, L, L, L.
81              
82             =head1 BUGS
83              
84             If you find the bug or want to implement new features, please report it at
85             L
86              
87             The code repository is available at
88             L
89              
90             =head1 AUTHOR
91              
92             Piotr Roszatycki
93              
94             =head1 LICENSE
95              
96             Copyright (c) 2012-2013 Piotr Roszatycki .
97              
98             This is free software; you can redistribute it and/or modify it under
99             the same terms as perl itself.
100              
101             See L