Class: FlashSessionCookieMiddleware

Inherits:
Object
  • Object
show all
Defined in:
app/middlewares/flash_session_cookie_middleware.rb,
lib/middlewares/flash_session_cookie_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, session_key = '_session_id') ⇒ FlashSessionCookieMiddleware

Returns a new instance of FlashSessionCookieMiddleware.



4
5
6
7
# File 'app/middlewares/flash_session_cookie_middleware.rb', line 4

def initialize(app, session_key = '_session_id')
  @app = app
  @session_key = session_key
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'app/middlewares/flash_session_cookie_middleware.rb', line 9

def call(env)
  if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
    req = Rack::Request.new(env)
    env['HTTP_COOKIE'] = [ @session_key, ::Rack::Utils.escape(req.params[@session_key]) ].join('=').freeze unless req.params[@session_key].nil?
    env['HTTP_ACCEPT'] = "#{req.params['_http_accept']}".freeze unless req.params['_http_accept'].nil?
  end

  @app.call(env)
end