line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SockJS::Transport::Base; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
65834
|
use strict; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
223
|
|
4
|
9
|
|
|
9
|
|
37
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
261
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
47
|
use List::Util qw(any); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
4029
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
39
|
|
|
39
|
0
|
9421
|
my $class = shift; |
10
|
39
|
|
|
|
|
87
|
my (%params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
39
|
|
|
|
|
68
|
my $self = {}; |
13
|
39
|
|
|
|
|
87
|
bless $self, $class; |
14
|
|
|
|
|
|
|
|
15
|
39
|
|
100
|
|
|
226
|
$self->{name} = $params{name} || ''; |
16
|
39
|
|
|
|
|
87
|
$self->{allowed_methods} = ['OPTIONS']; |
17
|
|
|
|
|
|
|
|
18
|
39
|
|
|
|
|
142
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
0
|
25
|
sub name { shift->{name} } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub dispatch { |
24
|
38
|
|
|
38
|
0
|
1772
|
my $self = shift; |
25
|
38
|
|
|
|
|
77
|
my ($env) = @_; |
26
|
|
|
|
|
|
|
|
27
|
38
|
|
|
|
|
93
|
$env->{'sockjs.cacheable'} = $self->{cacheable}; |
28
|
38
|
|
|
|
|
70
|
$env->{'sockjs.allowed_methods'} = $self->{allowed_methods}; |
29
|
|
|
|
|
|
|
|
30
|
38
|
|
|
|
|
62
|
my $method = $env->{REQUEST_METHOD}; |
31
|
38
|
100
|
|
75
|
|
120
|
if ( !any { $_ eq $method } @{ $self->{allowed_methods} } ) { |
|
75
|
|
|
|
|
187
|
|
|
38
|
|
|
|
|
170
|
|
32
|
1
|
|
|
|
|
2
|
return [ 405, [ 'Allow' => join ', ', @{ $self->{allowed_methods} } ], |
|
1
|
|
|
|
|
6
|
|
33
|
|
|
|
|
|
|
[''] ]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
37
|
|
|
|
|
145
|
$method = "dispatch_$method"; |
37
|
37
|
|
|
|
|
151
|
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
|
|
335
|
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
|
|
|
75
|
$params{headers} ? @{ $params{headers} } : () |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
], |
60
|
|
|
|
|
|
|
[$error] |
61
|
|
|
|
|
|
|
]; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |