--- AnyEvent-HTTP/HTTP.pm 2008/06/05 16:33:02 1.12 +++ AnyEvent-HTTP/HTTP.pm 2008/06/05 16:43:45 1.13 @@ -246,6 +246,8 @@ : $scheme eq "https" ? 443 : return $cb->(undef, { Status => 599, Reason => "only http and https URL schemes supported" }); + $hdr{referer} ||= "$scheme://$authority$upath"; # leave out fragment and query string, just a heuristic + $authority =~ /^(?: .*\@ )? ([^\@:]+) (?: : (\d+) )?$/x or return $cb->(undef, { Status => 599, Reason => "unparsable URL" }); @@ -257,8 +259,6 @@ $upath =~ s%^/?%/%; - $hdr{referer} ||= "$scheme://$authority$upath"; - # cookie processing if (my $jar = $arg{cookie_jar}) { %$jar = () if $jar->{version} < 1; @@ -402,7 +402,7 @@ } } - if ($_[1]{Status} =~ /^x30[12]$/ && $recurse) { + if ($_[1]{Status} =~ /^30[12]$/ && $recurse) { # microsoft and other assholes don't give a shit for following standards, # try to support a common form of broken Location header. $_[1]{location} =~ s%^/%$scheme://$uhost:$uport/%;