Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: greg [...] hewgill.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 5.800
Fixed in: 5.801



Subject: HTTP::Message content 'CODE' reference
I am working with LWP::UserAgent and am having trouble with the content of HTTP::Message objects in the latest version of HTTP::Message. Since I am sending very large files I am using the feature where the content can be a 'CODE' reference which will be called when data is needed. My code looks something like this: my $reader = sub { my $buf; read F, $buf, 16384; return $buf; }; $request->content($reader); When using HTTP::Message newer than cvs version 1.43, the above fails with a "Not a SCALAR reference" inside the request method. In order to make this work, I must use: $request->content(\$reader); Unfortunately, passing the reference-to-reference-to-CODE like this fails with pre-1.43 HTTP::Message modules. I believe something happened in the following changes: http://cvs.sourceforge.net/viewcvs.py/libwww-perl/lwp5/lib/HTTP/Message.pm?r1=1.42&r2=1.43 but I have not isolated the exact problem.
From: greg [...] hewgill.com
[guest - Thu Aug 26 17:12:58 2004]: I have been able to work around this problem with the following code: if ($HTTP::Message::VERSION =~ /^1\.4[34]$/) { $request->content(\$reader); } else { $request->content($reader); } I guess this issue can be downgraded from "Critical" since there is a workaround, but this workaround will need to be present in all code that uses HTTP::Message with 'CODE' references as content.
From: gustavo [...] cpqd.com.br
[guest - Thu Aug 26 17:41:12 2004]: I changed a line in the 1.68 version of LWP::Protocol/http.pm where the dereferencing of a CODE as a SCALAR was happening and I didn't need to change my code: ---------------------------------- --- http.pm.orig 2004-11-03 14:38:24.000000000 -0200 +++ http.pm 2004-11-03 14:45:05.000000000 -0200 @@ -166,7 +166,7 @@ }); my $content_ref = $request->content_ref; - $content_ref = $$content_ref if ref($$content_ref); + $content_ref = $$content_ref if (ref($content_ref) eq 'SCALAR') && ref($$content_ref); my $chunked; my $has_content; --------------------------------- I haven't give much thought to it to know if this is a complete fix, but I think this is part of it. Gustavo.