Fix regexp in urldecode
[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 $number = $ARGV[0] || 1;
13 my $what   = $ARGV[1] || 'multipart';
14
15
16 my $headers = LoadFile( sprintf( "t/data/%s/%.3d-headers.yml", $what, $number ) );
17 my $content = IO::File->new( sprintf( "t/data/%s/%.3d-content.dat", $what, $number ), O_RDONLY );
18 my $body    = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
19
20 binmode $content;
21
22 while ( $content->read( my $buffer, 1024 ) ) {
23     $body->add($buffer);
24 }
25
26 warn Dumper( $body->param  );
27 warn Dumper( $body->upload );
28 warn Dumper( $body->body   );
29
30 warn "state          : " . $body->state;
31 warn "length         : " . $body->length;
32 warn "content length : " . $body->content_length;
33 warn "body length    : " . ( $body->body->stat )[7] if $body->body;
34 warn "buffer         : " . $body->buffer if $body->buffer;