line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::WebSocket::Handshake::Client; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2369
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
130
|
|
4
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
110
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
19
|
use base 'Protocol::WebSocket::Handshake'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
1420
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Carp; |
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
61
|
use Protocol::WebSocket::URL; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
84
|
|
11
|
5
|
|
|
5
|
|
1478
|
use Protocol::WebSocket::Frame; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
1980
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
19
|
|
|
19
|
1
|
1836
|
my $self = shift->SUPER::new(@_); |
15
|
|
|
|
|
|
|
|
16
|
19
|
100
|
|
|
|
66
|
$self->_set_url($self->{url}) if defined $self->{url}; |
17
|
|
|
|
|
|
|
|
18
|
19
|
100
|
|
|
|
39
|
if (my $version = $self->{version}) { |
19
|
5
|
|
|
|
|
18
|
$self->req->version($version); |
20
|
5
|
|
|
|
|
20
|
$self->res->version($version); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
19
|
|
|
|
|
85
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub url { |
27
|
4
|
|
|
4
|
1
|
38
|
my $self = shift; |
28
|
4
|
|
|
|
|
7
|
my $url = shift; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
|
|
|
11
|
return $self->{url} unless $url; |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
14
|
$self->_set_url($url); |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
9
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub parse { |
38
|
18
|
|
|
18
|
1
|
38
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
18
|
|
|
|
|
51
|
my $req = $self->req; |
41
|
18
|
|
|
|
|
37
|
my $res = $self->res; |
42
|
|
|
|
|
|
|
|
43
|
18
|
50
|
|
|
|
41
|
unless ($res->is_done) { |
44
|
18
|
100
|
|
|
|
103
|
unless ($res->parse($_[0])) { |
45
|
2
|
|
|
|
|
6
|
$self->error($res->error); |
46
|
2
|
|
|
|
|
8
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
16
|
100
|
|
|
|
43
|
if ($res->is_done) { |
50
|
6
|
50
|
66
|
|
|
16
|
if ( $req->version eq 'draft-ietf-hybi-00' |
51
|
|
|
|
|
|
|
&& $req->checksum ne $res->checksum) |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
|
|
0
|
$self->error('Checksum is wrong.'); |
54
|
0
|
|
|
|
|
0
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
16
|
|
|
|
|
72
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
15
|
|
|
15
|
1
|
50
|
sub is_done { shift->res->is_done } |
63
|
9
|
|
|
9
|
1
|
28
|
sub to_string { shift->req->to_string } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub build_frame { |
66
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
0
|
return Protocol::WebSocket::Frame->new(masked => 1, version => $self->version, @_); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
8
|
|
|
8
|
|
36
|
sub _build_url { Protocol::WebSocket::URL->new } |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _set_url { |
74
|
17
|
|
|
17
|
|
33
|
my $self = shift; |
75
|
17
|
|
|
|
|
25
|
my $url = shift; |
76
|
|
|
|
|
|
|
|
77
|
17
|
100
|
|
|
|
45
|
$url = $self->_build_url->parse($url) unless ref $url; |
78
|
|
|
|
|
|
|
|
79
|
17
|
100
|
|
|
|
37
|
$self->req->secure(1) if $url->secure; |
80
|
|
|
|
|
|
|
|
81
|
17
|
|
|
|
|
53
|
my $req = $self->req; |
82
|
|
|
|
|
|
|
|
83
|
17
|
|
|
|
|
35
|
my $host = $url->host; |
84
|
17
|
100
|
66
|
|
|
34
|
$host .= ':' . $url->port |
|
|
100
|
|
|
|
|
|
85
|
|
|
|
|
|
|
if defined $url->port |
86
|
|
|
|
|
|
|
&& ($url->secure ? $url->port ne '443' : $url->port ne '80'); |
87
|
17
|
|
|
|
|
70
|
$req->host($host); |
88
|
|
|
|
|
|
|
|
89
|
17
|
|
|
|
|
34
|
$req->resource_name($url->resource_name); |
90
|
|
|
|
|
|
|
|
91
|
17
|
|
|
|
|
46
|
return $self; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
__END__ |