| 1 | package HTTP::Engine::Interface::Test; | ||||||||||||||
| 2 | use HTTP::Engine::Interface | ||||||||||||||
| 3 | 13 | ▶ | builder => 'NoEnv', | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | writer => { | ||||||||||||||
| 5 | attributes => { | ||||||||||||||
| 6 | output_body_buffer => { | ||||||||||||||
| 7 | is => 'rw', | ||||||||||||||
| 8 | }, | ||||||||||||||
| 9 | }, | ||||||||||||||
| 10 | around => { | ||||||||||||||
| 11 | 34 | ▶ | finalize => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 34 | my $next = shift; | |||||||||||||
| 13 | 34 | my ( $self, $req, $res ) = @_; | |||||||||||||
| 14 | 34 | $self->output_body_buffer(''); | |||||||||||||
| 15 | 34 | $next->(@_); | |||||||||||||
| 16 | 34 | $res->body( $self->output_body_buffer ); | |||||||||||||
| 17 | 34 | $res->as_http_response; | |||||||||||||
| 18 | }, | ||||||||||||||
| 19 | }, | ||||||||||||||
| 20 | 13 | ▶ | output_header => sub {}, | ||||||||||||
|
Subroutine
output_header: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 21 | 21 | ▶ | write => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Subroutine
write: called CC=2 SCAR=7.0
| |||||||||||||||
| 22 | 21 | my($self, $buffer) = @_; | |||||||||||||
| 23 | 21 | ▶ | Carp::carp("do not pass the utf8-string as HTTP-Response: '$buffer'") if Encode::is_utf8($buffer); | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 24 | 21 | $self->output_body_buffer( $self->output_body_buffer . $buffer ); | |||||||||||||
| 25 | }, | ||||||||||||||
| 26 | } | ||||||||||||||
| 27 | 13 | ; | |||||||||||||
| 28 | |||||||||||||||
| 29 | 13 | ▶ | use HTTP::Engine::Test::Request; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 30 | 13 | ▶ | use Carp (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 31 | 13 | ▶ | use Encode (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 32 | |||||||||||||||
| 33 | 36 | ▶ | sub run { | ||||||||||||
|
Subroutine
run: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||
| 34 | 36 | my ( $self, $request, %args ) = @_; | |||||||||||||
| 35 | 36 | ▶ | Carp::croak('missing request object') unless $request; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | 36 | ▶ | Carp::croak('incorrect request object($request->uri() returns undef)') unless $request->uri; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 37 | 36 | ▶ | if ($request->method eq 'POST') { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | 9 | ▶ | Carp::carp('missing content-length header') unless defined $request->content_length; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | 9 | ▶ | Carp::carp('missing content-type header') unless $request->content_type; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | } | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 36 | return $self->handle_request( | |||||||||||||
| 43 | HTTP::Engine::Test::Request->build_request_args( | ||||||||||||||
| 44 | $request->uri, | ||||||||||||||
| 45 | $request->content, | ||||||||||||||
| 46 | { | ||||||||||||||
| 47 | headers => $request->headers, | ||||||||||||||
| 48 | method => $request->method, | ||||||||||||||
| 49 | protocol => $request->protocol, | ||||||||||||||
| 50 | %args, | ||||||||||||||
| 51 | }, | ||||||||||||||
| 52 | ), | ||||||||||||||
| 53 | ); | ||||||||||||||
| 54 | } | ||||||||||||||
| 55 | |||||||||||||||
| 56 | 13 | __INTERFACE__ | |||||||||||||
| 57 | |||||||||||||||
| 58 | __END__ | ||||||||||||||