| 1 | package Plack::Middleware::Reproxy::Furl; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use parent qw(Plack::Middleware::Reproxy); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Plack::Util::Accessor qw(furl); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Furl::HTTP; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | sub prepare_app { | ||||||||
|
Subroutine
prepare_app: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 8 | 1 | my $self = shift; | |||||||||
| 9 | 1 | ▶ | if (! $self->furl) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 10 | 1 | my $furl = Furl::HTTP->new; | |||||||||
| 11 | 1 | $self->furl($furl); | |||||||||
| 12 | } | ||||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 2 | ▶ | sub reproxy_to { | ||||||||
|
Subroutine
reproxy_to: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 2 | my ($self, $res, $env, $url) = @_; | |||||||||
| 17 | |||||||||||
| 18 | # Now recreate headers | ||||||||||
| 19 | 2 | my @hdrs = $self->extract_headers($env); | |||||||||
| 20 | |||||||||||
| 21 | 2 | my $input = $env->{'psgi.input'}; | |||||||||
| 22 | 2 | $input->seek(0, 0); | |||||||||
| 23 | my @args = ( | ||||||||||
| 24 | method => $env->{HTTP_METHOD}, | ||||||||||
| 25 | 2 | url => $url, | |||||||||
| 26 | headers => \@hdrs, | ||||||||||
| 27 | content => $input, | ||||||||||
| 28 | ); | ||||||||||
| 29 | 2 | my (undef, $code, undef, $hdrs, $body) = $self->furl->request(@args); | |||||||||
| 30 | |||||||||||
| 31 | 2 | @$res = ( $code, $hdrs, [ $body ] ); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 1 | 1; | |||||||||
| 35 | |||||||||||
| 36 | __END__ | ||||||||||