UA bug: response.pm base
Brad Johnson (brad@darwindigital.com)
Tue, 4 Aug 1998 11:51:08 -0400
I've been having this discussion on the the Win32 web list,
but I think it should also be on the general list.
> From: "Keith Calvert Ivey" <kcivey@cpcug.org>
> Date: Mon, 3 Aug 1998 21:10:30 -0500
> X-Message-Number: 35
>
> Brad Johnson <brad@darwindigital.com> wrote:
> > #!perl -w
> > require LWP::UserAgent;
> > my $ua = new LWP::UserAgent;
> > $ua->agent("test " . $ua->agent);
> > $ua->env_proxy;
> >
> > $url = "http://www.ibm.com/e-business/";
> > my $res = $ua->request(HTTP::Request->new(GET => $url));
> > print $res->base;
>
<snip>
>
> for that particular page the server sends a header line that
> reads
>
> Content-Location: index.phtml
>
> Since that's a relative URI, I think the module should be
> absolutizing it by using the request URI, to give
>
> http://www.ibm.com/e-business/index.phtml
>
> But it may be that you're expected to absolutize the URI
> returned by base yourself.
>
Unfortunately, that's not an acceptable solution (to do it yourself)
because other URL calls (internal calls, too) assume an absolute
base (the url->scheme in particular). So though I suspect that the
IBM site is ignoring HTTP protocol with their site, it probably would
be good for the module to absolutize the response->base.
I made this kludge to fix the Response.pm base subroutine:
sub base
{
my $self = shift;
my $base = $self->header('Content-Base') || # HTTP/1.1
$self->header('Content-Location') || # HTTP/1.1
$self->header('Base') || # backwards
compatability HTTP/1.0
$self->request->url;
$base = $self->request->url if !($base =~ /:/); # if relative base
given by headers
$base = URI::URL->new($base) unless ref $base;
$base;
}
Any ideas for a better fix?
Brad johnson
brad@darwindigital.com