Skip Menu |
 

This queue is for tickets about the HTTP-Message CPAN distribution.

Report information
The Basics
Id: 77466
Status: resolved
Priority: 0/
Queue: HTTP-Message

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

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



Subject: warning for empty POST requests
Download (untitled) / with headers
text/plain 486b
Since version 6.03, HTTP::Request::Common::POST will emit a warning when being given an empty $form_ref (which e.g. HTML::Form might do): $ perl -w -MHTTP::Request::Common -e 'POST "http://unf.ug/", [foo=>"bar"]' $ perl -w -MHTTP::Request::Common -e 'POST "http://unf.ug/", []' Use of uninitialized value $content in substitution (s///) at /usr/local/lib/perl5/site_perl/5.16.0/HTTP/Request/Common.pm line 86. Please find my suggestion for a fix attached as patch. Kind regards, fany
Subject: HTTP-Message.patch
Download HTTP-Message.patch
text/x-diff 973b
diff --git a/lib/HTTP/Request/Common.pm b/lib/HTTP/Request/Common.pm index 626e048..f6571a5 100644 --- a/lib/HTTP/Request/Common.pm +++ b/lib/HTTP/Request/Common.pm @@ -83,7 +83,7 @@ sub POST $content = $url->query; # HTML/4.01 says that line breaks are represented as "CR LF" pairs (i.e., `%0D%0A') - $content =~ s/(?<!%0D)%0A/%0D%0A/g; + $content =~ s/(?<!%0D)%0A/%0D%0A/g if defined $content; } } diff --git a/t/common-req.t b/t/common-req.t index 06d5022..ea6cd09 100644 --- a/t/common-req.t +++ b/t/common-req.t @@ -1,7 +1,7 @@ #perl -w use Test; -plan tests => 52; +plan tests => 53; use HTTP::Request::Common; @@ -63,6 +63,13 @@ ok($r->header("Subject"), "Heisan"); ok($r->content, "Howdy\n"); ok($r->content_type, "text/plain"); +{ + my @warnings; + local $SIG{__WARN__} = sub { push @warnings, @_ }; + $r = POST 'http://unf.ug/', []; + ok( "@warnings", '', 'empty POST' ); +} + # # POST for File upload #


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.