diff options
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 9 |
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) |