line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Headers; |
2
|
61
|
|
|
61
|
|
66746
|
use Mojo::Base -base; |
|
61
|
|
|
|
|
157
|
|
|
61
|
|
|
|
|
445
|
|
3
|
|
|
|
|
|
|
|
4
|
61
|
|
|
61
|
|
399
|
use Carp qw(croak); |
|
61
|
|
|
|
|
153
|
|
|
61
|
|
|
|
|
3045
|
|
5
|
61
|
|
|
61
|
|
465
|
use Mojo::Util qw(header_params monkey_patch); |
|
61
|
|
|
|
|
161
|
|
|
61
|
|
|
|
|
154127
|
|
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
|
46800
|
|
|
46800
|
|
67673
|
my $self = shift; |
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
|
|
|
|
46800
|
|
|
|
25
|
46800
|
100
|
50
|
|
|
110341
|
$self->{headers}{$header} = [@_] and return $self if @_; |
26
|
37629
|
100
|
|
|
|
194265
|
return undef unless my $headers = $self->{headers}{$header}; |
27
|
8013
|
|
|
|
|
52160
|
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
|
17177
|
my ($self, $name) = (shift, shift); |
37
|
|
|
|
|
|
|
|
38
|
9064
|
|
66
|
|
|
25812
|
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
|
|
|
|
|
15010
|
my $key = lc $name; |
42
|
9060
|
100
|
66
|
|
|
19997
|
$self->{names}{$key} //= $name unless $NAMES{$key}; |
43
|
9060
|
|
|
|
|
11213
|
push @{$self->{headers}{$key}}, @_; |
|
9060
|
|
|
|
|
25560
|
|
44
|
|
|
|
|
|
|
|
45
|
9060
|
|
|
|
|
20042
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub append { |
49
|
57
|
|
|
57
|
1
|
907
|
my ($self, $name, $value) = @_; |
50
|
57
|
|
|
|
|
207
|
my $old = $self->header($name); |
51
|
57
|
100
|
|
|
|
286
|
return $self->header($name => defined $old ? "$old, $value" : $value); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub clone { |
55
|
81
|
|
|
81
|
1
|
181
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
81
|
|
|
|
|
208
|
my $clone = $self->new; |
58
|
81
|
|
100
|
|
|
181
|
%{$clone->{names}} = %{$self->{names} // {}}; |
|
81
|
|
|
|
|
271
|
|
|
81
|
|
|
|
|
464
|
|
59
|
81
|
|
|
|
|
183
|
@{$clone->{headers}{$_}} = @{$self->{headers}{$_}} for keys %{$self->{headers}}; |
|
81
|
|
|
|
|
812
|
|
|
305
|
|
|
|
|
837
|
|
|
305
|
|
|
|
|
534
|
|
60
|
|
|
|
|
|
|
|
61
|
81
|
|
|
|
|
368
|
return $clone; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub dehop { |
65
|
22
|
|
|
22
|
1
|
43
|
my $self = shift; |
66
|
22
|
|
|
|
|
53
|
delete @{$self->{headers}}{@HOP_BY_HOP}; |
|
22
|
|
|
|
|
94
|
|
67
|
22
|
|
|
|
|
50
|
return $self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
68
|
|
100
|
68
|
1
|
562
|
sub every_header { shift->{headers}{lc shift} // [] } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub from_hash { |
73
|
223
|
|
|
223
|
1
|
616
|
my ($self, $hash) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Empty hash deletes all headers |
76
|
223
|
100
|
|
|
|
354
|
delete $self->{headers} if keys %{$hash} == 0; |
|
223
|
|
|
|
|
944
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Merge |
79
|
223
|
|
|
|
|
725
|
for my $header (keys %$hash) { |
80
|
220
|
|
|
|
|
469
|
my $value = $hash->{$header}; |
81
|
220
|
100
|
|
|
|
826
|
$self->add($header => ref $value eq 'ARRAY' ? @$value : $value); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
223
|
|
|
|
|
580
|
return $self; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub header { |
88
|
973
|
|
|
973
|
1
|
4050
|
my ($self, $name) = (shift, shift); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Replace |
91
|
973
|
100
|
|
|
|
2747
|
return $self->remove($name)->add($name, @_) if @_; |
92
|
|
|
|
|
|
|
|
93
|
782
|
100
|
|
|
|
3515
|
return undef unless my $headers = $self->{headers}{lc $name}; |
94
|
569
|
|
|
|
|
3721
|
return join ', ', @$headers; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
2740
|
|
50
|
2740
|
1
|
11342
|
sub is_finished { (shift->{state} // '') eq 'finished' } |
98
|
|
|
|
|
|
|
|
99
|
2654
|
|
|
2654
|
1
|
8427
|
sub is_limit_exceeded { !!shift->{limit} } |
100
|
|
|
|
|
|
|
|
101
|
2134
|
|
|
2134
|
1
|
6347
|
sub leftovers { delete shift->{buffer} } |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub links { |
104
|
11
|
|
|
11
|
1
|
41
|
my ($self, $links) = @_; |
105
|
|
|
|
|
|
|
|
106
|
11
|
100
|
|
|
|
32
|
return $self->link(join(', ', map {qq{<$links->{$_}>; rel="$_"}} sort keys %$links)) if $links; |
|
4
|
|
|
|
|
25
|
|
107
|
|
|
|
|
|
|
|
108
|
8
|
|
100
|
|
|
17
|
my $header = $self->link // ''; |
109
|
8
|
|
|
|
|
17
|
my $data = {}; |
110
|
8
|
|
|
|
|
64
|
while ($header =~ s/^[,\s]*<(.+?)>//) { |
111
|
8
|
|
|
|
|
26
|
my $target = $1; |
112
|
8
|
|
|
|
|
26
|
(my $params, $header) = header_params $header; |
113
|
8
|
100
|
100
|
|
|
131
|
$data->{$params->{rel}} //= {%$params, link => $target} if defined $params->{rel}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
8
|
|
|
|
|
60
|
return $data; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub names { |
120
|
2069
|
|
|
2069
|
1
|
4788
|
my $self = shift; |
121
|
2069
|
100
|
|
|
|
3215
|
return [map { $NAMES{$_} || $self->{names}{$_} } sort keys %{$self->{headers}}]; |
|
8457
|
|
|
|
|
27256
|
|
|
2069
|
|
|
|
|
12753
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub parse { |
125
|
2741
|
|
|
2741
|
1
|
5883
|
my ($self, $chunk) = @_; |
126
|
|
|
|
|
|
|
|
127
|
2741
|
|
|
|
|
5488
|
$self->{state} = 'headers'; |
128
|
2741
|
|
|
|
|
8415
|
$self->{buffer} .= $chunk; |
129
|
2741
|
|
100
|
|
|
9615
|
my $headers = $self->{cache} //= []; |
130
|
2741
|
|
|
|
|
6849
|
my $size = $self->max_line_size; |
131
|
2741
|
|
|
|
|
7033
|
my $lines = $self->max_lines; |
132
|
2741
|
|
|
|
|
63020
|
while ($self->{buffer} =~ s/^(.*?)\x0d?\x0a//) { |
133
|
10645
|
|
|
|
|
26613
|
my $line = $1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Check line size limit |
136
|
10645
|
100
|
100
|
|
|
41664
|
if ($+[0] > $size || @$headers >= $lines) { |
137
|
5
|
|
|
|
|
29
|
@$self{qw(state limit)} = ('finished', 1); |
138
|
5
|
|
|
|
|
36
|
return $self; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# New header |
142
|
10640
|
100
|
66
|
|
|
42162
|
if ($line =~ /^(\S[^:]*):\s*(.*)$/) { push @$headers, [$1, $2] } |
|
8504
|
100
|
|
|
|
125259
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Multi-line |
145
|
3
|
|
|
|
|
21
|
elsif ($line =~ s/^\s+// && @$headers) { $headers->[-1][1] .= " $line" } |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Empty line |
148
|
|
|
|
|
|
|
else { |
149
|
2133
|
|
|
|
|
7963
|
$self->add(@$_) for @$headers; |
150
|
2133
|
|
|
|
|
6019
|
@$self{qw(state cache)} = ('finished', []); |
151
|
2133
|
|
|
|
|
9904
|
return $self; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Check line size limit |
156
|
603
|
100
|
|
|
|
1265
|
@$self{qw(state limit)} = ('finished', 1) if length $self->{buffer} > $size; |
157
|
|
|
|
|
|
|
|
158
|
603
|
|
|
|
|
1151
|
return $self; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
3
|
|
|
3
|
1
|
11
|
sub referer { shift->referrer(@_) } |
162
|
10
|
|
|
10
|
1
|
33
|
sub referrer { shift->header(Referer => @_) } |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub remove { |
165
|
1357
|
|
|
1357
|
1
|
2986
|
my ($self, $name) = @_; |
166
|
1357
|
|
|
|
|
4227
|
delete $self->{headers}{lc $name}; |
167
|
1357
|
|
|
|
|
3088
|
return $self; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub to_hash { |
171
|
28
|
|
|
28
|
1
|
3714
|
my ($self, $multi) = @_; |
172
|
28
|
100
|
|
|
|
64
|
return {map { $_ => $self->{headers}{lc $_} } @{$self->names}} if $multi; |
|
45
|
|
|
|
|
263
|
|
|
18
|
|
|
|
|
37
|
|
173
|
10
|
|
|
|
|
20
|
return {map { $_ => $self->header($_) } @{$self->names}}; |
|
24
|
|
|
|
|
42
|
|
|
10
|
|
|
|
|
22
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub to_string { |
177
|
1971
|
|
|
1971
|
1
|
3413
|
my $self = shift; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Make sure multi-line values are formatted correctly |
180
|
1971
|
|
|
|
|
3014
|
my @headers; |
181
|
1971
|
|
|
|
|
2894
|
for my $name (@{$self->names}) { push @headers, "$name: $_" for @{$self->{headers}{lc $name}} } |
|
1971
|
|
|
|
|
4651
|
|
|
8155
|
|
|
|
|
11180
|
|
|
8155
|
|
|
|
|
30471
|
|
182
|
|
|
|
|
|
|
|
183
|
1971
|
|
|
|
|
10273
|
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 |