… | |
… | |
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.21; |
51 | our $VERSION = 2.22; |
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; |
… | |
… | |
194 | |
194 | |
195 | C<$scheme> must be either missing or must be C<http> for HTTP. |
195 | C<$scheme> must be either missing or must be C<http> for HTTP. |
196 | |
196 | |
197 | If not specified, then the default proxy is used (see |
197 | If not specified, then the default proxy is used (see |
198 | C<AnyEvent::HTTP::set_proxy>). |
198 | C<AnyEvent::HTTP::set_proxy>). |
|
|
199 | |
|
|
200 | Currently, if your proxy requires authorization, you have to specify an |
|
|
201 | appropriate "Proxy-Authorization" header in every request. |
199 | |
202 | |
200 | =item body => $string |
203 | =item body => $string |
201 | |
204 | |
202 | The request body, usually empty. Will be sent as-is (future versions of |
205 | The request body, usually empty. Will be sent as-is (future versions of |
203 | this module might offer more options). |
206 | this module might offer more options). |
… | |
… | |
770 | |
773 | |
771 | my $uport = $uscheme eq "http" ? 80 |
774 | my $uport = $uscheme eq "http" ? 80 |
772 | : $uscheme eq "https" ? 443 |
775 | : $uscheme eq "https" ? 443 |
773 | : return $cb->(undef, { @pseudo, Status => 599, Reason => "Only http and https URL schemes supported" }); |
776 | : return $cb->(undef, { @pseudo, Status => 599, Reason => "Only http and https URL schemes supported" }); |
774 | |
777 | |
775 | $uauthority =~ /^(?: .*\@ )? ([^\@:]+) (?: : (\d+) )?$/x |
778 | $uauthority =~ /^(?: .*\@ )? ([^\@]+?) (?: : (\d+) )?$/x |
776 | or return $cb->(undef, { @pseudo, Status => 599, Reason => "Unparsable URL" }); |
779 | or return $cb->(undef, { @pseudo, Status => 599, Reason => "Unparsable URL" }); |
777 | |
780 | |
778 | my $uhost = lc $1; |
781 | my $uhost = lc $1; |
779 | $uport = $2 if defined $2; |
782 | $uport = $2 if defined $2; |
780 | |
783 | |
… | |
… | |
1120 | _destroy_state %state; |
1123 | _destroy_state %state; |
1121 | |
1124 | |
1122 | %state = (); |
1125 | %state = (); |
1123 | $state{recurse} = |
1126 | $state{recurse} = |
1124 | http_request ( |
1127 | http_request ( |
1125 | $method => $url, |
1128 | $method => $url, |
1126 | %arg, |
1129 | %arg, |
1127 | recurse => $recurse - 1, |
1130 | recurse => $recurse - 1, |
1128 | keepalive => 0, |
1131 | persistent => 0, |
1129 | sub { |
1132 | sub { |
1130 | %state = (); |
1133 | %state = (); |
1131 | &$cb |
1134 | &$cb |
1132 | } |
1135 | } |
1133 | ); |
1136 | ); |