2009-06-02 00:08:57 +02:00
|
|
|
require 'rack/utils'
|
|
|
|
|
|
|
|
class FlashSessionCookieMiddleware
|
|
|
|
def initialize(app, session_key = '_session_id')
|
|
|
|
@app = app
|
|
|
|
@session_key = session_key
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
|
2010-09-17 17:57:33 +02:00
|
|
|
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?
|
2009-06-02 00:08:57 +02:00
|
|
|
end
|
2010-04-13 21:10:40 +02:00
|
|
|
|
2009-06-02 00:08:57 +02:00
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|