Class: Uploader::FlashSessionCookieMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/uploader/middleware/flash_session_cookie_middleware.rb

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of FlashSessionCookieMiddleware.



5
6
7
8
# File 'lib/uploader/middleware/flash_session_cookie_middleware.rb', line 5

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
# File 'lib/uploader/middleware/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, 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