I've now applied the following patch <
http://gitorious.org/projects/libwww-
perl/repos/mainline/commits/5a04f678e229a505f3fc7f1073cfe85342abb68e>
commit 5a04f678e229a505f3fc7f1073cfe85342abb68e
Author: Gisle Aas <gisle@aas.no>
Date: Fri Dec 5 10:09:21 2008 -0800
Prefer use specified Content-Length header [RT#41462]
We ended up with a double Content-Length header when the user specified
one explictly.
diff --git a/lib/HTTP/Request/Common.pm b/lib/HTTP/Request/Common.pm
index 9b342d1..26ad747 100644
--- a/lib/HTTP/Request/Common.pm
+++ b/lib/HTTP/Request/Common.pm
@@ -102,15 +102,19 @@ sub _simple_req
my($method, $url) = splice(@_, 0, 2);
my $req = HTTP::Request->new($method => $url);
my($k, $v);
+ my $content;
while (($k,$v) = splice(@_, 0, 2)) {
if (lc($k) eq 'content') {
$req->add_content($v);
- $req->header("Content-Length", length(${$req->content_ref}));
+ $content++;
}
else {
$req->push_header($k, $v);
}
}
+ if ($content && !defined($req->header("Content-Length"))) {
+ $req->header("Content-Length", length(${$req->content_ref}));
+ }
$req;
}
diff --git a/t/base/common-req.t b/t/base/common-req.t
index acb4c53..86fe116 100644
--- a/t/base/common-req.t
+++ b/t/base/common-req.t
@@ -1,7 +1,7 @@
#perl -w
use Test;
-plan tests => 51;
+plan tests => 52;
use HTTP::Request::Common;
@@ -205,3 +205,9 @@ EOT
$r = HTTP::Request::Common::DELETE '
http://www.example.com';
ok($r->method, "DELETE");
+
+$r = HTTP::Request::Common::PUT '
http://www.example.com',
+ 'Content-Type' => 'application/octet-steam',
+ 'Content' => 'foobarbaz',
+ 'Content-Length' => 12; # a slight lie
+ok($r->header('Content-Length'), 12);
d