--- AnyEvent-HTTP/HTTP.pm 2008/10/29 14:51:07 1.34 +++ AnyEvent-HTTP/HTTP.pm 2009/03/07 03:43:09 1.38 @@ -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); @@ -322,10 +322,10 @@ my ($rhost, $rport, $rscheme, $rpath); # request host, port, path if ($proxy) { - ($rhost, $rport, $rscheme, $rpath) = (@$proxy, $url); + ($rpath, $rhost, $rport, $rscheme) = ($url, @$proxy); # don't support https requests over https-proxy transport, - # can't be done with tls as spec'ed. + # can't be done with tls as spec'ed, unless you double-encrypt. $rscheme = "http" if $uscheme eq "https" && $rscheme eq "https"; } else { ($rhost, $rport, $rscheme, $rpath) = ($uhost, $uport, $uscheme, $upath); @@ -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