--- AnyEvent-HTTP/HTTP.pm 2008/10/29 14:51:07 1.34 +++ AnyEvent-HTTP/HTTP.pm 2008/11/21 08:20:14 1.37 @@ -50,7 +50,7 @@ use base Exporter::; -our $VERSION = '1.05'; +our $VERSION = '1.11'; our @EXPORT = qw(http_get http_post http_head http_request); @@ -428,10 +428,7 @@ for values %hdr; my $finish = sub { - # TODO: use destroy method, when/if available - #$state{handle}->destroy; - $state{handle}->on_eof (undef); - $state{handle}->on_error (undef); + $state{handle}->destroy; %state = (); # set-cookie processing @@ -530,7 +527,9 @@ # too bad, need to read until we get an error or EOF, # no way to detect winged data. $_[0]->on_error (sub { - $finish->($_[0]{rbuf}, \%hdr); + # delete ought to be more efficient, as we would have to make + # a copy otherwise as $_[0] gets destroyed. + $finish->(delete $_[0]{rbuf}, \%hdr); }); $_[0]->on_eof (undef); $_[0]->on_read (sub { }); @@ -644,6 +643,9 @@ Marc Lehmann http://home.schmorp.de/ +With many thanks to Дмитрий Шалашов, who provided countless +testcases and bugreports. + =cut 1