line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SockJS::Transport::Base; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
66561
|
use strict; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
246
|
|
4
|
9
|
|
|
9
|
|
41
|
use warnings; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
236
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
44
|
use List::Util qw(any); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
4529
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
39
|
|
|
39
|
0
|
10018
|
my $class = shift; |
10
|
39
|
|
|
|
|
94
|
my (%params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
39
|
|
|
|
|
93
|
my $self = {}; |
13
|
39
|
|
|
|
|
100
|
bless $self, $class; |
14
|
|
|
|
|
|
|
|
15
|
39
|
|
100
|
|
|
242
|
$self->{name} = $params{name} || ''; |
16
|
39
|
|
|
|
|
95
|
$self->{allowed_methods} = ['OPTIONS']; |
17
|
|
|
|
|
|
|
|
18
|
39
|
|
|
|
|
126
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
0
|
37
|
sub name { shift->{name} } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub dispatch { |
24
|
38
|
|
|
38
|
0
|
1856
|
my $self = shift; |
25
|
38
|
|
|
|
|
91
|
my ($env) = @_; |
26
|
|
|
|
|
|
|
|
27
|
38
|
|
|
|
|
99
|
$env->{'sockjs.cacheable'} = $self->{cacheable}; |
28
|
38
|
|
|
|
|
66
|
$env->{'sockjs.allowed_methods'} = $self->{allowed_methods}; |
29
|
|
|
|
|
|
|
|
30
|
38
|
|
|
|
|
65
|
my $method = $env->{REQUEST_METHOD}; |
31
|
38
|
100
|
|
75
|
|
128
|
if ( !any { $_ eq $method } @{ $self->{allowed_methods} } ) { |
|
75
|
|
|
|
|
176
|
|
|
38
|
|
|
|
|
214
|
|
32
|
1
|
|
|
|
|
2
|
return [ 405, [ 'Allow' => join ', ', @{ $self->{allowed_methods} } ], |
|
1
|
|
|
|
|
7
|
|
33
|
|
|
|
|
|
|
[''] ]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
37
|
|
|
|
|
152
|
$method = "dispatch_$method"; |
37
|
37
|
|
|
|
|
160
|
return $self->$method(@_); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub dispatch_OPTIONS { |
41
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
42
|
1
|
|
|
|
|
3
|
my ($env) = @_; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
2
|
$env->{'sockjs.cacheable'} = 1; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
4
|
return [ 204, [], [''] ]; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _return_error { |
50
|
7
|
|
|
7
|
|
309
|
my $self = shift; |
51
|
7
|
|
|
|
|
16
|
my ( $error, %params ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return [ |
54
|
|
|
|
|
|
|
$params{status} || 500, |
55
|
|
|
|
|
|
|
[ |
56
|
|
|
|
|
|
|
'Content-Type' => 'text/plain; charset=UTF-8', |
57
|
|
|
|
|
|
|
'Content-Length' => length($error), |
58
|
7
|
50
|
100
|
|
|
80
|
$params{headers} ? @{ $params{headers} } : () |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
], |
60
|
|
|
|
|
|
|
[$error] |
61
|
|
|
|
|
|
|
]; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |