line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::ws_Punix; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION=.002; |
4
|
|
|
|
|
|
|
our %KNOWN; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
URI::ws_Punix - URI for ws+unix |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use URI; |
13
|
|
|
|
|
|
|
my $url='ws+unix://unix%2F:%2Ftest%2Fsocket.sock/testing'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $uri=new URI($url); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# will output: ws+unix |
18
|
|
|
|
|
|
|
print $uri->scheme,"\n"; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# will output: unix/ |
21
|
|
|
|
|
|
|
print $uri->host,"\n"; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# will output: /test/socket.sock |
24
|
|
|
|
|
|
|
print $uri->port |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# some classes don't yet understand the scheme ws+unix, so here is a work around |
27
|
|
|
|
|
|
|
$uri->set_false_scheme('ws'); |
28
|
|
|
|
|
|
|
print $uri->scheme,"\n"; # now prints "ws" |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This class acts as a parser layer for URI, and adds support for handling the rare WebSocket URI using a "Unix Domain Socket. The scheme expected is "ws+unix". Since most modules don't understand this just yet, the fake scheme or $uri->set_false_scheme('ws') was added. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
|
1162
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
37
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
52
|
|
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
2
|
|
715
|
use parent q(URI::_server); |
|
2
|
|
|
|
|
496
|
|
|
2
|
|
|
|
|
9
|
|
40
|
2
|
|
|
2
|
|
14412
|
use URI::Escape qw(uri_unescape); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
620
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 URI::ws_Punix-Edefault_port |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Returns the default port /tmp/unix.sock |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
1
|
73
|
sub default_port { '/tmp/unix.sock' } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _port { |
53
|
3
|
|
|
3
|
|
15
|
my $self=shift; |
54
|
3
|
100
|
|
|
|
14
|
return $self->SUPER::_port(@_) if $#_ >-1; |
55
|
2
|
50
|
|
|
|
12
|
if($$self=~ m,^ws+\+unix://unix%2F:?([^/]+),is) { |
56
|
2
|
|
|
|
|
8
|
return uri_unescape($1); |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
0
|
return $self->SUPER::_port(@_); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub host { |
62
|
3
|
|
|
3
|
1
|
1179
|
my $self=shift; |
63
|
3
|
100
|
|
|
|
15
|
return $self->SUPER::host('unix/') if $#_ >-1; |
64
|
2
|
50
|
|
|
|
14
|
if($$self=~ m,^ws+\+unix://unix%2F:?.*$,is) { |
65
|
2
|
|
|
|
|
8
|
return 'unix/'; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
0
|
return $self->SUPER::host(@_); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 $uri->set_false_scheme('ws') |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Used to overload the default behavior.. sometimes you may want to say "ws" in place of "ws+unix". Some modules expect ws, this method lets you overload the default of $uri->scheme. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub set_false_scheme { |
77
|
1
|
|
|
1
|
1
|
159
|
my ($self,$scheme)=@_; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
54
|
$KNOWN{$self}=$scheme; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 URI::ws_Punix-Escheme |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Normally follows the defaults unless $uri->set_false_scheme('value') was called on this instance. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub scheme { |
89
|
3
|
|
|
3
|
1
|
540
|
my $self=shift; |
90
|
3
|
100
|
|
|
|
12
|
if($#_ >-1) { |
91
|
1
|
|
|
|
|
7
|
return $self->SUPER::scheme(@_); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
2
|
100
|
|
|
|
4
|
if(exists $KNOWN{$self}) { |
95
|
1
|
|
|
|
|
6
|
return $KNOWN{$self}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
9
|
return $self->SUPER::scheme; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 URI::ws_Punix-Esecure |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns false |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
1
|
1
|
966
|
sub secure { 0 } |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
our %KNWON=(); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub DESTROY { |
112
|
3
|
|
|
3
|
|
1635
|
my $self=shift; |
113
|
|
|
|
|
|
|
|
114
|
3
|
|
|
|
|
13
|
delete $KNOWN{$self}; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Michael Shipper |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|