line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SockJS::Transport::XHRStreaming; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
377
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'SockJS::Transport::Base'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
357
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
0
|
5524
|
my $self = shift->SUPER::new(@_); |
10
|
3
|
|
|
|
|
6
|
my (%params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
50
|
|
|
12
|
$self->{response_limit} = $params{response_limit} || 128 * 1024; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
21
|
push @{$self->{allowed_methods}}, 'POST'; |
|
3
|
|
|
|
|
51
|
|
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
|
|
9
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub dispatch_POST { |
20
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
21
|
3
|
|
|
|
|
5
|
my ($env, $conn) = @_; |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
6
|
my $limit = $self->{response_limit}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return sub { |
26
|
3
|
|
|
3
|
|
355
|
my $respond = shift; |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
9
|
my $writer = $respond->( |
29
|
|
|
|
|
|
|
[ |
30
|
|
|
|
|
|
|
200, |
31
|
|
|
|
|
|
|
[ 'Content-Type' => 'application/javascript; charset=UTF-8' ] |
32
|
|
|
|
|
|
|
] |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
48
|
$writer->write(('h' x 2048) . "\n"); |
36
|
|
|
|
|
|
|
|
37
|
3
|
100
|
66
|
|
|
147
|
if ($conn->is_connected && !$conn->is_reconnecting) { |
38
|
1
|
|
|
|
|
5
|
$writer->write('c[2010,"Another connection still open"]' . "\n"); |
39
|
1
|
|
|
|
|
34
|
$writer->write(''); |
40
|
1
|
|
|
|
|
33
|
$writer->close; |
41
|
1
|
|
|
|
|
30
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$conn->write_cb( |
45
|
|
|
|
|
|
|
sub { |
46
|
2
|
|
|
|
|
4
|
my $conn = shift; |
47
|
2
|
|
|
|
|
4
|
my ($message) = @_; |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
11
|
$writer->write($message . "\n"); |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
78
|
$limit -= length($message) - 1; |
52
|
|
|
|
|
|
|
|
53
|
2
|
50
|
|
|
|
7
|
if ($limit <= 0) { |
54
|
0
|
|
|
|
|
0
|
$writer->write(''); |
55
|
0
|
|
|
|
|
0
|
$writer->close; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
$conn->reconnecting; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
2
|
|
|
|
|
28
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$conn->close_cb( |
63
|
|
|
|
|
|
|
sub { |
64
|
1
|
|
|
|
|
2
|
my $conn = shift; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
5
|
$writer->write(''); |
67
|
1
|
|
|
|
|
34
|
$writer->close; |
68
|
|
|
|
|
|
|
} |
69
|
2
|
|
|
|
|
9
|
); |
70
|
|
|
|
|
|
|
|
71
|
2
|
100
|
|
|
|
12
|
if ($conn->is_closed) { |
|
|
50
|
|
|
|
|
|
72
|
1
|
|
|
|
|
10
|
$conn->connected; |
73
|
1
|
|
|
|
|
3
|
$conn->close; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif ($conn->is_connected) { |
76
|
0
|
|
|
|
|
0
|
$conn->reconnected; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else { |
79
|
1
|
|
|
|
|
1
|
$limit -= 4; |
80
|
1
|
|
|
|
|
4
|
$conn->write('o'); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
2
|
$conn->connected; |
83
|
|
|
|
|
|
|
} |
84
|
3
|
|
|
|
|
14
|
}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |