line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SockJS::Transport::HtmlFile; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
431
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'SockJS::Transport::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
432
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
5
|
|
|
5
|
0
|
12347
|
my $self = shift->SUPER::new(@_); |
10
|
5
|
|
|
|
|
10
|
my (%params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
50
|
|
|
16
|
$self->{response_limit} = $params{response_limit} || 128 * 1024; |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
|
|
26
|
push @{$self->{allowed_methods}}, 'GET'; |
|
5
|
|
|
|
|
13
|
|
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
|
|
13
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub dispatch_GET { |
20
|
5
|
|
|
5
|
0
|
10
|
my $self = shift; |
21
|
5
|
|
|
|
|
10
|
my ($env, $conn) = @_; |
22
|
|
|
|
|
|
|
|
23
|
5
|
|
|
|
|
29
|
my ($callback) = $env->{QUERY_STRING} =~ m/(?:^|&|;)c=([^&;]+)/; |
24
|
5
|
100
|
|
|
|
13
|
if (!$callback) { |
25
|
1
|
|
|
|
|
7
|
return [500, [], ['"callback" parameter required']]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
9
|
$callback =~ s/%(..)/chr(hex($1))/eg; |
|
0
|
|
|
|
|
0
|
|
29
|
4
|
100
|
|
|
|
15
|
if ($callback !~ m/^[a-zA-Z0-9-_\.]+$/) { |
30
|
1
|
|
|
|
|
5
|
return [500, [], ['invalid "callback" parameter']]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
6
|
my $limit = $self->{response_limit}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return sub { |
36
|
3
|
|
|
3
|
|
418
|
my $respond = shift; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
12
|
my $writer = $respond->( |
39
|
|
|
|
|
|
|
[ |
40
|
|
|
|
|
|
|
200, |
41
|
|
|
|
|
|
|
[ |
42
|
|
|
|
|
|
|
'Content-Type' => 'text/html; charset=UTF-8', |
43
|
|
|
|
|
|
|
'Connection' => 'close', |
44
|
|
|
|
|
|
|
] |
45
|
|
|
|
|
|
|
] |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
3
|
100
|
66
|
|
|
17
|
if ($conn->is_connected && !$conn->is_reconnecting) { |
49
|
1
|
|
|
|
|
5
|
my $message = $self->_wrap_message( |
50
|
|
|
|
|
|
|
'c[2010,"Another connection still open"]' . "\n"); |
51
|
1
|
|
|
|
|
13
|
$writer->write($message); |
52
|
1
|
|
|
|
|
57
|
$writer->close; |
53
|
1
|
|
|
|
|
41
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$conn->write_cb( |
57
|
|
|
|
|
|
|
sub { |
58
|
2
|
|
|
|
|
3
|
my $conn = shift; |
59
|
2
|
|
|
|
|
5
|
my ($message) = @_; |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
3
|
$limit -= length($message) - 1; |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
5
|
$writer->write($self->_wrap_message($message)); |
64
|
|
|
|
|
|
|
|
65
|
2
|
50
|
|
|
|
109
|
if ($limit <= 0) { |
66
|
0
|
|
|
|
|
0
|
$writer->close; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
0
|
$conn->reconnecting; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
2
|
|
|
|
|
11
|
); |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
13
|
$conn->close_cb(sub { $writer->close }); |
|
0
|
|
|
|
|
0
|
|
74
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
25
|
$writer->write(<<"EOF" . (' ' x 1024)); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Don't panic! |
81
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
EOF |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
134
|
$conn->write('o'); |
91
|
|
|
|
|
|
|
|
92
|
2
|
50
|
|
|
|
5
|
if ($conn->is_closed) { |
|
|
50
|
|
|
|
|
|
93
|
0
|
|
|
|
|
0
|
$conn->connected; |
94
|
0
|
|
|
|
|
0
|
$conn->close; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
elsif ($conn->is_connected) { |
97
|
0
|
|
|
|
|
0
|
$conn->reconnected; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
else { |
100
|
2
|
|
|
|
|
4
|
$conn->connected; |
101
|
|
|
|
|
|
|
} |
102
|
3
|
|
|
|
|
33
|
}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _wrap_message { |
106
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
107
|
3
|
|
|
|
|
5
|
my ($message) = @_; |
108
|
|
|
|
|
|
|
|
109
|
3
|
|
|
|
|
18
|
$message =~ s/(['""\\\/\n\r\t]{1})/\\$1/smg; |
110
|
3
|
|
|
|
|
25
|
return qq{\r\n}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |