line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WebSocket::HTTP; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1624
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
186
|
|
4
|
6
|
|
|
6
|
|
46
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
147
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2723
|
use Call::Context (); |
|
6
|
|
|
|
|
2455
|
|
|
6
|
|
|
|
|
126
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
2409
|
use Net::WebSocket::X (); |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
1063
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=encoding utf-8 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Net::WebSocket::HTTP - HTTP utilities for Net::WebSocket |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@tokens = Net::WebSocket::HTTP::split_tokens($tokens_str); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 FUNCTIONS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 @tokens = split_tokens( TOKENS_STR ) |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
A parser for the C<1#token> format as defined in L. (C<1#> and C are defined independently of each other.) |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Returns a list of the HTTP tokens in TOKENS_STR. Throws an exception |
27
|
|
|
|
|
|
|
if any of the tokens is invalid as per the RFC’s C definition. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#Would this be useful to publish separately? It seemed so at one point, |
32
|
|
|
|
|
|
|
#but “#1token” doesn’t appear in the HTTP RFC. |
33
|
|
|
|
|
|
|
sub split_tokens { |
34
|
39
|
|
|
39
|
1
|
15526
|
my ($value) = @_; |
35
|
|
|
|
|
|
|
|
36
|
39
|
|
|
|
|
119
|
Call::Context::must_be_list(); |
37
|
|
|
|
|
|
|
|
38
|
38
|
|
|
|
|
1583
|
$value =~ s<\A[ \t]+><>; |
39
|
38
|
|
|
|
|
98
|
$value =~ s<[ \t]+\z><>; |
40
|
|
|
|
|
|
|
|
41
|
38
|
|
|
|
|
109
|
my @tokens; |
42
|
38
|
|
|
|
|
152
|
for my $p ( split m<[ \t]*,[ \t]*>, $value ) { |
43
|
42
|
100
|
|
|
|
131
|
if ($p =~ tr~()<>@,;:\\"/[]?={} \t~~) { |
44
|
16
|
|
|
|
|
59
|
die Net::WebSocket::X->create('BadToken', $p); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
26
|
|
|
|
|
63
|
push @tokens, $p; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
22
|
|
|
|
|
80
|
return @tokens; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |