… | |
… | |
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; |
… | |
… | |
904 | |
904 | |
905 | } elsif ($loc !~ /^(?: $ | [^:\/?\#]+ : )/x) { # anything "simple" |
905 | } elsif ($loc !~ /^(?: $ | [^:\/?\#]+ : )/x) { # anything "simple" |
906 | $loc =~ s/^\.\/+//; |
906 | $loc =~ s/^\.\/+//; |
907 | |
907 | |
908 | if ($loc !~ m%^[.?#]%) { |
908 | if ($loc !~ m%^[.?#]%) { |
909 | my $prefix = "$uscheme://$uhost:$uport"; |
909 | my $prefix = "$uscheme://$uauthority"; |
910 | |
910 | |
911 | unless ($loc =~ s/^\///) { |
911 | unless ($loc =~ s/^\///) { |
912 | $prefix .= $upath; |
912 | $prefix .= $upath; |
913 | $prefix =~ s/\/[^\/]*$//; |
913 | $prefix =~ s/\/[^\/]*$//; |
914 | } |
914 | } |
… | |
… | |
1217 | # on a keepalive request (in theory, this should be a separate config option). |
1217 | # on a keepalive request (in theory, this should be a separate config option). |
1218 | if ($persistent && $KA_CACHE{$ka_key}) { |
1218 | if ($persistent && $KA_CACHE{$ka_key}) { |
1219 | $was_persistent = 1; |
1219 | $was_persistent = 1; |
1220 | |
1220 | |
1221 | $state{handle} = ka_fetch $ka_key; |
1221 | $state{handle} = ka_fetch $ka_key; |
1222 | $state{handle}->destroyed |
1222 | # $state{handle}->destroyed |
1223 | and die "AnyEvent::HTTP: unexpectedly got a destructed handle (1), please report.";#d# |
1223 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (1), please report.";#d# |
1224 | $prepare_handle->(); |
1224 | $prepare_handle->(); |
1225 | $state{handle}->destroyed |
1225 | # $state{handle}->destroyed |
1226 | and die "AnyEvent::HTTP: unexpectedly got a destructed handle (2), please report.";#d# |
1226 | # and die "AnyEvent::HTTP: unexpectedly got a destructed handle (2), please report.";#d# |
1227 | $handle_actual_request->(); |
1227 | $handle_actual_request->(); |
1228 | |
1228 | |
1229 | } else { |
1229 | } else { |
1230 | my $tcp_connect = $arg{tcp_connect} |
1230 | my $tcp_connect = $arg{tcp_connect} |
1231 | || do { require AnyEvent::Socket; \&AnyEvent::Socket::tcp_connect }; |
1231 | || do { require AnyEvent::Socket; \&AnyEvent::Socket::tcp_connect }; |