… | |
… | |
14 | |
14 | |
15 | AnyEvent::Handle - non-blocking I/O on file handles via AnyEvent |
15 | AnyEvent::Handle - non-blocking I/O on file handles via AnyEvent |
16 | |
16 | |
17 | =cut |
17 | =cut |
18 | |
18 | |
19 | our $VERSION = 4.45; |
19 | our $VERSION = 4.452; |
20 | |
20 | |
21 | =head1 SYNOPSIS |
21 | =head1 SYNOPSIS |
22 | |
22 | |
23 | use AnyEvent; |
23 | use AnyEvent; |
24 | use AnyEvent::Handle; |
24 | use AnyEvent::Handle; |
… | |
… | |
245 | yet. This data will be lost. Calling the C<stoptls> method in time might |
245 | yet. This data will be lost. Calling the C<stoptls> method in time might |
246 | help. |
246 | help. |
247 | |
247 | |
248 | =item peername => $string |
248 | =item peername => $string |
249 | |
249 | |
250 | A string used to identify the remote site - usually the DNS hostname used |
250 | A string used to identify the remote site - usually the DNS hostname |
251 | to create the connection. |
251 | (I<not> IDN!) used to create the connection, rarely the IP address. |
252 | |
252 | |
253 | Apart from being useful in error messages, this string is also used in TLS |
253 | Apart from being useful in error messages, this string is also used in TLS |
254 | common name verification (see C<verify_cn> in L<AnyEvent::TLS>). |
254 | common name verification (see C<verify_cn> in L<AnyEvent::TLS>). |
255 | |
255 | |
256 | =item tls => "accept" | "connect" | Net::SSLeay::SSL object |
256 | =item tls => "accept" | "connect" | Net::SSLeay::SSL object |
… | |
… | |
1216 | =cut |
1216 | =cut |
1217 | |
1217 | |
1218 | register_read_type json => sub { |
1218 | register_read_type json => sub { |
1219 | my ($self, $cb) = @_; |
1219 | my ($self, $cb) = @_; |
1220 | |
1220 | |
1221 | require JSON; |
1221 | my $json = $self->{json} ||= |
|
|
1222 | eval { require JSON::XS; JSON::XS->new->utf8 } |
|
|
1223 | || do { require JSON; JSON->new->utf8 }; |
1222 | |
1224 | |
1223 | my $data; |
1225 | my $data; |
1224 | my $rbuf = \$self->{rbuf}; |
1226 | my $rbuf = \$self->{rbuf}; |
1225 | |
|
|
1226 | my $json = $self->{json} ||= JSON->new->utf8; |
|
|
1227 | |
1227 | |
1228 | sub { |
1228 | sub { |
1229 | my $ref = eval { $json->incr_parse ($self->{rbuf}) }; |
1229 | my $ref = eval { $json->incr_parse ($self->{rbuf}) }; |
1230 | |
1230 | |
1231 | if ($ref) { |
1231 | if ($ref) { |