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