| 1 | package RPC::Any::Interface::PSGI; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | our $VERSION = '0.03'; | |||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use HTTP::Request; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Plack::Request; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 3 | has _plack_req => (is => 'rw', isa => 'Plack::Request'); | |||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | around 'get_input' => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | my $orig = shift; | |||||||||
| 16 | 2 | my $self = shift; | |||||||||
| 17 | 2 | my $env = shift; | |||||||||
| 18 | |||||||||||
| 19 | 2 | $self->_plack_req(Plack::Request->new($env)); | |||||||||
| 20 | 2 | return $self->_plack_req->content; | |||||||||
| 21 | 3 | }; | |||||||||
| 22 | |||||||||||
| 23 | 2 | ▶ | around 'input_to_request' => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||
| 24 | 2 | my $orig = shift; | |||||||||
| 25 | 2 | my $self = shift; | |||||||||
| 26 | 2 | my $input = shift; | |||||||||
| 27 | |||||||||||
| 28 | 2 | my $request = HTTP::Request->new($self->_plack_req->method, $self->_plack_req->request_uri, $self->_plack_req->headers); | |||||||||
| 29 | 2 | $request->protocol($self->_plack_req->protocol); | |||||||||
| 30 | 2 | $request->content_type($self->_plack_req->content_type); | |||||||||
| 31 | 2 | $request->content_length($self->_plack_req->content_length); | |||||||||
| 32 | |||||||||||
| 33 | 2 | ▶ | if (utf8::is_utf8($input)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | utf8::encode($input); | |||||||||
| 35 | 0 | $self->_set_request_utf8($request); | |||||||||
| 36 | } | ||||||||||
| 37 | 2 | $request->content($input); | |||||||||
| 38 | |||||||||||
| 39 | 2 | return $request; | |||||||||
| 40 | 3 | }; | |||||||||
| 41 | |||||||||||
| 42 | # HTTP role doesn't allow me to get headers and content seperately | ||||||||||
| 43 | # so I copied the header processing | ||||||||||
| 44 | 1 | ▶ | around 'produce_output' => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 45 | 1 | my $orig = shift; | |||||||||
| 46 | 1 | my $self = shift; | |||||||||
| 47 | 1 | my $response = shift; | |||||||||
| 48 | |||||||||||
| 49 | 1 | my %headers = %{ $self->_output_headers }; | |||||||||
| 50 | 1 | ▶ | $response->header(%headers) if %headers; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 1 | my @headers; | |||||||||
| 53 | 1 | ▶ | $response->headers->scan(sub { push @headers, @_ }); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 54 | |||||||||||
| 55 | 1 | return [ $response->code, [ @headers ], [ $response->content ] ]; | |||||||||
| 56 | 3 | }; | |||||||||
| 57 | |||||||||||
| 58 | 3 | 1; | |||||||||
| 59 | |||||||||||
| 60 | __END__ | ||||||||||