Permalink
Browse files

Merge pull request #231 from lawrencepit/cookies

Request should return cookies, also when initially not set.
  • Loading branch information...
2 parents d099ea0 + 02209e2 commit 1b7f7af86908858cfbcc1c1cadd95edb937b0e48 @raggi raggi committed Sep 16, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/rack/request.rb
  2. +9 −0 test/spec_request.rb
View
@@ -250,8 +250,8 @@ def cookies
hash = @env["rack.request.cookie_hash"] ||= {}
string = @env["HTTP_COOKIE"]
- hash.clear unless string
return hash if string == @env["rack.request.cookie_string"]
+ hash.clear
# According to RFC 2109:
# If multiple cookies satisfy the criteria above, they are ordered in
View
@@ -357,6 +357,15 @@
hash = req.cookies
req.env.delete("HTTP_COOKIE")
req.cookies.should.equal(hash)
+ req.env["HTTP_COOKIE"] = "zoo=m"
+ req.cookies.should.equal(hash)
+ end
+
+ should "modify the cookies hash in place" do
+ req = Rack::Request.new(Rack::MockRequest.env_for(""))
+ req.cookies.should.equal({})
+ req.cookies['foo'] = 'bar'
+ req.cookies.should.equal 'foo' => 'bar'
end
should "raise any errors on every request" do

0 comments on commit 1b7f7af

Please sign in to comment.