| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Eve::HttpResponse; |
|
2
|
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
10895
|
use parent qw(Eve::Class); |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
71
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
603
|
use strict; |
|
|
10
|
|
|
|
|
27
|
|
|
|
10
|
|
|
|
|
353
|
|
|
6
|
10
|
|
|
10
|
|
56
|
use warnings; |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
2546
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
B - an HTTP response abstract class. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Eve::HttpResponse::Implementation; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$response->set_status(code => 302); |
|
17
|
|
|
|
|
|
|
$response->set_header(name => 'Location', value => '/other'); |
|
18
|
|
|
|
|
|
|
$response->set_cookie( |
|
19
|
|
|
|
|
|
|
name => 'cookie1', |
|
20
|
|
|
|
|
|
|
value => 'value', |
|
21
|
|
|
|
|
|
|
domain => '.example.com', |
|
22
|
|
|
|
|
|
|
path => '/some/', |
|
23
|
|
|
|
|
|
|
expires => '+1d', |
|
24
|
|
|
|
|
|
|
secure = >1); |
|
25
|
|
|
|
|
|
|
$response->set_body(text => 'Hello world!'); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
print $response->get_text(); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
The class is an interface defining abstraction that is required to be |
|
32
|
|
|
|
|
|
|
used as a parent class for various HTTP response implementations. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 B |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub init { |
|
41
|
12
|
|
|
12
|
1
|
21
|
my $self = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
12
|
|
|
|
|
34
|
$self->{'_header_hash'} = {}; |
|
44
|
12
|
|
|
|
|
32
|
$self->{'_cookie_list'} = []; |
|
45
|
12
|
|
|
|
|
26
|
$self->{'_code'} = 200; |
|
46
|
12
|
|
|
|
|
27
|
$self->{'_body'} = ''; |
|
47
|
|
|
|
|
|
|
|
|
48
|
12
|
|
|
|
|
30
|
return; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 B |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Sets or overwrites an HTTP header of the response. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head3 Arguments |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item C |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item C |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub set_header { |
|
68
|
1
|
|
|
1
|
1
|
1736
|
Eve::Error::NotImplemented->throw(); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 B |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Sets or overwrites the HTTP response status. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head3 Arguments |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 4 |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item C |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=back |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub set_status { |
|
86
|
1
|
|
|
1
|
1
|
1246
|
Eve::Error::NotImplemented->throw(); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 B |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Sets an HTTP response cookie. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head3 Arguments |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item C |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item C |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item C |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item C |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item C |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item C |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
(optional) defaults to false |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub set_cookie { |
|
116
|
1
|
|
|
1
|
1
|
1439
|
Eve::Error::NotImplemented->throw(); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 B |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Sets or overwrites the HTTP response body. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head3 Arguments |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=over 4 |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item C |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub set_body { |
|
134
|
1
|
|
|
1
|
1
|
1414
|
Eve::Error::NotImplemented->throw(); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 B |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head3 Returns |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
The HTTP response as text. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub get_text { |
|
146
|
1
|
|
|
1
|
1
|
1399
|
Eve::Error::NotImplemented->throw(); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over 4 |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item C |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=back |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright 2012 Igor Zinovyev. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
162
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
163
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHORS |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=over 4 |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item L |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=back |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |