aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-06 07:57:33 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-06 07:57:33 -0700
commit1989b20c163e2e344556b4f64e566afb96e93d50 (patch)
treed386cea5896e0584097ac6eb0b5a952760f00fc6 /actionpack/lib/action_dispatch
parent447c2cb1b0684c6efcfe1063222d537567fa1d3e (diff)
downloadrails-1989b20c163e2e344556b4f64e566afb96e93d50.tar.gz
rails-1989b20c163e2e344556b4f64e566afb96e93d50.tar.bz2
rails-1989b20c163e2e344556b4f64e566afb96e93d50.zip
ask the request for the cookie jar
this prevents the middleware from knowing the specific key for the jar
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 4e3a2fb637..dac9dd2fe7 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -12,6 +12,10 @@ module ActionDispatch
end
# :stopdoc:
+ def have_cookie_jar?
+ env.key? 'action_dispatch.cookies'.freeze
+ end
+
def cookie_jar=(jar)
env['action_dispatch.cookies'.freeze] = jar
end
@@ -601,9 +605,12 @@ module ActionDispatch
end
def call(env)
+ request = ActionDispatch::Request.new env
+
status, headers, body = @app.call(env)
- if cookie_jar = env['action_dispatch.cookies']
+ if request.have_cookie_jar?
+ cookie_jar = request.cookie_jar
unless cookie_jar.committed?
cookie_jar.write(headers)
if headers[HTTP_HEADER].respond_to?(:join)