7 use lib "$FindBin::Bin/lib";
9 use Test::More tests => 37;
12 use Digest::MD5 qw(md5_hex);
14 use File::Spec::Functions;
18 my $path = catdir( getcwd(), 't', 'data', 'urlencoded' );
20 for ( my $i = 1; $i <= 6; $i++ ) {
22 my $test = sprintf( "%.3d", $i );
23 my $headers = PAML::LoadFile( catfile( $path, "$test-headers.pml" ) );
24 my $results = PAML::LoadFile( catfile( $path, "$test-results.pml" ) );
25 my $content = IO::File->new( catfile( $path, "$test-content.dat" ) );
26 my $body = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
28 binmode $content, ':raw';
30 while ( $content->read( my $buffer, 1024 ) ) {
34 is_deeply( $body->body, $results->{body}, "$test UrlEncoded body" );
35 is_deeply( $body->param, $results->{param}, "$test UrlEncoded param" );
36 is_deeply( $body->param_order, $results->{param_order} ? $results->{param_order} : [], "$test UrlEncoded param_order" );
37 is_deeply( $body->upload, $results->{upload}, "$test UrlEncoded upload" );
38 cmp_ok( $body->state, 'eq', 'done', "$test UrlEncoded state" );
39 cmp_ok( $body->length, '==', $body->content_length, "$test UrlEncoded length" );
41 # Check trailing header on the chunked request
43 my $content = IO::File->new( catfile( $path, "002-content.dat" ) );
45 $content->read( my $buf, 4096 );
46 is( $body->trailing_headers->header('Content-MD5'), md5_hex($buf), "$test trailing header ok" );