ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-HTTP/HTTP.pm
(Generate patch)

Comparing AnyEvent-HTTP/HTTP.pm (file contents):
Revision 1.127 by root, Sun Aug 28 09:31:29 2016 UTC vs.
Revision 1.128 by root, Sat Nov 26 03:45:33 2016 UTC

46use AnyEvent::Util (); 46use AnyEvent::Util ();
47use AnyEvent::Handle (); 47use AnyEvent::Handle ();
48 48
49use base Exporter::; 49use base Exporter::;
50 50
51our $VERSION = 2.23; 51our $VERSION = 2.24;
52 52
53our @EXPORT = qw(http_get http_post http_head http_request); 53our @EXPORT = qw(http_get http_post http_head http_request);
54 54
55our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; 55our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)";
56our $MAX_RECURSE = 10; 56our $MAX_RECURSE = 10;
1031 $finish->(delete $state{handle}); 1031 $finish->(delete $state{handle});
1032 1032
1033 } elsif ($chunked) { 1033 } elsif ($chunked) {
1034 my $cl = 0; 1034 my $cl = 0;
1035 my $body = ""; 1035 my $body = "";
1036 my $on_body = $arg{on_body} || sub { $body .= shift; 1 }; 1036 my $on_body = (!$redirect && $arg{on_body}) || sub { $body .= shift; 1 };
1037 1037
1038 $state{read_chunk} = sub { 1038 $state{read_chunk} = sub {
1039 $_[1] =~ /^([0-9a-fA-F]+)/ 1039 $_[1] =~ /^([0-9a-fA-F]+)/
1040 or return $finish->(undef, $ae_error => "Garbled chunked transfer encoding"); 1040 or return $finish->(undef, $ae_error => "Garbled chunked transfer encoding");
1041 1041
1074 } 1074 }
1075 }; 1075 };
1076 1076
1077 $_[0]->push_read (line => $state{read_chunk}); 1077 $_[0]->push_read (line => $state{read_chunk});
1078 1078
1079 } elsif ($arg{on_body}) { 1079 } elsif (!$redirect && $arg{on_body}) {
1080 if (defined $len) { 1080 if (defined $len) {
1081 $_[0]->on_read (sub { 1081 $_[0]->on_read (sub {
1082 $len -= length $_[0]{rbuf}; 1082 $len -= length $_[0]{rbuf};
1083 1083
1084 $arg{on_body}(delete $_[0]{rbuf}, \%hdr) 1084 $arg{on_body}(delete $_[0]{rbuf}, \%hdr)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines