Skip Menu |
 

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

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

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

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



Subject: HTTP::Request::Common::PUT should set content length
Download (untitled) / with headers
text/plain 316b
As it stands, if I put content in a PUT request made with HTTP::Request::Common, it won't work with some (annoying) HTTP parsers, like those used in testing Catalyst, because there is no content-length header. The POST routine creates that header, and it's very convenient. Please supply it for PUT, too. -- rjbs
Download (untitled) / with headers
text/plain 943b
I've now applied this patch. To appear in LWP-5.811. diff --git a/lib/HTTP/Request/Common.pm b/lib/HTTP/Request/Common.pm index d1ec52a..b0c8951 100644 --- a/lib/HTTP/Request/Common.pm +++ b/lib/HTTP/Request/Common.pm @@ -104,6 +104,7 @@ sub _simple_req while (($k,$v) = splice(@_, 0, 2)) { if (lc($k) eq 'content') { $req->add_content($v); + $req->header("Content-Length", length(${$req->content_ref})); } else { $req->push_header($k, $v); diff --git a/t/base/common-req.t b/t/base/common-req.t index 66f74b4..5c4ba0d 100644 --- a/t/base/common-req.t +++ b/t/base/common-req.t @@ -30,7 +30,7 @@ print "not " if defined($r->header("Content")); print "ok 5\n"; print "not " unless ${$r->content_ref} eq "foo" and - $r->content eq "foo"; + $r->content eq "foo" and $r->content_length == 3; print "ok 6\n"; #--- Test POST requests ---
Download (untitled) / with headers
text/plain 281b
This actually makes things worse, from what I can tell. It uses length, but not bytes.pm, so anything with a UTF-8 string content is now broken. This has been causing a lot of "Augh what is broken!?" today on #catalyst the length call should be using bytes.pm's length -- rjbs
Download (untitled) / with headers
text/plain 282b
On Wed Apr 09 14:17:59 2008, RJBS wrote: Show quoted text
> the length call should be using bytes.pm's length
No, I don't think so. The content you provide need to be encoded as bytes before you call PUT(). LWP will now enforce this and the constructor will croak if you pass it Unicode strings.


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.