48
|
0 |
2 |
0 |
$self->{'ae_handle'} ||= do {
my @tls_opts;
if ($self->{'tls_verify_yn'}) {
push @tls_opts, ("verify", 1, "verify_peername", "https");
};
my $tls = "AnyEvent::TLS"->new(@tls_opts);
&Net::SSLeay::CTX_set_alpn_protos(scalar $tls->ctx, scalar $self->_ALPN_PROTOS);
my $weak_self = $self;
&Scalar::Util::weaken($weak_self);
my $read_chunk;
"AnyEvent::Handle"->new("connect", [$host, $port], "tls", "connect", "tls_ctx", $tls, "on_error", sub {
my($handle, $fatal, $msg) = @_;
$weak_self->_on_stream_error($msg);
$handle->destroy;
}
, "on_eof", sub {
$weak_self->_on_stream_close if $weak_self;
(shift())->destroy;
}
, "on_read", sub {
$read_chunk = $_[0]->rbuf;
$_[0]->rbuf = "";
$h2->feed($read_chunk);
}
)
} |