Skip to content

Instantly share code, notes, and snippets.

@tokuhirom
Created August 26, 2008 08:12
Show Gist options
  • Save tokuhirom/7232 to your computer and use it in GitHub Desktop.
Save tokuhirom/7232 to your computer and use it in GitHub Desktop.
package Net::HTTPS::BlockingHack;
use strict;
use warnings;
use Net::HTTPS;
sub hack {
my ($class, $callback) = @_;
no strict 'refs';
if ($Net::HTTPS::SSL_SOCKET_CLASS eq 'Net::SSL') {
local *Net::HTTPS::blocking = *Net::SSL::blocking;
$callback->();
} elsif ($Net::HTTPS::SSL_SOCKET_CLASS eq 'IO::Socket::SSL') {
local *Net::HTTPS::blocking = *IO::Socket::SSL::blocking;
$callback->();
}
}
1;
__END__
=head1 SYNOPSIS
my $sock = Net::HTTPS::BlockingHack->hack(sub {
Net::HTTPS->new(
PeerAddr => 'www.yahoo.co.jp',
PeerPort => 443,
Proto => 'tcp',
Timeout => $timeout,
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment