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

Owner: Nobody in particular
Requestors: greg [...]

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

Subject: HTTP::Message content 'CODE' reference
Download (untitled) / with headers
text/plain 954b
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: but I have not isolated the exact problem.
From: greg [...]
Download (untitled) / with headers
text/plain 428b
[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 [...]
Download (untitled) / with headers
text/plain 778b
[guest - Thu Aug 26 17:41:12 2004]: I changed a line in the 1.68 version of LWP::Protocol/ where the dereferencing of a CODE as a SCALAR was happening and I didn't need to change my code: ---------------------------------- --- 2004-11-03 14:38:24.000000000 -0200 +++ 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.

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

Please report any issues with to