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