line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Headers; |
2
|
61
|
|
|
61
|
|
63192
|
use Mojo::Base -base; |
|
61
|
|
|
|
|
156
|
|
|
61
|
|
|
|
|
416
|
|
3
|
|
|
|
|
|
|
|
4
|
61
|
|
|
61
|
|
451
|
use Carp qw(croak); |
|
61
|
|
|
|
|
134
|
|
|
61
|
|
|
|
|
3112
|
|
5
|
61
|
|
|
61
|
|
458
|
use Mojo::Util qw(header_params monkey_patch); |
|
61
|
|
|
|
|
142
|
|
|
61
|
|
|
|
|
151542
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has max_line_size => sub { $ENV{MOJO_MAX_LINE_SIZE} || 8192 }; |
8
|
|
|
|
|
|
|
has max_lines => sub { $ENV{MOJO_MAX_LINES} || 100 }; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Common headers |
11
|
|
|
|
|
|
|
my %NAMES = map { lc() => $_ } ( |
12
|
|
|
|
|
|
|
qw(Accept Accept-Charset Accept-Encoding Accept-Language Accept-Ranges Access-Control-Allow-Origin Allow), |
13
|
|
|
|
|
|
|
qw(Authorization Cache-Control Connection Content-Disposition Content-Encoding Content-Language Content-Length), |
14
|
|
|
|
|
|
|
qw(Content-Location Content-Range Content-Security-Policy Content-Type Cookie DNT Date ETag Expect Expires Host), |
15
|
|
|
|
|
|
|
qw(If-Modified-Since If-None-Match Last-Modified Link Location Origin Proxy-Authenticate Proxy-Authorization), |
16
|
|
|
|
|
|
|
qw(Range Sec-WebSocket-Accept Sec-WebSocket-Extensions Sec-WebSocket-Key Sec-WebSocket-Protocol), |
17
|
|
|
|
|
|
|
qw(Sec-WebSocket-Version Server Server-Timing Set-Cookie Status Strict-Transport-Security TE Trailer), |
18
|
|
|
|
|
|
|
qw(Transfer-Encoding Upgrade User-Agent Vary WWW-Authenticate) |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
for my $header (keys %NAMES) { |
21
|
|
|
|
|
|
|
my $name = $header; |
22
|
|
|
|
|
|
|
$name =~ y/-/_/; |
23
|
|
|
|
|
|
|
monkey_patch __PACKAGE__, $name, sub { |
24
|
46963
|
|
|
46963
|
|
68928
|
my $self = shift; |
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
|
|
|
|
46963
|
|
|
|
25
|
46963
|
100
|
50
|
|
|
111402
|
$self->{headers}{$header} = [@_] and return $self if @_; |
26
|
37792
|
100
|
|
|
|
189338
|
return undef unless my $headers = $self->{headers}{$header}; |
27
|
8079
|
|
|
|
|
51347
|
return join ', ', @$headers; |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Hop-by-hop headers |
32
|
|
|
|
|
|
|
my @HOP_BY_HOP |
33
|
|
|
|
|
|
|
= map {lc} qw(Connection Keep-Alive Proxy-Authenticate Proxy-Authorization TE Trailer Transfer-Encoding Upgrade); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub add { |
36
|
9064
|
|
|
9064
|
1
|
16981
|
my ($self, $name) = (shift, shift); |
37
|
|
|
|
|
|
|
|
38
|
9064
|
|
66
|
|
|
25470
|
tr/\x0d\x0a// and croak "Invalid characters in $name header" for @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Make sure we have a normal case entry for name |
41
|
9060
|
|
|
|
|
15121
|
my $key = lc $name; |
42
|
9060
|
100
|
66
|
|
|
19779
|
$self->{names}{$key} //= $name unless $NAMES{$key}; |
43
|
9060
|
|
|
|
|
11638
|
push @{$self->{headers}{$key}}, @_; |
|
9060
|
|
|
|
|
24835
|
|
44
|
|
|
|
|
|
|
|
45
|
9060
|
|
|
|
|
19905
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub append { |
49
|
57
|
|
|
57
|
1
|
865
|
my ($self, $name, $value) = @_; |
50
|
57
|
|
|
|
|
191
|
my $old = $self->header($name); |
51
|
57
|
100
|
|
|
|
282
|
return $self->header($name => defined $old ? "$old, $value" : $value); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub clone { |
55
|
81
|
|
|
81
|
1
|
163
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
81
|
|
|
|
|
225
|
my $clone = $self->new; |
58
|
81
|
|
100
|
|
|
151
|
%{$clone->{names}} = %{$self->{names} // {}}; |
|
81
|
|
|
|
|
273
|
|
|
81
|
|
|
|
|
421
|
|
59
|
81
|
|
|
|
|
185
|
@{$clone->{headers}{$_}} = @{$self->{headers}{$_}} for keys %{$self->{headers}}; |
|
81
|
|
|
|
|
689
|
|
|
305
|
|
|
|
|
831
|
|
|
305
|
|
|
|
|
493
|
|
60
|
|
|
|
|
|
|
|
61
|
81
|
|
|
|
|
309
|
return $clone; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub dehop { |
65
|
22
|
|
|
22
|
1
|
57
|
my $self = shift; |
66
|
22
|
|
|
|
|
50
|
delete @{$self->{headers}}{@HOP_BY_HOP}; |
|
22
|
|
|
|
|
100
|
|
67
|
22
|
|
|
|
|
60
|
return $self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
68
|
|
100
|
68
|
1
|
499
|
sub every_header { shift->{headers}{lc shift} // [] } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub from_hash { |
73
|
223
|
|
|
223
|
1
|
645
|
my ($self, $hash) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Empty hash deletes all headers |
76
|
223
|
100
|
|
|
|
366
|
delete $self->{headers} if keys %{$hash} == 0; |
|
223
|
|
|
|
|
969
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Merge |
79
|
223
|
|
|
|
|
731
|
for my $header (keys %$hash) { |
80
|
220
|
|
|
|
|
501
|
my $value = $hash->{$header}; |
81
|
220
|
100
|
|
|
|
848
|
$self->add($header => ref $value eq 'ARRAY' ? @$value : $value); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
223
|
|
|
|
|
555
|
return $self; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub header { |
88
|
973
|
|
|
973
|
1
|
3913
|
my ($self, $name) = (shift, shift); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Replace |
91
|
973
|
100
|
|
|
|
2606
|
return $self->remove($name)->add($name, @_) if @_; |
92
|
|
|
|
|
|
|
|
93
|
782
|
100
|
|
|
|
3065
|
return undef unless my $headers = $self->{headers}{lc $name}; |
94
|
569
|
|
|
|
|
3483
|
return join ', ', @$headers; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
2778
|
|
50
|
2778
|
1
|
11089
|
sub is_finished { (shift->{state} // '') eq 'finished' } |
98
|
|
|
|
|
|
|
|
99
|
2687
|
|
|
2687
|
1
|
8340
|
sub is_limit_exceeded { !!shift->{limit} } |
100
|
|
|
|
|
|
|
|
101
|
2134
|
|
|
2134
|
1
|
6268
|
sub leftovers { delete shift->{buffer} } |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub links { |
104
|
11
|
|
|
11
|
1
|
33
|
my ($self, $links) = @_; |
105
|
|
|
|
|
|
|
|
106
|
11
|
100
|
|
|
|
37
|
return $self->link(join(', ', map {qq{<$links->{$_}>; rel="$_"}} sort keys %$links)) if $links; |
|
4
|
|
|
|
|
23
|
|
107
|
|
|
|
|
|
|
|
108
|
8
|
|
100
|
|
|
18
|
my $header = $self->link // ''; |
109
|
8
|
|
|
|
|
16
|
my $data = {}; |
110
|
8
|
|
|
|
|
56
|
while ($header =~ s/^[,\s]*<(.+?)>//) { |
111
|
8
|
|
|
|
|
22
|
my $target = $1; |
112
|
8
|
|
|
|
|
25
|
(my $params, $header) = header_params $header; |
113
|
8
|
100
|
100
|
|
|
142
|
$data->{$params->{rel}} //= {%$params, link => $target} if defined $params->{rel}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
8
|
|
|
|
|
46
|
return $data; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub names { |
120
|
2069
|
|
|
2069
|
1
|
4864
|
my $self = shift; |
121
|
2069
|
100
|
|
|
|
2986
|
return [map { $NAMES{$_} || $self->{names}{$_} } sort keys %{$self->{headers}}]; |
|
8457
|
|
|
|
|
26063
|
|
|
2069
|
|
|
|
|
12009
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub parse { |
125
|
2779
|
|
|
2779
|
1
|
5832
|
my ($self, $chunk) = @_; |
126
|
|
|
|
|
|
|
|
127
|
2779
|
|
|
|
|
5334
|
$self->{state} = 'headers'; |
128
|
2779
|
|
|
|
|
8314
|
$self->{buffer} .= $chunk; |
129
|
2779
|
|
100
|
|
|
9706
|
my $headers = $self->{cache} //= []; |
130
|
2779
|
|
|
|
|
6837
|
my $size = $self->max_line_size; |
131
|
2779
|
|
|
|
|
6655
|
my $lines = $self->max_lines; |
132
|
2779
|
|
|
|
|
69483
|
while ($self->{buffer} =~ s/^(.*?)\x0d?\x0a//) { |
133
|
10645
|
|
|
|
|
26781
|
my $line = $1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Check line size limit |
136
|
10645
|
100
|
100
|
|
|
40710
|
if ($+[0] > $size || @$headers >= $lines) { |
137
|
5
|
|
|
|
|
21
|
@$self{qw(state limit)} = ('finished', 1); |
138
|
5
|
|
|
|
|
23
|
return $self; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# New header |
142
|
10640
|
100
|
66
|
|
|
40828
|
if ($line =~ /^(\S[^:]*):\s*(.*)$/) { push @$headers, [$1, $2] } |
|
8504
|
100
|
|
|
|
131133
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Multi-line |
145
|
3
|
|
|
|
|
22
|
elsif ($line =~ s/^\s+// && @$headers) { $headers->[-1][1] .= " $line" } |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Empty line |
148
|
|
|
|
|
|
|
else { |
149
|
2133
|
|
|
|
|
7713
|
$self->add(@$_) for @$headers; |
150
|
2133
|
|
|
|
|
5705
|
@$self{qw(state cache)} = ('finished', []); |
151
|
2133
|
|
|
|
|
9306
|
return $self; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Check line size limit |
156
|
641
|
100
|
|
|
|
1384
|
@$self{qw(state limit)} = ('finished', 1) if length $self->{buffer} > $size; |
157
|
|
|
|
|
|
|
|
158
|
641
|
|
|
|
|
1278
|
return $self; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
3
|
|
|
3
|
1
|
10
|
sub referer { shift->referrer(@_) } |
162
|
10
|
|
|
10
|
1
|
32
|
sub referrer { shift->header(Referer => @_) } |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub remove { |
165
|
1357
|
|
|
1357
|
1
|
2958
|
my ($self, $name) = @_; |
166
|
1357
|
|
|
|
|
4249
|
delete $self->{headers}{lc $name}; |
167
|
1357
|
|
|
|
|
2971
|
return $self; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub to_hash { |
171
|
28
|
|
|
28
|
1
|
3748
|
my ($self, $multi) = @_; |
172
|
28
|
100
|
|
|
|
61
|
return {map { $_ => $self->{headers}{lc $_} } @{$self->names}} if $multi; |
|
45
|
|
|
|
|
189
|
|
|
18
|
|
|
|
|
44
|
|
173
|
10
|
|
|
|
|
14
|
return {map { $_ => $self->header($_) } @{$self->names}}; |
|
24
|
|
|
|
|
46
|
|
|
10
|
|
|
|
|
24
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub to_string { |
177
|
1971
|
|
|
1971
|
1
|
3195
|
my $self = shift; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Make sure multi-line values are formatted correctly |
180
|
1971
|
|
|
|
|
3056
|
my @headers; |
181
|
1971
|
|
|
|
|
2872
|
for my $name (@{$self->names}) { push @headers, "$name: $_" for @{$self->{headers}{lc $name}} } |
|
1971
|
|
|
|
|
4448
|
|
|
8155
|
|
|
|
|
11245
|
|
|
8155
|
|
|
|
|
29437
|
|
182
|
|
|
|
|
|
|
|
183
|
1971
|
|
|
|
|
9983
|
return join "\x0d\x0a", @headers; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=encoding utf8 |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 NAME |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Mojo::Headers - HTTP headers |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SYNOPSIS |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
use Mojo::Headers; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# Parse |
199
|
|
|
|
|
|
|
my $headers = Mojo::Headers->new; |
200
|
|
|
|
|
|
|
$headers->parse("Content-Length: 42\x0d\x0a"); |
201
|
|
|
|
|
|
|
$headers->parse("Content-Type: text/html\x0d\x0a\x0d\x0a"); |
202
|
|
|
|
|
|
|
say $headers->content_length; |
203
|
|
|
|
|
|
|
say $headers->content_type; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Build |
206
|
|
|
|
|
|
|
my $headers = Mojo::Headers->new; |
207
|
|
|
|
|
|
|
$headers->content_length(42); |
208
|
|
|
|
|
|
|
$headers->content_type('text/plain'); |
209
|
|
|
|
|
|
|
say $headers->to_string; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 DESCRIPTION |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
L is a container for HTTP headers, based on L and L
|
214
|
|
|
|
|
|
|
7231|https://tools.ietf.org/html/rfc7231>. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L implements the following attributes. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 max_line_size |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
my $size = $headers->max_line_size; |
223
|
|
|
|
|
|
|
$headers = $headers->max_line_size(1024); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Maximum header line size in bytes, defaults to the value of the C environment variable or C<8192> |
226
|
|
|
|
|
|
|
(8KiB). |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 max_lines |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
my $num = $headers->max_lines; |
231
|
|
|
|
|
|
|
$headers = $headers->max_lines(200); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Maximum number of header lines, defaults to the value of the C environment variable or C<100>. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 METHODS |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
L inherits all methods from L and implements the following new ones. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head2 accept |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
my $accept = $headers->accept; |
242
|
|
|
|
|
|
|
$headers = $headers->accept('application/json'); |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head2 accept_charset |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
my $charset = $headers->accept_charset; |
249
|
|
|
|
|
|
|
$headers = $headers->accept_charset('UTF-8'); |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head2 accept_encoding |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
my $encoding = $headers->accept_encoding; |
256
|
|
|
|
|
|
|
$headers = $headers->accept_encoding('gzip'); |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head2 accept_language |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
my $language = $headers->accept_language; |
263
|
|
|
|
|
|
|
$headers = $headers->accept_language('de, en'); |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head2 accept_ranges |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
my $ranges = $headers->accept_ranges; |
270
|
|
|
|
|
|
|
$headers = $headers->accept_ranges('bytes'); |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 access_control_allow_origin |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
my $origin = $headers->access_control_allow_origin; |
277
|
|
|
|
|
|
|
$headers = $headers->access_control_allow_origin('*'); |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
280
|
|
|
|
|
|
|
Resource Sharing|https://www.w3.org/TR/cors/>. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head2 add |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$headers = $headers->add(Foo => 'one value'); |
285
|
|
|
|
|
|
|
$headers = $headers->add(Foo => 'first value', 'second value'); |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Add header with one or more lines. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
# "Vary: Accept |
290
|
|
|
|
|
|
|
# Vary: Accept-Encoding" |
291
|
|
|
|
|
|
|
$headers->add(Vary => 'Accept')->add(Vary => 'Accept-Encoding')->to_string; |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head2 allow |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
my $allow = $headers->allow; |
296
|
|
|
|
|
|
|
$headers = $headers->allow('GET, POST'); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head2 append |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
$headers = $headers->append(Vary => 'Accept-Encoding'); |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Append value to header and flatten it if necessary. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
# "Vary: Accept" |
307
|
|
|
|
|
|
|
$headers->append(Vary => 'Accept')->to_string; |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
# "Vary: Accept, Accept-Encoding" |
310
|
|
|
|
|
|
|
$headers->vary('Accept')->append(Vary => 'Accept-Encoding')->to_string; |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head2 authorization |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
my $authorization = $headers->authorization; |
315
|
|
|
|
|
|
|
$headers = $headers->authorization('Basic Zm9vOmJhcg=='); |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head2 cache_control |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
my $cache_control = $headers->cache_control; |
322
|
|
|
|
|
|
|
$headers = $headers->cache_control('max-age=1, no-cache'); |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head2 clone |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
my $clone = $headers->clone; |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Return a new L object cloned from these headers. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=head2 connection |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
my $connection = $headers->connection; |
335
|
|
|
|
|
|
|
$headers = $headers->connection('close'); |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=head2 content_disposition |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
my $disposition = $headers->content_disposition; |
342
|
|
|
|
|
|
|
$headers = $headers->content_disposition('foo'); |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=head2 content_encoding |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
my $encoding = $headers->content_encoding; |
349
|
|
|
|
|
|
|
$headers = $headers->content_encoding('gzip'); |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=head2 content_language |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
my $language = $headers->content_language; |
356
|
|
|
|
|
|
|
$headers = $headers->content_language('en'); |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=head2 content_length |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
my $len = $headers->content_length; |
363
|
|
|
|
|
|
|
$headers = $headers->content_length(4000); |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=head2 content_location |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
my $location = $headers->content_location; |
370
|
|
|
|
|
|
|
$headers = $headers->content_location('http://127.0.0.1/foo'); |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=head2 content_range |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
my $range = $headers->content_range; |
377
|
|
|
|
|
|
|
$headers = $headers->content_range('bytes 2-8/100'); |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head2 content_security_policy |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
my $policy = $headers->content_security_policy; |
384
|
|
|
|
|
|
|
$headers = $headers->content_security_policy('default-src https:'); |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
387
|
|
|
|
|
|
|
1.0|https://www.w3.org/TR/CSP/>. |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
=head2 content_type |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
my $type = $headers->content_type; |
392
|
|
|
|
|
|
|
$headers = $headers->content_type('text/plain'); |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=head2 cookie |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
my $cookie = $headers->cookie; |
399
|
|
|
|
|
|
|
$headers = $headers->cookie('f=b'); |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
402
|
|
|
|
|
|
|
6265|https://tools.ietf.org/html/rfc6265>. |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=head2 date |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
my $date = $headers->date; |
407
|
|
|
|
|
|
|
$headers = $headers->date('Sun, 17 Aug 2008 16:27:35 GMT'); |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=head2 dehop |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
$headers = $headers->dehop; |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
Remove hop-by-hop headers that should not be retransmitted. |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=head2 dnt |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
my $dnt = $headers->dnt; |
420
|
|
|
|
|
|
|
$headers = $headers->dnt(1); |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C (Do Not Track) header, which has no specification yet, but |
423
|
|
|
|
|
|
|
is very commonly used. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=head2 etag |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
my $etag = $headers->etag; |
428
|
|
|
|
|
|
|
$headers = $headers->etag('"abc321"'); |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=head2 every_header |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
my $all = $headers->every_header('Location'); |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
Similar to L"header">, but returns all headers sharing the same name as an array reference. |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
# Get first header value |
439
|
|
|
|
|
|
|
say $headers->every_header('Location')->[0]; |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=head2 expect |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
my $expect = $headers->expect; |
444
|
|
|
|
|
|
|
$headers = $headers->expect('100-continue'); |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
=head2 expires |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
my $expires = $headers->expires; |
451
|
|
|
|
|
|
|
$headers = $headers->expires('Thu, 01 Dec 1994 16:00:00 GMT'); |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head2 from_hash |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
$headers = $headers->from_hash({'Cookie' => 'a=b'}); |
458
|
|
|
|
|
|
|
$headers = $headers->from_hash({'Cookie' => ['a=b', 'c=d']}); |
459
|
|
|
|
|
|
|
$headers = $headers->from_hash({}); |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
Parse headers from a hash reference, an empty hash removes all headers. |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head2 header |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
my $value = $headers->header('Foo'); |
466
|
|
|
|
|
|
|
$headers = $headers->header(Foo => 'one value'); |
467
|
|
|
|
|
|
|
$headers = $headers->header(Foo => 'first value', 'second value'); |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Get or replace the current header values. |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=head2 host |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
my $host = $headers->host; |
474
|
|
|
|
|
|
|
$headers = $headers->host('127.0.0.1'); |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=head2 if_modified_since |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
my $date = $headers->if_modified_since; |
481
|
|
|
|
|
|
|
$headers = $headers->if_modified_since('Sun, 17 Aug 2008 16:27:35 GMT'); |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
=head2 if_none_match |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
my $etag = $headers->if_none_match; |
488
|
|
|
|
|
|
|
$headers = $headers->if_none_match('"abc321"'); |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
=head2 is_finished |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
my $bool = $headers->is_finished; |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
Check if header parser is finished. |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head2 is_limit_exceeded |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
my $bool = $headers->is_limit_exceeded; |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
Check if headers have exceeded L"max_line_size"> or L"max_lines">. |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=head2 last_modified |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
my $date = $headers->last_modified; |
507
|
|
|
|
|
|
|
$headers = $headers->last_modified('Sun, 17 Aug 2008 16:27:35 GMT'); |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=head2 leftovers |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
my $bytes = $headers->leftovers; |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
Get and remove leftover data from header parser. |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=head2 link |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
my $link = $headers->link; |
520
|
|
|
|
|
|
|
$headers = $headers->link('; rel="next"'); |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
523
|
|
|
|
|
|
|
5988|https://tools.ietf.org/html/rfc5988>. |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=head2 links |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
my $links = $headers->links; |
528
|
|
|
|
|
|
|
$headers = $headers->links({next => 'http://example.com/foo', prev => 'http://example.com/bar'}); |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
Get or set web links from or to C header according to L. |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
# Extract information about next page |
533
|
|
|
|
|
|
|
say $headers->links->{next}{link}; |
534
|
|
|
|
|
|
|
say $headers->links->{next}{title}; |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head2 location |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
my $location = $headers->location; |
539
|
|
|
|
|
|
|
$headers = $headers->location('http://127.0.0.1/foo'); |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=head2 names |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
my $names = $headers->names; |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
Return an array reference with all currently defined headers. |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
# Names of all headers |
550
|
|
|
|
|
|
|
say for @{$headers->names}; |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
=head2 origin |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
my $origin = $headers->origin; |
555
|
|
|
|
|
|
|
$headers = $headers->origin('http://example.com'); |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
558
|
|
|
|
|
|
|
6454|https://tools.ietf.org/html/rfc6454>. |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
=head2 parse |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
$headers = $headers->parse("Content-Type: text/plain\x0d\x0a\x0d\x0a"); |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
Parse formatted headers. |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=head2 proxy_authenticate |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
my $authenticate = $headers->proxy_authenticate; |
569
|
|
|
|
|
|
|
$headers = $headers->proxy_authenticate('Basic "realm"'); |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=head2 proxy_authorization |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
my $authorization = $headers->proxy_authorization; |
576
|
|
|
|
|
|
|
$headers = $headers->proxy_authorization('Basic Zm9vOmJhcg=='); |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
=head2 range |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
my $range = $headers->range; |
583
|
|
|
|
|
|
|
$headers = $headers->range('bytes=2-8'); |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=head2 referer |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
my $referrer = $headers->referer; |
590
|
|
|
|
|
|
|
$headers = $headers->referer('http://example.com'); |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
Alias for L"referrer">. |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
=head2 referrer |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
my $referrer = $headers->referrer; |
597
|
|
|
|
|
|
|
$headers = $headers->referrer('http://example.com'); |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header, there was a typo in L
|
600
|
|
|
|
|
|
|
2068|https://tools.ietf.org/html/rfc2068> which resulted in C becoming an official header. |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
=head2 remove |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
$headers = $headers->remove('Foo'); |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
Remove a header. |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=head2 sec_websocket_accept |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
my $accept = $headers->sec_websocket_accept; |
611
|
|
|
|
|
|
|
$headers = $headers->sec_websocket_accept('s3pPLMBiTxaQ9kYGzzhZRbK+xOo='); |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
614
|
|
|
|
|
|
|
6455|https://tools.ietf.org/html/rfc6455>. |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
=head2 sec_websocket_extensions |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
my $extensions = $headers->sec_websocket_extensions; |
619
|
|
|
|
|
|
|
$headers = $headers->sec_websocket_extensions('foo'); |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
622
|
|
|
|
|
|
|
6455|https://tools.ietf.org/html/rfc6455>. |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
=head2 sec_websocket_key |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
my $key = $headers->sec_websocket_key; |
627
|
|
|
|
|
|
|
$headers = $headers->sec_websocket_key('dGhlIHNhbXBsZSBub25jZQ=='); |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
630
|
|
|
|
|
|
|
6455|https://tools.ietf.org/html/rfc6455>. |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=head2 sec_websocket_protocol |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
my $proto = $headers->sec_websocket_protocol; |
635
|
|
|
|
|
|
|
$headers = $headers->sec_websocket_protocol('sample'); |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
638
|
|
|
|
|
|
|
6455|https://tools.ietf.org/html/rfc6455>. |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
=head2 sec_websocket_version |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
my $version = $headers->sec_websocket_version; |
643
|
|
|
|
|
|
|
$headers = $headers->sec_websocket_version(13); |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
646
|
|
|
|
|
|
|
6455|https://tools.ietf.org/html/rfc6455>. |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=head2 server |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
my $server = $headers->server; |
651
|
|
|
|
|
|
|
$headers = $headers->server('Mojo'); |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
=head2 server_timing |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
my $timing = $headers->server_timing; |
658
|
|
|
|
|
|
|
$headers = $headers->server_timing('app;desc=Mojolicious;dur=0.0001'); |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
661
|
|
|
|
|
|
|
Timing|https://www.w3.org/TR/server-timing/>. |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
=head2 set_cookie |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
my $cookie = $headers->set_cookie; |
666
|
|
|
|
|
|
|
$headers = $headers->set_cookie('f=b; path=/'); |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
669
|
|
|
|
|
|
|
6265|https://tools.ietf.org/html/rfc6265>. |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
=head2 status |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
my $status = $headers->status; |
674
|
|
|
|
|
|
|
$headers = $headers->status('200 OK'); |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
677
|
|
|
|
|
|
|
3875|https://tools.ietf.org/html/rfc3875>. |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=head2 strict_transport_security |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
my $policy = $headers->strict_transport_security; |
682
|
|
|
|
|
|
|
$headers = $headers->strict_transport_security('max-age=31536000'); |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header from L
|
685
|
|
|
|
|
|
|
6797|https://tools.ietf.org/html/rfc6797>. |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
=head2 te |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
my $te = $headers->te; |
690
|
|
|
|
|
|
|
$headers = $headers->te('chunked'); |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
=head2 to_hash |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
my $single = $headers->to_hash; |
697
|
|
|
|
|
|
|
my $multi = $headers->to_hash(1); |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
Turn headers into hash reference, array references to represent multiple headers with the same name are disabled by |
700
|
|
|
|
|
|
|
default. |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
say $headers->to_hash->{DNT}; |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=head2 to_string |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
my $str = $headers->to_string; |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
Turn headers into a string, suitable for HTTP messages. |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
=head2 trailer |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
my $trailer = $headers->trailer; |
713
|
|
|
|
|
|
|
$headers = $headers->trailer('X-Foo'); |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
=head2 transfer_encoding |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
my $encoding = $headers->transfer_encoding; |
720
|
|
|
|
|
|
|
$headers = $headers->transfer_encoding('chunked'); |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=head2 upgrade |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
my $upgrade = $headers->upgrade; |
727
|
|
|
|
|
|
|
$headers = $headers->upgrade('websocket'); |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
=head2 user_agent |
732
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
my $agent = $headers->user_agent; |
734
|
|
|
|
|
|
|
$headers = $headers->user_agent('Mojo/1.0'); |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
=head2 vary |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
my $vary = $headers->vary; |
741
|
|
|
|
|
|
|
$headers = $headers->vary('*'); |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
=head2 www_authenticate |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
my $authenticate = $headers->www_authenticate; |
748
|
|
|
|
|
|
|
$headers = $headers->www_authenticate('Basic realm="realm"'); |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
Get or replace current header value, shortcut for the C header. |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
=head1 SEE ALSO |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
L, L, L. |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
=cut |