How to decode a cookie from the header of a websocket connection handshake? (Ruby)

前端 未结 1 1444
遇见更好的自我
遇见更好的自我 2020-12-19 15:16

I am running a Sinatra app within an EventMachine.run loop and in my ws.onopen method I wish to check the handshake heade

相关标签:
1条回答
  • 2020-12-19 15:57

    The answer is to use Rack::Utils.unencode.

    I now have this working

    Marshal.load(rack_cookie.coder.decode(Rack::Utils.unescape(bakesale.split('--').first))) decodes perfectly to the hash I need, allowing me to extract the user ID. W00t!

    Many thanks to User spastorino over at https://github.com/rack/rack/issues/551 for pointing me in the right direction.

    0 讨论(0)
提交回复
热议问题