Re: cloning HTTP::Request uri

Gisle Aas (gisle@aas.no)
17 Nov 1999 21:42:24 +0100


Jeffrey Behr <behr@shadowlink.net> writes:

> I'm using WebFS::FileCopy 1.01 to transfer files and seem to be 
> running into a problem with the HTTP::Request:clone method.  I'm 
> trying to utilize a WebFS capability to move multiple files to a 
> single destination directory simultaneously, and in the process 
> the filename is stripped from each "from" URI and appended to the 
> directory URI to create a URI to put the content "to".
> 
> WebFS::FileCopy:copy_urls uses LWP::Request (HTTP::Request) objects 
> and clones the "to" Request's (directory) URI before appending the 
> filename to the cloned URI.  I appear to be getting a copy as the
> cloned Request, but for some reason as soon as the cloned Request 
> URI is updated, so is the original.  The URI clone is done in 
> HTTP::Request:clone.

This is a bug.  This patch should fix it:

Index: lib/HTTP/Request.pm
===================================================================
RCS file: /home/cvs/aas/perl/mods/libwww-perl/lib/HTTP/Request.pm,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -p -r1.26 -r1.27
--- lib/HTTP/Request.pm	1999/03/20 07:37:35	1.26
+++ lib/HTTP/Request.pm	1999/11/17 20:38:14	1.27
@@ -101,6 +101,7 @@ sub uri
 	if (!defined $uri) {
 	    # that's ok
 	} elsif (ref $uri) {
+	    $uri = $uri->clone;
 	    unless ($HTTP::URI_CLASS eq "URI") {
 		# Argh!! Hate this... old LWP legacy!
 		eval { $uri = $uri->abs; };

Regards,
Gisle