| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package POE::Component::WWW::WebDevout::BrowserSupportInfo; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
392729
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.001004'; # VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
72
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use POE qw(Wheel::Run Filter::Reference Filter::Line); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
10
|
1
|
|
|
1
|
|
610
|
use WWW::WebDevout::BrowserSupportInfo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10774
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub spawn { |
|
13
|
1
|
|
|
1
|
1
|
350
|
my $package = shift; |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
50
|
|
|
|
6
|
croak "Must have even number of arguments to spawn()" |
|
16
|
|
|
|
|
|
|
if @_ & 1; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
7
|
my %params = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
11
|
$params{ lc $_ } = delete $params{ $_ } for keys %params; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
50
|
|
|
|
7
|
delete $params{options} |
|
23
|
|
|
|
|
|
|
unless ref $params{options} eq 'HASH'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
6
|
my $self = bless \%params, $package; |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
21
|
$self->{session_id} = POE::Session->create( |
|
28
|
|
|
|
|
|
|
object_states => [ |
|
29
|
|
|
|
|
|
|
$self => { |
|
30
|
|
|
|
|
|
|
fetch => '_fetch', |
|
31
|
|
|
|
|
|
|
shutdown => '_shutdown', |
|
32
|
|
|
|
|
|
|
}, |
|
33
|
|
|
|
|
|
|
$self => [ |
|
34
|
|
|
|
|
|
|
qw( |
|
35
|
|
|
|
|
|
|
_child_error |
|
36
|
|
|
|
|
|
|
_child_close |
|
37
|
|
|
|
|
|
|
_child_stderr |
|
38
|
|
|
|
|
|
|
_child_stdout |
|
39
|
|
|
|
|
|
|
_sig_chld |
|
40
|
|
|
|
|
|
|
_start |
|
41
|
|
|
|
|
|
|
) |
|
42
|
|
|
|
|
|
|
], |
|
43
|
|
|
|
|
|
|
], |
|
44
|
|
|
|
|
|
|
( exists $params{options} ? ( options => $params{options} ) : () ), |
|
45
|
|
|
|
|
|
|
)->ID; |
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
1331
|
return $self; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _start { |
|
51
|
1
|
|
|
1
|
|
422
|
my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; |
|
52
|
1
|
|
|
|
|
6
|
$self->{session_id} = $_[SESSION]->ID(); |
|
53
|
1
|
50
|
|
|
|
9
|
if ( $self->{alias} ) { |
|
54
|
0
|
|
|
|
|
0
|
$kernel->alias_set( $self->{alias} ); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
else { |
|
57
|
1
|
|
|
|
|
6
|
$kernel->refcount_increment( $self->{session_id} => __PACKAGE__ ); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->{wheel} = POE::Wheel::Run->new( |
|
61
|
0
|
|
0
|
0
|
|
0
|
Program => sub { _wheel( $self->{obj_args} || {} ); }, |
|
62
|
1
|
50
|
|
|
|
60
|
ErrorEvent => '_child_error', |
|
63
|
|
|
|
|
|
|
CloseEvent => '_child_close', |
|
64
|
|
|
|
|
|
|
StderrEvent => '_child_stderr', |
|
65
|
|
|
|
|
|
|
StdoutEvent => '_child_stdout', |
|
66
|
|
|
|
|
|
|
StdioFilter => POE::Filter::Reference->new, |
|
67
|
|
|
|
|
|
|
StderrFilter => POE::Filter::Line->new, |
|
68
|
|
|
|
|
|
|
( $^O eq 'MSWin32' ? ( CloseOnCall => 0 ) : ( CloseOnCall => 1 ) ), |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
50
|
|
|
|
18193
|
$kernel->call('shutdown') |
|
72
|
|
|
|
|
|
|
unless $self->{wheel}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
33
|
$kernel->sig_child( $self->{wheel}->PID, '_sig_chld' ); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _sig_chld { |
|
78
|
1
|
|
|
1
|
|
2635
|
$poe_kernel->sig_handled; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _child_close { |
|
82
|
0
|
|
|
0
|
|
0
|
my ( $kernel, $self, $wheel_id ) = @_[ KERNEL, OBJECT, ARG0 ]; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
0
|
warn "_child_close called (@_[ARG0..$#_])\n" |
|
85
|
|
|
|
|
|
|
if $self->{debug}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
delete $self->{wheel}; |
|
88
|
0
|
0
|
|
|
|
0
|
$kernel->yield('shutdown') |
|
89
|
|
|
|
|
|
|
unless $self->{shutdown}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
0
|
undef; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _child_error { |
|
95
|
1
|
|
|
1
|
|
4092
|
my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; |
|
96
|
1
|
50
|
|
|
|
323
|
warn "_child_error called (@_[ARG0..$#_])\n" |
|
97
|
|
|
|
|
|
|
if $self->{debug}; |
|
98
|
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
20
|
delete $self->{wheel}; |
|
100
|
1
|
50
|
|
|
|
734
|
$kernel->yield('shutdown') |
|
101
|
|
|
|
|
|
|
unless $self->{shutdown}; |
|
102
|
|
|
|
|
|
|
|
|
103
|
1
|
|
|
|
|
7
|
undef; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _child_stderr { |
|
107
|
0
|
|
|
0
|
|
0
|
my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; |
|
108
|
0
|
0
|
|
|
|
0
|
warn "_child_stderr: $_[ARG0]\n" |
|
109
|
|
|
|
|
|
|
if $self->{debug}; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
0
|
undef; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _child_stdout { |
|
115
|
1
|
|
|
1
|
|
2857328
|
my ( $kernel, $self, $input ) = @_[ KERNEL, OBJECT, ARG0 ]; |
|
116
|
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
7
|
my $session = delete $input->{sender}; |
|
118
|
1
|
|
|
|
|
4
|
my $event = delete $input->{event}; |
|
119
|
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
4
|
delete @$input{ qw(login pass ua_args) }; |
|
121
|
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
8
|
$kernel->post( $session, $event, $input ); |
|
123
|
1
|
|
|
|
|
159
|
$kernel->refcount_decrement( $session => __PACKAGE__ ); |
|
124
|
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
100
|
undef; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub shutdown { |
|
129
|
1
|
|
|
1
|
1
|
4186
|
my $self = shift; |
|
130
|
1
|
|
|
|
|
9
|
$poe_kernel->post( $self->{session_id} => 'shutdown' ); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub _shutdown { |
|
134
|
1
|
|
|
1
|
|
1016
|
my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; |
|
135
|
1
|
|
|
|
|
21
|
$kernel->alarm_remove_all; |
|
136
|
1
|
|
|
|
|
121
|
$kernel->alias_remove( $_ ) for $kernel->alias_list; |
|
137
|
1
|
50
|
|
|
|
61
|
$kernel->refcount_decrement( $self->{session_id} => __PACKAGE__ ) |
|
138
|
|
|
|
|
|
|
unless $self->{alias}; |
|
139
|
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
43
|
$self->{shutdown} = 1; |
|
141
|
1
|
50
|
|
|
|
13
|
$self->{wheel}->shutdown_stdin |
|
142
|
|
|
|
|
|
|
if $self->{wheel}; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub session_id { |
|
146
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->{session_id}; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub fetch { |
|
150
|
1
|
|
|
1
|
1
|
4324
|
my $self = shift; |
|
151
|
1
|
|
|
|
|
38
|
$poe_kernel->post( $self->{session_id} => 'fetch' => @_ ); |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub _fetch { |
|
155
|
1
|
|
|
1
|
|
2818
|
my ( $kernel, $self, $args )= @_[ KERNEL, OBJECT, ARG0 ]; |
|
156
|
|
|
|
|
|
|
|
|
157
|
1
|
|
|
|
|
6
|
my $sender = $_[SENDER]->ID; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
return |
|
160
|
1
|
50
|
|
|
|
12
|
if $self->{shutdown}; |
|
161
|
|
|
|
|
|
|
|
|
162
|
3
|
|
|
|
|
48
|
$args->{ lc $_ } = delete $args->{ $_ } |
|
163
|
1
|
|
|
|
|
20
|
for grep { !/^_/ } keys %{ $args }; |
|
|
1
|
|
|
|
|
5
|
|
|
164
|
|
|
|
|
|
|
|
|
165
|
1
|
50
|
|
|
|
6
|
unless ( defined $args->{what} ) { |
|
166
|
0
|
|
|
|
|
0
|
carp "Missing the term to look up (`what` argument)"; |
|
167
|
0
|
|
|
|
|
0
|
return; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
1
|
50
|
|
|
|
132
|
unless ( defined $args->{event} ) { |
|
171
|
0
|
|
|
|
|
0
|
carp "Missing the name of the event for results (`event` argument)"; |
|
172
|
0
|
|
|
|
|
0
|
return; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
1
|
50
|
|
|
|
7
|
if ( $args->{session} ) { |
|
176
|
0
|
0
|
|
|
|
0
|
if ( my $ref = $kernel->alias_resolve( $args->{session} ) ) { |
|
177
|
0
|
|
|
|
|
0
|
$args->{sender} = $ref->ID; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
else { |
|
180
|
0
|
|
|
|
|
0
|
carp "Could not resolve `session` parameter to a " |
|
181
|
|
|
|
|
|
|
. "valid POE session. Aborting..."; |
|
182
|
0
|
|
|
|
|
0
|
return; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
else { |
|
186
|
1
|
|
|
|
|
12
|
$args->{sender} = $sender; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
1
|
|
|
|
|
10
|
$kernel->refcount_increment( $args->{sender} => __PACKAGE__ ); |
|
190
|
1
|
|
|
|
|
75
|
$self->{wheel}->put( $args ); |
|
191
|
|
|
|
|
|
|
|
|
192
|
1
|
|
|
|
|
697
|
undef; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub _wheel { |
|
196
|
0
|
|
|
0
|
|
|
my $poco_args = shift; |
|
197
|
0
|
0
|
|
|
|
|
if ( $^O eq 'MSWin32' ) { |
|
198
|
0
|
|
|
|
|
|
binmode STDIN; |
|
199
|
0
|
|
|
|
|
|
binmode STDOUT; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
my $wd = WWW::WebDevout::BrowserSupportInfo->new( %$poco_args ); |
|
203
|
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
my $raw; |
|
205
|
0
|
|
|
|
|
|
my $size = 4096; |
|
206
|
0
|
|
|
|
|
|
my $filter = POE::Filter::Reference->new; |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
while ( sysread STDIN, $raw, $size ) { |
|
209
|
0
|
|
|
|
|
|
my $requests = $filter->get( [ $raw ] ); |
|
210
|
0
|
|
|
|
|
|
foreach my $req_ref ( @$requests ) { |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
_retrieve_browser_info( $wd, $req_ref ); |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
my $response = $filter->put( [ $req_ref ] ); |
|
215
|
0
|
|
|
|
|
|
print STDOUT @$response; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub _retrieve_browser_info { |
|
221
|
0
|
|
|
0
|
|
|
my ( $wd, $req_ref ) = @_; |
|
222
|
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
my $results = $wd->fetch( $req_ref->{what} ); |
|
224
|
0
|
0
|
|
|
|
|
if ( defined $results ) { |
|
225
|
0
|
|
|
|
|
|
@$req_ref{ qw( uri_info results ) } |
|
226
|
|
|
|
|
|
|
= ( $wd->uri_info, $wd->browser_results ); |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
else { |
|
229
|
0
|
|
|
|
|
|
$req_ref->{error} = $wd->error; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
0
|
|
|
|
|
|
undef; |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
1; |
|
235
|
|
|
|
|
|
|
__END__ |