File::Temp = 0.14
HTTP::Headers = 0
IO::File = 1.14
+IO::Handle::Util = 0.01
Digest::MD5 = 0
[Prereqs / TestRequires]
use strict;
use base 'HTTP::Body';
use bytes;
+use IO::Handle::Util;
our $DECODE = qr/%([0-9a-fA-F]{2})/;
my $self = shift;
return unless $self->length == $self->content_length;
+
+ # Store a copy of the raw request that the body() method can return
+ # see RT #111876
+ my $body_content = $self->{buffer};
+ $self->body(IO::Handle::Util::io_from_any($body_content));
# I tested parsing this using APR::Request, but perl is faster
# Pure-Perl 2560/s
$body->add($buffer);
}
- is_deeply( $body->body, $results->{body}, "$test UrlEncoded body" );
+ is_deeply( readfh($body->body), $results->{body}, "$test UrlEncoded body" );
is_deeply( $body->param, $results->{param}, "$test UrlEncoded param" );
is_deeply( $body->param_order, $results->{param_order} ? $results->{param_order} : [], "$test UrlEncoded param_order" );
is_deeply( $body->upload, $results->{upload}, "$test UrlEncoded upload" );
is( $body->trailing_headers->header('Content-MD5'), md5_hex($buf), "$test trailing header ok" );
}
}
+
+sub readfh {
+ my $fh = shift or die "readfh requires a filehandle";
+ $fh->seek(0,0) or die "Failed to seek";
+ return join "", $fh->getlines;
+}
{
- "body" => undef,
+ "body" => "text1=Ratione+accusamus+aspernatur+aliquam&text2=%C3%A5%C3%A4%C3%B6%C3%A5%C3%A4%C3%B6&select=A&select=B&textarea=Voluptatem+cumque+voluptate+sit+recusandae+at.+Et+quas+facere+rerum+unde+esse.+Sit+est+et+voluptatem.+Vel+temporibus+velit+neque+odio+non.%0D%0A%0D%0AMolestias+rerum+ut+sapiente+facere+repellendus+illo.+Eum+nulla+quis+aut.+Quidem+voluptas+vitae+ipsam+officia+voluptatibus+eveniet.+Aspernatur+cupiditate+ratione+aliquam+quidem+corrupti.+Eos+sunt+rerum+non+optio+culpa.&encoding=foo%3Dbar",
"upload" => {},
"param" => {
"text2" => "\303\245\303\244\303\266\303\245\303\244\303\266",
{
- "body" => undef,
+ "body" => "one=foo&two=bar",
"upload" => {},
"param" => {
"one" => "foo",
{
- "body" => undef,
+ "body" => "text1=Ratione+accusamus+aspernatur+aliquam&text2=%C3%A5%C3%A4%C3%B6%C3%A5%C3%A4%C3%B6&select=A&select=B&textarea=Voluptatem+cumque+voluptate+sit+recusandae+at.+Et+quas+facere+rerum+unde+esse.+Sit+est+et+voluptatem.+Vel+temporibus+velit+neque+odio+non.%0D%0A%0D%0AMolestias+rerum+ut+sapiente+facere+repellendus+illo.+Eum+nulla+quis+aut.+Quidem+voluptas+vitae+ipsam+officia+voluptatibus+eveniet.+Aspernatur+cupiditate+ratione+aliquam+quidem+corrupti.+Eos+sunt+rerum+non+optio+culpa.&encoding=foo%3Dbar",
"upload" => {},
"param" => {
"text2" => "\303\245\303\244\303\266\303\245\303\244\303\266",
{
- "body" => undef,
+ "body" => "one=foo; two=bar",
"upload" => {},
"param" => {
"one" => "foo",
{
- "body" => undef,
+ "body" => "one=foo;two=bar",
"upload" => {},
"param" => {
"one" => "foo",
{
- "body" => undef,
+ "body" => "one=foo;two=bar=bam",
"upload" => {},
"param" => {
"one" => "foo",