minor refactoring, created HTTP::Body::Octetstream
[catagits/HTTP-Body.git] / test.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use lib './lib';
6
7 use Data::Dumper;
8 use HTTP::Body;
9 use IO::File;
10 use YAML qw[LoadFile];
11
12 my $test = shift(@ARGV) || 1;
13
14 my $headers = LoadFile( sprintf( "t/data/multipart/%.3d-headers.yml", $test ) );
15 my $content = IO::File->new( sprintf( "t/data/multipart/%.3d-content.dat", $test ), O_RDONLY );
16 my $body    = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
17
18 binmode $content;
19
20 while ( $content->read( my $buffer, 1024 ) ) {
21     $body->add($buffer);
22 }
23
24 warn Dumper( $body->param  );
25 warn Dumper( $body->upload );
26 warn Dumper( $body->body   );
27
28 warn "length         : " . $body->length;
29 warn "content length : " . $body->content_length;
30 warn "state          : " . $body->{state};
31 warn "buffer         : " . $body->buffer;