AnyEvent-HTTP
view release on metacpan or search on metacpan
push @pseudo, Redirect => delete $arg{Redirect} if exists $arg{Redirect};
my $recurse = exists $arg{recurse} ? delete $arg{recurse} : $MAX_RECURSE;
return $cb->(undef, { @pseudo, Status => 599, Reason => "Too many redirections" })
if $recurse < 0;
my $proxy = exists $arg{proxy} ? $arg{proxy} : $PROXY;
my $timeout = $arg{timeout} || $TIMEOUT;
my ($uscheme, $uauthority, $upath, $query, undef) = # ignore fragment
$url =~ m|^([^:]+):(?://([^/?#]*))?([^?#]*)(?:(\?[^#]*))?(?:#(.*))?$|;
$uscheme = lc $uscheme;
my $uport = $uscheme eq "http" ? 80
: $uscheme eq "https" ? 443
: return $cb->(undef, { @pseudo, Status => 599, Reason => "Only http and https URL schemes supported" });
$uauthority =~ /^(?: .*\@ )? ([^\@]+?) (?: : (\d+) )?$/x
or return $cb->(undef, { @pseudo, Status => 599, Reason => "Unparsable URL" });
# don't support https requests over https-proxy transport,
# can't be done with tls as spec'ed, unless you double-encrypt.
$rscheme = "http" if $uscheme eq "https" && $rscheme eq "https";
$rhost = lc $rhost;
$rscheme = lc $rscheme;
} else {
($rhost, $rport, $rscheme, $rpath) = ($uhost, $uport, $uscheme, $upath);
}
# leave out fragment and query string, just a heuristic
$hdr{referer} = "$uscheme://$uauthority$upath" unless exists $hdr{referer};
$hdr{"user-agent"} = $USERAGENT unless exists $hdr{"user-agent"};
$hdr{"content-length"} = length $arg{body}
if length $arg{body} || $method ne "GET";
my $idempotent = $IDEMPOTENT{$method};
# default value for keepalive is true iff the request is for an idempotent method
my $persistent = exists $arg{persistent} ? !!$arg{persistent} : $idempotent;
( run in 1.342 second using v1.01-cache-2.11-cpan-b16cb0d3907 )