| 1 | package HTTP::Engine::Response; | ||||||||||
| 2 | 67 | ▶ | use Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 67 | ▶ | use HTTP::Status (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 67 | ▶ | use HTTP::Headers::Fast; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 67 | ▶ | use HTTP::Engine::Types::Core qw( Header ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | # Mouse, Moose role merging is borked with attributes | ||||||||||
| 9 | #with qw(HTTP::Engine::Response); | ||||||||||
| 10 | |||||||||||
| 11 | 68 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 12 | 68 | my ( $self, $param ) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 68 | for my $field (qw(content_type)) { | |||||||||
| 15 | 68 | ▶ | if ( my $val = $param->{$field} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 2 | $self->$field($val); | |||||||||
| 17 | } | ||||||||||
| 18 | } | ||||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 67 | has body => ( | |||||||||
| 22 | is => 'rw', | ||||||||||
| 23 | isa => 'Any', | ||||||||||
| 24 | default => '', | ||||||||||
| 25 | ); | ||||||||||
| 26 | 0 | ▶ | sub content { shift->body(@_) } # alias | ||||||||
|
Subroutine
content: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 27 | |||||||||||
| 28 | has cookies => ( | ||||||||||
| 29 | is => 'rw', | ||||||||||
| 30 | isa => 'HashRef', | ||||||||||
| 31 | 68 | ▶ | default => sub { {} }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 67 | ); | |||||||||
| 33 | |||||||||||
| 34 | 67 | has protocol => ( | |||||||||
| 35 | is => 'rw', | ||||||||||
| 36 | # isa => 'Str', | ||||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | 67 | has status => ( | |||||||||
| 40 | is => 'rw', | ||||||||||
| 41 | isa => 'Int', | ||||||||||
| 42 | default => 200, | ||||||||||
| 43 | ); | ||||||||||
| 44 | |||||||||||
| 45 | 5 | ▶ | sub code { shift->status(@_) } | ||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 46 | |||||||||||
| 47 | has headers => ( | ||||||||||
| 48 | is => 'rw', | ||||||||||
| 49 | isa => Header, | ||||||||||
| 50 | coerce => 1, | ||||||||||
| 51 | 59 | ▶ | default => sub { HTTP::Headers::Fast->new }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 52 | 67 | handles => [ qw(content_encoding content_length content_type header) ], | |||||||||
| 53 | ); | ||||||||||
| 54 | |||||||||||
| 55 | 12 | ▶ | sub is_info { HTTP::Status::is_info (shift->status) } | ||||||||
|
Subroutine
is_info: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 56 | 12 | ▶ | sub is_success { HTTP::Status::is_success (shift->status) } | ||||||||
|
Subroutine
is_success: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 57 | 12 | ▶ | sub is_redirect { HTTP::Status::is_redirect (shift->status) } | ||||||||
|
Subroutine
is_redirect: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 58 | 12 | ▶ | sub is_error { HTTP::Status::is_error (shift->status) } | ||||||||
|
Subroutine
is_error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 59 | |||||||||||
| 60 | 67 | *output = \&body; | |||||||||
| 61 | |||||||||||
| 62 | 1 | ▶ | sub set_http_response { | ||||||||
|
Subroutine
set_http_response: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 63 | 1 | my ($self, $res) = @_; | |||||||||
| 64 | 1 | $self->status( $res->code ); | |||||||||
| 65 | 1 | $self->headers( $res->headers->clone ); | |||||||||
| 66 | 1 | $self->body( $res->content ); | |||||||||
| 67 | 1 | $self; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 34 | ▶ | sub as_http_response { | ||||||||
|
Subroutine
as_http_response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 71 | 34 | my $self = shift; | |||||||||
| 72 | |||||||||||
| 73 | 34 | require HTTP::Response; | |||||||||
| 74 | 34 | HTTP::Response->new( | |||||||||
| 75 | $self->status, | ||||||||||
| 76 | '', | ||||||||||
| 77 | $self->headers->clone, | ||||||||||
| 78 | $self->body, # FIXME slurp file handles | ||||||||||
| 79 | ); | ||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 67 | ▶ | no Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 83 | 67 | __PACKAGE__->meta->make_immutable(inline_destructor => 1); | |||||||||
| 84 | 67 | 1; | |||||||||
| 85 | __END__ | ||||||||||