line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WebSocket::Handshake::Base; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1238
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
73
|
|
4
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
98
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1390
|
use Digest::SHA (); |
|
2
|
|
|
|
|
9038
|
|
|
2
|
|
|
|
|
69
|
|
7
|
2
|
|
|
2
|
|
1318
|
use Module::Load (); |
|
2
|
|
|
|
|
3690
|
|
|
2
|
|
|
|
|
70
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
22
|
use constant _WS_MAGIC_CONSTANT => '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
935
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub create_header_text { |
12
|
1
|
|
|
1
|
0
|
27
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
7
|
return join( "\x0d\x0a", $self->_create_header_lines(), q<> ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _get_accept { |
18
|
1
|
|
|
1
|
|
3
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
8
|
my $key_b64 = $self->{'key'}; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
7
|
$key_b64 =~ s<\A\s+|\s+\z><>g; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
21
|
my $accept = Digest::SHA::sha1_base64( $key_b64 . _WS_MAGIC_CONSTANT() ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#pad base64 |
27
|
1
|
|
|
|
|
4
|
$accept .= '=' x (4 - (length($accept) % 4)); |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
6
|
return $accept; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _encode_subprotocols { |
33
|
1
|
|
|
1
|
|
96
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return ( $self->{'subprotocols'} |
36
|
1
|
50
|
|
|
|
6
|
? ( 'Sec-WebSocket-Protocol: ' . join(', ', @{ $self->{'subprotocols'} } ) ) |
|
1
|
|
|
|
|
25
|
|
37
|
|
|
|
|
|
|
: () |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _encode_extensions { |
42
|
1
|
|
|
1
|
|
5
|
my ($self) = @_; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
6
|
Module::Load::load('HTTP::Headers::Util'); |
45
|
|
|
|
|
|
|
|
46
|
1
|
50
|
|
|
|
132
|
return if !$self->{'extensions'}; |
47
|
1
|
50
|
|
|
|
3
|
return if !@{ $self->{'extensions'} }; |
|
1
|
|
|
|
|
6
|
|
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
4
|
my ($first, @others) = @{ $self->{'extensions'} }; |
|
1
|
|
|
|
|
4
|
|
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
8
|
return 'Sec-WebSocket-Extensions: ' . $first->to_string(@others); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |