Re: Inconsistent $response->base behaviour
Gisle Aas (aas@bergen.sn.no)
Tue, 16 Jul 1996 12:19:25 +0200
In message <yah4tn8ipu2.fsf@twi.tudelft.nl>, Hans de Graaff writes:
> I just found out that the base() method in HTTP::Response usually
> returns a URI::URL object, but sometimes just plain text.
This patch makes $reponse->base always return a URI::URL object
reference.
Index: Response.pm
===================================================================
RCS file: /f/stovner/utvikling/CVSROOT/aas/perl/mods/libwww-perl/lib/HTTP/Response.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Response.pm 1996/05/26 10:40:27 1.19
+++ Response.pm 1996/07/16 10:15:13 1.20
@@ -1,5 +1,5 @@
#
-# $Id: Response.pm,v 1.19 1996/05/26 10:40:27 aas Exp $
+# $Id: Response.pm,v 1.20 1996/07/16 10:15:13 aas Exp $
package HTTP::Response;
@@ -45,6 +45,7 @@
@ISA = qw(HTTP::Message);
use HTTP::Status ();
+use URI::URL ();
=head2 $r = new HTTP::Response ($rc [, $msg])
@@ -105,8 +106,10 @@
=head2 $r->base
-Returns the base URL for this response. The base URL can come from 3
-sources:
+Returns the base URL for this response. The return value will be a
+reference to a URI::URL object.
+
+The base URL can have been obtained from the following 3 sources:
=over 4
@@ -135,7 +138,9 @@
sub base
{
my $self = shift;
- $self->header('Base') || $self->request->url;
+ my $base = $self->header('Base') || $self->request->url;
+ $base = URI::URL->new($base) unless ref $base;
+ $base;
}