7 use HTTP::Request::Common;
9 use HTTP::Message::PSGI ();
10 use File::Spec::Functions;
11 use File::Temp qw/ tempdir /;
15 my $shiftjs = 'test テスト';
16 my $path = File::Spec->catfile('t', 'utf8.txt');
18 ok my $req = POST '/root/echo_arg',
19 Content_Type => 'form-data',
24 'Content-Type' =>'text/plain; charset=UTF-8',
25 'Content' => Encode::encode('UTF-8', $utf8)],
28 'Content-Type' =>'text/plain; charset=SHIFT_JIS',
29 'Content' => Encode::encode('SHIFT_JIS', $shiftjs)],
32 'Content-Type' =>'text/plain; charset=SHIFT_JIS',
33 'Content' => Encode::encode('SHIFT_JIS', $shiftjs)],
35 "$path", Encode::encode_utf8('♥ttachment.txt'), 'Content-Type' =>'text/html; charset=UTF-8'
40 ok my $env = HTTP::Message::PSGI::req_to_psgi($req);
41 ok my $fh = $env->{'psgi.input'};
42 ok my $body = HTTP::Body->new( $req->header('Content-Type'), $req->header('Content-Length') );
43 ok my $tempdir = tempdir( 'XXXXXXX', CLEANUP => 1, DIR => File::Spec->tmpdir() );
44 $body->tmpdir($tempdir);
48 while ( $fh->read( my $buffer, 1024 ) ) {
52 is $body->param->{'arg0'}, 'helloworld';
53 is Encode::decode('UTF-8', $body->param->{'arg1'}), $utf8;
54 is Encode::decode('SHIFT_JIS', $body->param->{'arg2'}[0]), $shiftjs;
56 is $body->part_data->{'arg0'}->{data}, 'helloworld';
57 is Encode::decode('UTF-8', $body->part_data->{'arg1'}->{data}), $utf8;
58 is Encode::decode('SHIFT_JIS', $body->part_data->{'arg2'}[0]->{data}), $shiftjs;