… | |
… | |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use AnyEvent::HTTP; |
7 | use AnyEvent::HTTP; |
8 | |
8 | |
9 | http_get "http://www.nethype.de/", sub { print $_[1] }; |
9 | http_get "http://www.nethype.de/", sub { |
|
|
10 | my ($body, $hdr) = @_; |
|
|
11 | print "$hdr->{URL} Status: $hdr->{Status}\n"; |
|
|
12 | print $body; |
|
|
13 | }; |
10 | |
14 | |
11 | # ... do something else here |
15 | # ... do something else here |
12 | |
16 | |
13 | =head1 DESCRIPTION |
17 | =head1 DESCRIPTION |
14 | |
18 | |
… | |
… | |
46 | use AnyEvent::Util (); |
50 | use AnyEvent::Util (); |
47 | use AnyEvent::Handle (); |
51 | use AnyEvent::Handle (); |
48 | |
52 | |
49 | use base Exporter::; |
53 | use base Exporter::; |
50 | |
54 | |
51 | our $VERSION = 2.24; |
55 | our $VERSION = 2.25; |
52 | |
56 | |
53 | our @EXPORT = qw(http_get http_post http_head http_request); |
57 | our @EXPORT = qw(http_get http_post http_head http_request); |
54 | |
58 | |
55 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
59 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
56 | our $MAX_RECURSE = 10; |
60 | our $MAX_RECURSE = 10; |
… | |
… | |
716 | } |
720 | } |
717 | |
721 | |
718 | our %IDEMPOTENT = ( |
722 | our %IDEMPOTENT = ( |
719 | DELETE => 1, |
723 | DELETE => 1, |
720 | GET => 1, |
724 | GET => 1, |
|
|
725 | QUERY => 1, |
721 | HEAD => 1, |
726 | HEAD => 1, |
722 | OPTIONS => 1, |
727 | OPTIONS => 1, |
723 | PUT => 1, |
728 | PUT => 1, |
724 | TRACE => 1, |
729 | TRACE => 1, |
725 | |
730 | |
… | |
… | |
737 | MKCOL => 1, |
742 | MKCOL => 1, |
738 | MKREDIRECTREF => 1, |
743 | MKREDIRECTREF => 1, |
739 | MKWORKSPACE => 1, |
744 | MKWORKSPACE => 1, |
740 | MOVE => 1, |
745 | MOVE => 1, |
741 | ORDERPATCH => 1, |
746 | ORDERPATCH => 1, |
|
|
747 | PRI => 1, |
742 | PROPFIND => 1, |
748 | PROPFIND => 1, |
743 | PROPPATCH => 1, |
749 | PROPPATCH => 1, |
744 | REBIND => 1, |
750 | REBIND => 1, |
745 | REPORT => 1, |
751 | REPORT => 1, |
746 | SEARCH => 1, |
752 | SEARCH => 1, |
… | |
… | |
1238 | # $state{handle}->destroyed |
1244 | # $state{handle}->destroyed |
1239 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (1), please report.";#d# |
1245 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (1), please report.";#d# |
1240 | $prepare_handle->(); |
1246 | $prepare_handle->(); |
1241 | # $state{handle}->destroyed |
1247 | # $state{handle}->destroyed |
1242 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (2), please report.";#d# |
1248 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (2), please report.";#d# |
|
|
1249 | $rpath = $upath; |
1243 | $handle_actual_request->(); |
1250 | $handle_actual_request->(); |
1244 | |
1251 | |
1245 | } else { |
1252 | } else { |
1246 | my $tcp_connect = $arg{tcp_connect} |
1253 | my $tcp_connect = $arg{tcp_connect} |
1247 | || do { require AnyEvent::Socket; \&AnyEvent::Socket::tcp_connect }; |
1254 | || do { require AnyEvent::Socket; \&AnyEvent::Socket::tcp_connect }; |