I am running a Sinatra
app within an EventMachine.run
loop and in my ws.onopen
method I wish to check the handshake
heade
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.