argh invalid form authenticity token
i don't understand i am already sending both the session key and the authenticity token like so:
started POST "/test_cases/20/upload_script?authenticity_token=IeH8aJgyM1zgW50MXN9UMj1P2wXKO8ir6lvPr1By5ow=&_waftt2_session=BAh7CUkiD3Nlc3Npb25faWQGOgZFRiIlM2M2YTA3M2NjM2VkZDFmYzBiZTA3MTE2NWYwY2E3MTlJIhBfY3NyZl90b2tlbgY7AEZJIjFJZUg4YUpneU0xemdXNTBNWE45VU1qMVAyd1hLTzhpcjZsdlByMUJ5NW93PQY7AEZJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YjY5NzQ4YjI3NWYzYzJkOTI2NjE3YmI3NzM3ZTQ3NGM2MmFiNjJhY2U2MzI4ZWUwOTcyOWQ2Y2NkNTVlNzViZWI5ZmQzZjkxNGUxYmIzYTQ0MWQ0ODQ3YTVlMDY5YTMyZmFlMDQwMGVmN2NkYjRhZGFkMDgxYmFkOWQxOTJkZQY7AFRJ开发者_高级运维Ihh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkCSAI=--3833637df52e559ca3bb3eb6d0d6b5a611d82bf4"
and the whole session key is also being set in env['HTTP_COOKIE'] - yes the key and the value
what am i missing here?
I had exactly the same problem with swfupload.
As far as I can remember:
It happens because Flash doesn't set the cookie correctly in its first request (2nd and subsequent requests are OK). I used some Rack middleware to copy the session key into env['HTTP_COOKIE] but it didn't work as expected.
My invetigations led me to a bug in the Rack::Request object which prevents it from correctly setting cookies if env['HTTP_COOKIE'] is initially empty.
Here is the middleware code that eventually fixed it for me:
class FlashUploadMiddleware
def initialize(app,session_key)
@app = app
@session_key = session_key
end
def call(env)
env['HTTP_COOKIE'] = "bugfix=true" unless env['HTTP_COOKIE']
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
req = Rack::Request.new( env )
req.cookies[ @session_key ] = req["session_id"] unless req["session_id"].nil?
end
@app.call(env)
end
end
This class needs to be in a file called flash_upload_middleware.rb somewhere in your load path. It is initialised from an .rb file in config/initialisers
ActionController::Dispatcher.middleware.use(
FlashUploadMiddleware,
ActionController::Base.session_options[:key] )
精彩评论