From 1989b20c163e2e344556b4f64e566afb96e93d50 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 6 Aug 2015 07:57:33 -0700 Subject: ask the request for the cookie jar this prevents the middleware from knowing the specific key for the jar --- actionpack/lib/action_dispatch/middleware/cookies.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch') 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) -- cgit v1.2.3