--- AnyEvent-HTTP/HTTP.pm 2009/07/06 03:03:12 1.43 +++ AnyEvent-HTTP/HTTP.pm 2009/07/07 00:15:32 1.44 @@ -43,14 +43,14 @@ use Errno (); -use AnyEvent 4.452 (); +use AnyEvent 4.8 (); use AnyEvent::Util (); use AnyEvent::Socket (); use AnyEvent::Handle (); use base Exporter::; -our $VERSION = '1.12'; +our $VERSION = '1.4'; our @EXPORT = qw(http_get http_post http_head http_request); @@ -421,7 +421,12 @@ $state{connect_guard} = AnyEvent::Socket::tcp_connect $rhost, $rport, sub { $state{fh} = shift - or return (%state = (), $cb->(undef, { Status => 599, Reason => "$!", URL => $url })); + or do { + my $err = "$!"; + %state = (); + return $cb->(undef, { Status => 599, Reason => $err, URL => $url }); + }; + pop; # free memory, save a tree return unless delete $state{connect_guard};