Skip Menu |
 

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 53037
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 5.834
Fixed in: (no value)



Subject: LWP::Protocol::collect() does not play nice with overloaded object files
Here's a simple example. use LWP::Simple; use Path::Class; $file = file("output.html"); print "HTTP Status: ".getstore("http://www.google.com", $file)."\n"; print "File exists" if -e $file; The file is silently thrown away. It works fine if you force $file to be a string. The root of the problem is in LWP::Protocol::collect(). It checks if the filename is not a reference. That won't play nice with stringified objects. Rather than trying to check if the thing is an object and it is string overloaded, a simple solution is to make the else clause assume its a file rather than (in this case ineffectually) dying. So... if (!defined($arg) || !$response->is_success) { ...its that thing... } elsif (ref($arg) eq 'CODE') { ...its a code ref... } elsif( length($arg) ) { ...assume its a file... } else { ...die, we got an empty string... } If you hand it something weird and get a file called HASH(0x1398209), ok fine.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.