Hi all,
I need to perform a PUT operation and send a very large file (several hundred MBytes). I have been using the following code to do this:
...
my $header = HTTP::Headers->new;
$header->content_type('application/octet-stream');
$header->content_length($fileSize);
$header->authorization_basic($usr, $pwd); my $readFunc = sub {
read(FH, my $buf, 65536);
return $buf;
}; my $req = HTTP::Request->new("PUT", $url, $header, $readFunc);
...But after updating to the 5.802 version of LWP this code has stopped working.
When I execute my script, it prints a warning telling me that the Content-Length header has been fixed, and the file in the destination server is corrupted.
Looking at the code of the library, I have found these lines:
# Set (or override) Content-Length header
my $clen = $request_headers->header('Content-Length');
if (defined($$content_ref) && length($$content_ref)) {
$has_content++;
if (!defined($clen) || $clen ne length($$content_ref)) {
if (defined $clen) {
warn "Content-Length header value was wrong, fixed";
hlist_remove([EMAIL PROTECTED], 'Content-Length');
}
push(@h, 'Content-Length' => length($$content_ref));
}
} elsif ($clen) {
warn "Content-Length set when there is not content, fixed";
hlist_remove([EMAIL PROTECTED], 'Content-Length');
}I think these lines prevent the use of a function as the content reference.
Is this a bug, or the support for function references has been removed?
Thanks in advance, Rodrigo Ruiz
-- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.813 / Virus Database: 553 - Release Date: 13/12/2004
