use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 16;
use Cwd;
+use Digest::MD5 qw(md5_hex);
use HTTP::Body;
use File::Spec::Functions;
use IO::File;
my $path = catdir( getcwd(), 't', 'data', 'urlencoded' );
-for ( my $i = 1; $i <= 2; $i++ ) {
+for ( my $i = 1; $i <= 3; $i++ ) {
my $test = sprintf( "%.3d", $i );
my $headers = YAML::LoadFile( catfile( $path, "$test-headers.yml" ) );
is_deeply( $body->param, $results->{param}, "$test UrlEncoded param" );
is_deeply( $body->upload, $results->{upload}, "$test UrlEncoded upload" );
cmp_ok( $body->state, 'eq', 'done', "$test UrlEncoded state" );
- cmp_ok( $body->length, '==', $headers->{'Content-Length'}, "$test UrlEncoded length" );
+ cmp_ok( $body->length, '==', $body->content_length, "$test UrlEncoded length" );
+
+ # Check trailing header on the chunked request
+ if ( $i == 3 ) {
+ my $content = IO::File->new( catfile( $path, "002-content.dat" ) );
+ $content->read( my $buf, 4096 );
+ is( $body->trailing_headers->header('Content-MD5'), md5_hex($buf), "$test trailing header ok" );
+ }
}