Skip Menu |

This queue is for tickets about the REST-Client CPAN distribution.

Report information
The Basics
Id: 100579
Status: resolved
Priority: 0/
Queue: REST-Client

People
Owner: Nobody in particular
Requestors: thomas [...] hoerndlein.de
Cc:
AdminCc:

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



Subject: HTTP PUT and HTTP Post do not work with value 0 (zero)
Date: Thu, 27 Nov 2014 12:57:10 +0100 (CET)
To: bug-REST-Client [...] rt.cpan.org
From: Thomas Hörndlein <thomas [...] hoerndlein.de>
Hello, REST::Client does not work with body content which evaluates to false like this: $client->PUT('http://example.com/dir/file', 0); $client->POST('http://example.com/dir/file', 0); The reason is an incorrect formulated if-condition within the request-subroutine: sub request { … #build headers if($content){ $req->content($content); $req->header('Content-Length', length($content)); }else{ $req->header('Content-Length', 0); } … } This always evaluates to false if $content is something like 0 or the empty string ‘’ and so on. The fix would be testing the length of $content like this: sub request { … #build headers if(length $content){ $req->content($content); $req->header('Content-Length', length($content)); }else{ $req->header('Content-Length', 0); } … } Kind regards, Thomas
Subject: Re: [rt.cpan.org #100579] HTTP PUT and HTTP Post do not work with value 0 (zero)
Date: Thu, 27 Nov 2014 10:07:58 -0800
To: bug-REST-Client [...] rt.cpan.org
From: Miles <miles [...] milescrawford.com>
thanks, i will fix that! On Nov 27, 2014 3:57 AM, "Thomas Hörndlein via RT" < bug-REST-Client@rt.cpan.org> wrote: Show quoted text
> Thu Nov 27 06:57:23 2014: Request 100579 was acted upon. > Transaction: Ticket created by thomas@hoerndlein.de > Queue: REST-Client > Subject: HTTP PUT and HTTP Post do not work with value 0 (zero) > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: thomas@hoerndlein.de > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=100579 > > > > Hello, > > REST::Client does not work with body content which evaluates to false like > this: > > $client->PUT('http://example.com/dir/file', 0); > $client->POST('http://example.com/dir/file', 0); > > > The reason is an incorrect formulated if-condition within the > request-subroutine: > > sub request { > … > #build headers > if($content){ > $req->content($content); > $req->header('Content-Length', length($content)); > }else{ > $req->header('Content-Length', 0); > } > … > } > > This always evaluates to false if $content is something like 0 or the empty > string ‘’ and so on. > > The fix would be testing the length of $content like this: > > sub request { > … > #build headers > if(length $content){ > $req->content($content); > $req->header('Content-Length', length($content)); > }else{ > $req->header('Content-Length', 0); > } > … > } > > Kind regards, > Thomas > >
Fixed in 272. Thanks for the report!