… | |
… | |
48 | use AnyEvent::Socket (); |
48 | use AnyEvent::Socket (); |
49 | use AnyEvent::Handle (); |
49 | use AnyEvent::Handle (); |
50 | |
50 | |
51 | use base Exporter::; |
51 | use base Exporter::; |
52 | |
52 | |
53 | our $VERSION = '1.1'; |
53 | our $VERSION = '1.11'; |
54 | |
54 | |
55 | our @EXPORT = qw(http_get http_post http_head http_request); |
55 | our @EXPORT = qw(http_get http_post http_head http_request); |
56 | |
56 | |
57 | our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
57 | our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
58 | our $MAX_RECURSE = 10; |
58 | our $MAX_RECURSE = 10; |
… | |
… | |
525 | }); |
525 | }); |
526 | } else { |
526 | } else { |
527 | # too bad, need to read until we get an error or EOF, |
527 | # too bad, need to read until we get an error or EOF, |
528 | # no way to detect winged data. |
528 | # no way to detect winged data. |
529 | $_[0]->on_error (sub { |
529 | $_[0]->on_error (sub { |
|
|
530 | # delete ought to be more efficient, as we would have to make |
|
|
531 | # a copy otherwise as $_[0] gets destroyed. |
530 | $finish->($_[0]{rbuf}, \%hdr); |
532 | $finish->(delete $_[0]{rbuf}, \%hdr); |
531 | }); |
533 | }); |
532 | $_[0]->on_eof (undef); |
534 | $_[0]->on_eof (undef); |
533 | $_[0]->on_read (sub { }); |
535 | $_[0]->on_read (sub { }); |
534 | } |
536 | } |
535 | } |
537 | } |