Skip to content

Commit

Permalink
Keep #params from merging POST into GET
Browse files Browse the repository at this point in the history
Signed-off-by: raggi <jftucker@gmail.com>
  • Loading branch information
skade authored and raggi committed May 3, 2011
1 parent b1388fd commit 91bbcea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/request.rb
Expand Up @@ -199,7 +199,7 @@ def POST

# The union of GET and POST data.
def params
self.GET.update(self.POST)
@params ||= self.GET.merge(self.POST)
rescue EOFError
self.GET
end
Expand Down
14 changes: 14 additions & 0 deletions test/spec_request.rb
Expand Up @@ -125,6 +125,20 @@
req.params.should.equal "foo" => "bar", "quux" => "bla"
end

should "not unify GET and POST when calling params" do
mr = Rack::MockRequest.env_for("/?foo=quux",
"REQUEST_METHOD" => 'POST',
:input => "foo=bar&quux=bla"
)
req = Rack::Request.new mr

req.params

req.GET.should.equal "foo" => "quux"
req.POST.should.equal "foo" => "bar", "quux" => "bla"
req.params.should.equal req.GET.merge(req.POST)
end

should "raise if rack.input is missing" do
req = Rack::Request.new({})
lambda { req.POST }.should.raise(RuntimeError)
Expand Down

0 comments on commit 91bbcea

Please sign in to comment.