namespace change
[catagits/HTTP-Body.git] / test.pl
diff --git a/test.pl b/test.pl
index a9ef755..bfef045 100644 (file)
--- a/test.pl
+++ b/test.pl
@@ -9,22 +9,26 @@ use HTTP::Body;
 use IO::File;
 use YAML qw[LoadFile];
 
-my $test = shift(@ARGV) || 1;
+my $number = $ARGV[0] || 1;
+my $what   = $ARGV[1] || 'multipart';
 
-my $headers = LoadFile( sprintf( "t/data/multipart/%.3d-headers.yml", $test ) );
-my $content = IO::File->new( sprintf( "t/data/multipart/%.3d-content.dat", $test ), O_RDONLY );
-my $parser  = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
 
-warn ref($parser);
+my $headers = LoadFile( sprintf( "t/data/%s/%.3d-headers.yml", $what, $number ) );
+my $content = IO::File->new( sprintf( "t/data/%s/%.3d-content.dat", $what, $number ), O_RDONLY );
+my $body    = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
 
 binmode $content;
 
 while ( $content->read( my $buffer, 1024 ) ) {
-    last if $parser->add($buffer) == 0;
+    $body->add($buffer);
 }
 
-warn "length   : $parser->{length}\n";
-warn "state    : $parser->{state}\n";
+warn Dumper( $body->param  );
+warn Dumper( $body->upload );
+warn Dumper( $body->body   );
 
-warn Dumper( $parser->param );
-warn Dumper( $parser->upload );
+warn "state          : " . $body->state;
+warn "length         : " . $body->length;
+warn "content length : " . $body->content_length;
+warn "body length    : " . ( $body->body->stat )[7] if $body->body;
+warn "buffer         : " . $body->buffer if $body->buffer;