8 eval { require YAML; import YAML 'LoadFile'; };
10 eval { require YAML::Syck; import YAML::Syck 'LoadFile'; }
13 plan skip_all => 'Tests need YAML or YAML::Syck' if $@;
19 use File::Spec::Functions;
22 my $path = catdir( getcwd(), 't', 'data', 'multipart' );
24 for ( my $i = 1; $i <= 11; $i++ ) {
26 my $test = sprintf( "%.3d", $i );
27 my $headers = LoadFile( catfile( $path, "$test-headers.yml" ) );
28 my $results = LoadFile( catfile( $path, "$test-results.yml" ) );
29 my $content = IO::File->new( catfile( $path, "$test-content.dat" ) );
30 my $body = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
32 binmode $content, ':raw';
34 while ( $content->read( my $buffer, 1024 ) ) {
38 for my $field ( keys %{ $body->upload } ) {
40 my $value = $body->upload->{$field};
42 for ( ( ref($value) eq 'ARRAY' ) ? @{$value} : $value ) {
43 delete $_->{tempname};
47 is_deeply( $body->body, $results->{body}, "$test MultiPart body" );
48 is_deeply( $body->param, $results->{param}, "$test MultiPart param" );
49 is_deeply( $body->upload, $results->{upload}, "$test MultiPart upload" );
50 cmp_ok( $body->state, 'eq', 'done', "$test MultiPart state" );
51 cmp_ok( $body->length, '==', $headers->{'Content-Length'}, "$test MultiPart length" );