line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::WebSocket::URL; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
616
|
use strict; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
449
|
|
4
|
15
|
|
|
15
|
|
90
|
use warnings; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
6555
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
212
|
|
|
212
|
1
|
715
|
my $class = shift; |
8
|
212
|
50
|
|
|
|
368
|
$class = ref $class if ref $class; |
9
|
|
|
|
|
|
|
|
10
|
212
|
|
|
|
|
484
|
my $self = {@_}; |
11
|
212
|
|
|
|
|
325
|
bless $self, $class; |
12
|
|
|
|
|
|
|
|
13
|
212
|
|
100
|
|
|
715
|
$self->{secure} ||= 0; |
14
|
|
|
|
|
|
|
|
15
|
212
|
|
|
|
|
451
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
255
|
100
|
|
255
|
1
|
719
|
sub secure { @_ > 1 ? $_[0]->{secure} = $_[1] : $_[0]->{secure} } |
19
|
|
|
|
|
|
|
|
20
|
285
|
100
|
|
285
|
1
|
674
|
sub host { @_ > 1 ? $_[0]->{host} = $_[1] : $_[0]->{host} } |
21
|
260
|
100
|
|
260
|
1
|
715
|
sub port { @_ > 1 ? $_[0]->{port} = $_[1] : $_[0]->{port} } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub resource_name { |
24
|
243
|
100
|
|
243
|
1
|
687
|
@_ > 1 ? $_[0]->{resource_name} = $_[1] : $_[0]->{resource_name}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub parse { |
28
|
31
|
|
|
31
|
1
|
65
|
my $self = shift; |
29
|
31
|
|
|
|
|
107
|
my $string = shift; |
30
|
|
|
|
|
|
|
|
31
|
31
|
|
|
|
|
221
|
my ($scheme) = $string =~ m{^(wss?)://}; |
32
|
31
|
50
|
|
|
|
95
|
return unless $scheme; |
33
|
|
|
|
|
|
|
|
34
|
31
|
100
|
|
|
|
100
|
$self->secure(1) if $scheme =~ m/ss$/; |
35
|
|
|
|
|
|
|
|
36
|
31
|
|
|
|
|
538
|
my ($host, $port) = $string =~ m{^$scheme://([^:\/]+)(?::(\d+))?(?:|\/|$)}; |
37
|
31
|
50
|
33
|
|
|
166
|
$host = '/' unless defined $host && $host ne ''; |
38
|
31
|
|
|
|
|
99
|
$self->host($host); |
39
|
31
|
100
|
66
|
|
|
127
|
$port ||= $self->secure ? 443 : 80; |
40
|
31
|
|
|
|
|
83
|
$self->port($port); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# path and query |
43
|
31
|
|
|
|
|
229
|
my ($pnq) = $string =~ m{^$scheme://(?:.*?)(/.*)$}; |
44
|
31
|
100
|
66
|
|
|
135
|
$pnq = '/' unless defined $pnq && $pnq ne ''; |
45
|
31
|
|
|
|
|
87
|
$self->resource_name($pnq); |
46
|
|
|
|
|
|
|
|
47
|
31
|
|
|
|
|
126
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub to_string { |
51
|
181
|
|
|
181
|
1
|
247
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
181
|
|
|
|
|
212
|
my $string = ''; |
54
|
|
|
|
|
|
|
|
55
|
181
|
|
|
|
|
263
|
$string .= 'ws'; |
56
|
181
|
100
|
|
|
|
291
|
$string .= 's' if $self->secure; |
57
|
181
|
|
|
|
|
258
|
$string .= '://'; |
58
|
181
|
|
|
|
|
259
|
$string .= $self->host; |
59
|
181
|
100
|
|
|
|
281
|
$string .= ':' . $self->port if defined $self->port; |
60
|
181
|
|
100
|
|
|
268
|
$string .= $self->resource_name || '/'; |
61
|
|
|
|
|
|
|
|
62
|
181
|
|
|
|
|
672
|
return $string; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |