Re: Enclosed: Patch for LWP::UserAgent.pm
Chris W. Unger (cunger@cas.org)
Fri, 20 Mar 1998 10:04:21 -0500
> > Notice how the relative URL specified in the "Location" field begins with
> > "http:".
>
> Stupid thing. Is it a CGI script that generates this?
Gisle,
Yes, one of the publishers that we are collaborating with has a CGI
program that is returning this type of redirect. We have requested
that they change their redirection scheme, but we wanted to take a
proactive approach to correct the problem.
>
> Actually, the $url->abs method already support this kind of relative
> links. This is what the documentation says:
>
> $url->abs([$base, [$allow_scheme_in_relative_urls]])
> [...]
> Some older parsers used to allow the scheme name to be
> present in the relative URL if it was the same as the
> base URL scheme. RFC1808 says that this should be
> avoided, but you can enable this old behaviour by
> passing a TRUE value as the second argument to the
> abs() method. The difference is demonstrated by the
> following examples:
>
> url("http:foo")->abs("http://host/a/b") ==> "http:foo"
> url("http:foo")->abs("http://host/a/b", 1) ==> "http:/host/a/foo"
>
> But it this case is probably better to support this by default than
> not. I think a better fix would be:
>
> my $referral_uri = (URI::URL->new($location, $response->base))->abs(undef,1);
>
> It will probably be in 5.22.
OK, sorry I missed this when reading the documentation. Thanks you for your
prompt response and your willingness to support this type of redirect by
default.
Chris