Permalink
Browse files

Fixes to Request.params

  • Loading branch information...
1 parent bdf4db6 commit a1159fa72210fb7e68908ea5d184d087e84696f0 @flussence flussence committed Oct 27, 2012
Showing with 18 additions and 2 deletions.
  1. +2 −2 lib/Bailador/Request.pm
  2. +16 −0 t/05-post-content.t
View
@@ -5,8 +5,8 @@ class Bailador::Request {
method params {
my %ret;
- for $.env<psgi.input>.split('&') -> $p {
- my $pair = $p.split('=');
+ for $.env<psgi.input>.decode.split('&') -> $p {
+ my $pair = $p.split('=', 2);
%ret{$pair[0]} = uri_unescape $pair[1];
}
return %ret;
View
@@ -0,0 +1,16 @@
+use Test;
+use Bailador;
+use Bailador::Test;
+
+plan 3;
+
+post '/foo' => sub { request.env<psgi.input>.decode };
+
+my $data = 'hello=world&a=1;b=2';
+my $req = Bailador::Request.new_for_request('POST', '/foo');
+ $req.env<psgi.input> = $postdata.encode('utf-8');
+my $resp = Bailador::dispatch_request($req);
+
+lives_ok { eager $req.params<hello> }, 'Request data parses without dying';
+is ~$resp.content, $data, 'POST data string roundtrips correctly';
+is $req.params<a>, '1;b=2', 'application/x-www-form-urlencoded POST data should only split on &';

0 comments on commit a1159fa

Please sign in to comment.