Created
August 26, 2008 08:12
-
-
Save tokuhirom/7232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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