Skip to content

Commit

Permalink
Fixes to Request.params
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Parsons committed Oct 27, 2012
1 parent bdf4db6 commit a1159fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Bailador/Request.pm
Expand Up @@ -5,8 +5,8 @@ class Bailador::Request {


method params { method params {
my %ret; my %ret;
for $.env<psgi.input>.split('&') -> $p { for $.env<psgi.input>.decode.split('&') -> $p {
my $pair = $p.split('='); my $pair = $p.split('=', 2);
%ret{$pair[0]} = uri_unescape $pair[1]; %ret{$pair[0]} = uri_unescape $pair[1];
} }
return %ret; return %ret;
Expand Down
16 changes: 16 additions & 0 deletions t/05-post-content.t
@@ -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.