I've done some hacking and looks like I've found a way to fool the HTTP::Async into using IO::Socket::SSL. Below you'll find my module MyHacks.pm and an example how to use it.

package MyHacks; use Errno; use Net::HTTP::Methods; use IO::Socket::SSL; my $old_read_entity = \&Net::HTTP::Methods::read_entity_body; my $old_read_response = \&Net::HTTP::Methods::read_response_headers; *Net::HTTP::Methods::my_readline = \&my_readline; *Net::HTTP::Methods::my_read = \&my_read; *Net::HTTP::Methods::read_entity_body = \&my_read_entity; *Net::HTTP::Methods::read_response_headers = \&my_read_response; sub my_read_response { my @vals = eval {$old_read_response->(@_);}; if($@) { return if($@ =~ /^Non-blocking/); die $@; } return @vals; } sub my_read_entity { my $val = eval {$old_read_entity->(@_);}; if($@) { return if($@ =~ /^Non-blocking/); die $@; } return $val; } sub my_read { die if @_ > 3; my $self = shift; my $len = $_[1]; for (${*$self}{'http_buf'}) { if (length) { $_[0] = substr($_, 0, $len, ""); return length($_[0]); } else { my $n = $self->sysread($_[0], $len); die "Non-blocking\n" if (!defined $n && $!{EAGAIN}); return $n; } } } sub my_readline { my $self = shift; my $what = shift; for (${*$self}{'http_buf'}) { my $max_line_length = ${*$self}{'http_max_line_length'}; my $pos; while (1) { # find line ending $pos = index($_, "\012"); last if $pos >= 0; die "$what line too long (limit is $max_line_length)" if $max_line_length && length($_) > $max_line_length; # need to read more data to find a line ending READ: { my $n = $self->sysread($_, 1024, length); unless (defined $n) { redo READ if $!{EINTR}; die "Non-blocking\n" if ($!{EAGAIN}); # if we have already accumulated some data let's a +t least # return that as a line die "$what read failed: $!" unless length; } unless ($n) { return undef unless length; return substr($_, 0, length, ""); } } } die "$what line too long ($pos; limit is $max_line_length)" if $max_line_length && $pos > $max_line_length; my $line = substr($_, 0, $pos+1, ""); $line =~ s/(\015?\012)\z// || die "Assert"; return wantarray ? ($line, $1) : $line; } } package Net::HTTP::NB; use vars qw(@ISA); @ISA = qw(Net::HTTP); sub new { my $class = shift; my %args = @_; return Net::HTTPS->new(@_) if($args{PeerPort} == 443); return $class->SUPER::new(@_); } package Net::HTTPS; use vars qw(@ISA); @ISA = qw(IO::Socket::SSL Net::HTTP::Methods); sub configure { my($self, $cnf) = @_; $self->http_configure($cnf); } sub http_connect { my($self, $cnf) = @_; $self->SUPER::configure($cnf); } 1;

And the example

#!/usr/bin/perl # important, the MyHacks must be the first! use MyHacks; use HTTP::Async; use HTTP::Request; my $async = HTTP::Async->new; $async->add( HTTP::Request->new( GET => 'https://mail.google.com/') ); while( my $resp = $async->wait_for_next_response ) { print "Got: ", $resp->code, " ", $resp->message, "\n"; }

As usually. Try at your own risk. No warranties.


In reply to Re^2: Asyncron Https-Requests with HTTP::Async by andal
in thread Asyncron Https-Requests with HTTP::Async by atmosfearpete

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.