line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Engine::Response; |
2
|
67
|
|
|
67
|
|
27811
|
use Any::Moose; |
|
67
|
|
|
|
|
257299
|
|
|
67
|
|
|
|
|
555
|
|
3
|
|
|
|
|
|
|
|
4
|
67
|
|
|
67
|
|
120987
|
use HTTP::Status (); |
|
67
|
|
|
|
|
300207
|
|
|
67
|
|
|
|
|
2208
|
|
5
|
67
|
|
|
67
|
|
8669
|
use HTTP::Headers::Fast; |
|
67
|
|
|
|
|
31594
|
|
|
67
|
|
|
|
|
2651
|
|
6
|
67
|
|
|
67
|
|
5898
|
use HTTP::Engine::Types::Core qw( Header ); |
|
67
|
|
|
|
|
146
|
|
|
67
|
|
|
|
|
693
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Mouse, Moose role merging is borked with attributes |
9
|
|
|
|
|
|
|
#with qw(HTTP::Engine::Response); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub BUILD { |
12
|
68
|
|
|
68
|
1
|
867
|
my ( $self, $param ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
68
|
|
|
|
|
164
|
for my $field (qw(content_type)) { |
15
|
68
|
100
|
|
|
|
712
|
if ( my $val = $param->{$field} ) { |
16
|
2
|
|
|
|
|
16
|
$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
|
5
|
|
|
5
|
0
|
74
|
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
|
12
|
|
|
12
|
0
|
87
|
sub is_info { HTTP::Status::is_info (shift->status) } |
56
|
12
|
|
|
12
|
0
|
88
|
sub is_success { HTTP::Status::is_success (shift->status) } |
57
|
12
|
|
|
12
|
0
|
75
|
sub is_redirect { HTTP::Status::is_redirect (shift->status) } |
58
|
12
|
|
|
12
|
0
|
73
|
sub is_error { HTTP::Status::is_error (shift->status) } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
*output = \&body; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub set_http_response { |
63
|
1
|
|
|
1
|
1
|
5
|
my ($self, $res) = @_; |
64
|
1
|
|
|
|
|
5
|
$self->status( $res->code ); |
65
|
1
|
|
|
|
|
15
|
$self->headers( $res->headers->clone ); |
66
|
1
|
|
|
|
|
15
|
$self->body( $res->content ); |
67
|
1
|
|
|
|
|
13
|
$self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub as_http_response { |
71
|
34
|
|
|
34
|
0
|
66
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
34
|
|
|
|
|
4448
|
require HTTP::Response; |
74
|
34
|
|
|
|
|
9326
|
HTTP::Response->new( |
75
|
|
|
|
|
|
|
$self->status, |
76
|
|
|
|
|
|
|
'', |
77
|
|
|
|
|
|
|
$self->headers->clone, |
78
|
|
|
|
|
|
|
$self->body, # FIXME slurp file handles |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
67
|
|
|
67
|
|
53743
|
no Any::Moose; |
|
67
|
|
|
|
|
141
|
|
|
67
|
|
|
|
|
595
|
|
83
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(inline_destructor => 1); |
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
__END__ |