X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Futf_incoming.t;fp=t%2Futf_incoming.t;h=147b222c2fa444275d4732f04fb90cfe6b2140fb;hp=76eaa876a016e81e4ad7d319572ea2c580295502;hb=be634ffbdbe2fa1ff403d2c524ca53794958a3b7;hpb=90f231f1023d590e40c429dc8adad941ac13b651 diff --git a/t/utf_incoming.t b/t/utf_incoming.t index 76eaa87..147b222 100644 --- a/t/utf_incoming.t +++ b/t/utf_incoming.t @@ -4,7 +4,7 @@ use strict; use Test::More; use HTTP::Request::Common; use HTTP::Message::PSGI (); -use Encode 2.21 'decode_utf8', 'encode_utf8'; +use Encode 2.21 'decode_utf8', 'encode_utf8', 'encode'; use File::Spec; use JSON::MaybeXS; @@ -187,6 +187,12 @@ use JSON::MaybeXS; $c->res->from_psgi_response( ref($c)->to_app->($env)); } + sub echo_arg :Local { + my ($self, $c) = @_; + $c->response->content_type('text/plain'); + $c->response->body($c->req->body_parameters->{arg}); + } + package MyApp; use Catalyst; @@ -427,6 +433,36 @@ SKIP: { is $res->content_charset, 'UTF-8'; } +{ + my $utf8 = 'test ♥'; + my $shiftjs = 'test テスト'; + + ok my $req = POST '/root/echo_arg', + Content_Type => 'form-data', + Content => [ + arg0 => 'helloworld', + arg1 => [ + undef, '', + 'Content-Type' =>'text/plain; charset=UTF-8', + 'Content' => Encode::encode('UTF-8', $utf8)], + arg2 => [ + undef, '', + 'Content-Type' =>'text/plain; charset=SHIFT_JIS', + 'Content' => Encode::encode('SHIFT_JIS', $shiftjs)], + arg2 => [ + undef, '', + 'Content-Type' =>'text/plain; charset=SHIFT_JIS', + 'Content' => Encode::encode('SHIFT_JIS', $shiftjs)], + ]; + + my ($res, $c) = ctx_request $req; + + is $c->req->body_parameters->{'arg0'}, 'helloworld'; + is Encode::decode('UTF-8', $c->req->body_parameters->{'arg1'}), $utf8; + is Encode::decode('SHIFT_JIS', $c->req->body_parameters->{'arg2'}[0]), $shiftjs; + +} + ## should we use binmode on filehandles to force the encoding...? ## Not sure what else to do with multipart here, if docs are enough...