Sha256: bf9621cc5c276fc059c2d8d7ba928e2d136d45bf478e0779b64cd95a5d740211

Contents?: true

Size: 875 Bytes

Versions: 4

Compression:

Stored size: 875 Bytes

Contents

require 'rack/utils'

module Grandstand
  class Session
    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/ && env['PATH_INFO'] =~ /^\/admin\/galleries\/\d+\/images$/
        params = Rack::Request.new(env).POST
        unless params['session_key'].nil?
          # This will strip out the session_key from the POST params - not entirely necessary,
          # but still cleaner than the alternative
          env['HTTP_COOKIE'] = [ @session_key, params.delete('session_key') ].join('=').freeze
          env['rack.input'] = StringIO.new(Rack::Utils::Multipart.build_multipart(params))
          env['rack.input'].rewind
        end
        puts "\n\n#{env['HTTP_COOKIE'].inspect}\n\n"
      end
      @app.call(env)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grandstand-0.2.4 lib/grandstand/session.rb
grandstand-0.2.3 lib/grandstand/session.rb
grandstand-0.2.2 lib/grandstand/session.rb
grandstand-0.2.1 lib/grandstand/session.rb