… | |
… | |
46 | use AnyEvent::Util (); |
46 | use AnyEvent::Util (); |
47 | use AnyEvent::Handle (); |
47 | use AnyEvent::Handle (); |
48 | |
48 | |
49 | use base Exporter::; |
49 | use base Exporter::; |
50 | |
50 | |
51 | our $VERSION = 2.24; |
51 | our $VERSION = 2.25; |
52 | |
52 | |
53 | our @EXPORT = qw(http_get http_post http_head http_request); |
53 | our @EXPORT = qw(http_get http_post http_head http_request); |
54 | |
54 | |
55 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
55 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
56 | our $MAX_RECURSE = 10; |
56 | our $MAX_RECURSE = 10; |
… | |
… | |
200 | Currently, if your proxy requires authorization, you have to specify an |
200 | Currently, if your proxy requires authorization, you have to specify an |
201 | appropriate "Proxy-Authorization" header in every request. |
201 | appropriate "Proxy-Authorization" header in every request. |
202 | |
202 | |
203 | Note that this module will prefer an existing persistent connection, |
203 | Note that this module will prefer an existing persistent connection, |
204 | even if that connection was made using another proxy. If you need to |
204 | even if that connection was made using another proxy. If you need to |
205 | ensure that a new conneciton is made in this case, you can either force |
205 | ensure that a new connection is made in this case, you can either force |
206 | C<persistent> to false or e.g. use the proxy address in your C<sessionid>. |
206 | C<persistent> to false or e.g. use the proxy address in your C<sessionid>. |
207 | |
207 | |
208 | =item body => $string |
208 | =item body => $string |
209 | |
209 | |
210 | The request body, usually empty. Will be sent as-is (future versions of |
210 | The request body, usually empty. Will be sent as-is (future versions of |
… | |
… | |
272 | to do this, but you can provide your own C<tcp_connect> function - |
272 | to do this, but you can provide your own C<tcp_connect> function - |
273 | obviously, it has to follow the same calling conventions, except that it |
273 | obviously, it has to follow the same calling conventions, except that it |
274 | may always return a connection guard object. |
274 | may always return a connection guard object. |
275 | |
275 | |
276 | The connections made by this hook will be treated as equivalent to |
276 | The connections made by this hook will be treated as equivalent to |
277 | connecitons made the built-in way, specifically, they will be put into |
277 | connections made the built-in way, specifically, they will be put into |
278 | and taken from the persistent conneciton cache. If your C<$tcp_connect> |
278 | and taken from the persistent connection cache. If your C<$tcp_connect> |
279 | function is incompatible with this kind of re-use, consider switching off |
279 | function is incompatible with this kind of re-use, consider switching off |
280 | C<persistent> connections and/or providing a C<sessionid> identifier. |
280 | C<persistent> connections and/or providing a C<sessionid> identifier. |
281 | |
281 | |
282 | There are probably lots of weird uses for this function, starting from |
282 | There are probably lots of weird uses for this function, starting from |
283 | tracing the hosts C<http_request> actually tries to connect, to (inexact |
283 | tracing the hosts C<http_request> actually tries to connect, to (inexact |
… | |
… | |
716 | } |
716 | } |
717 | |
717 | |
718 | our %IDEMPOTENT = ( |
718 | our %IDEMPOTENT = ( |
719 | DELETE => 1, |
719 | DELETE => 1, |
720 | GET => 1, |
720 | GET => 1, |
|
|
721 | QUERY => 1, |
721 | HEAD => 1, |
722 | HEAD => 1, |
722 | OPTIONS => 1, |
723 | OPTIONS => 1, |
723 | PUT => 1, |
724 | PUT => 1, |
724 | TRACE => 1, |
725 | TRACE => 1, |
725 | |
726 | |
… | |
… | |
737 | MKCOL => 1, |
738 | MKCOL => 1, |
738 | MKREDIRECTREF => 1, |
739 | MKREDIRECTREF => 1, |
739 | MKWORKSPACE => 1, |
740 | MKWORKSPACE => 1, |
740 | MOVE => 1, |
741 | MOVE => 1, |
741 | ORDERPATCH => 1, |
742 | ORDERPATCH => 1, |
|
|
743 | PRI => 1, |
742 | PROPFIND => 1, |
744 | PROPFIND => 1, |
743 | PROPPATCH => 1, |
745 | PROPPATCH => 1, |
744 | REBIND => 1, |
746 | REBIND => 1, |
745 | REPORT => 1, |
747 | REPORT => 1, |
746 | SEARCH => 1, |
748 | SEARCH => 1, |
… | |
… | |
1238 | # $state{handle}->destroyed |
1240 | # $state{handle}->destroyed |
1239 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (1), please report.";#d# |
1241 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (1), please report.";#d# |
1240 | $prepare_handle->(); |
1242 | $prepare_handle->(); |
1241 | # $state{handle}->destroyed |
1243 | # $state{handle}->destroyed |
1242 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (2), please report.";#d# |
1244 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (2), please report.";#d# |
|
|
1245 | $rpath = $upath; |
1243 | $handle_actual_request->(); |
1246 | $handle_actual_request->(); |
1244 | |
1247 | |
1245 | } else { |
1248 | } else { |
1246 | my $tcp_connect = $arg{tcp_connect} |
1249 | my $tcp_connect = $arg{tcp_connect} |
1247 | || do { require AnyEvent::Socket; \&AnyEvent::Socket::tcp_connect }; |
1250 | || do { require AnyEvent::Socket; \&AnyEvent::Socket::tcp_connect }; |