Skip to content

Instantly share code, notes, and snippets.

@ckoehler
Created May 30, 2011 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckoehler/999572 to your computer and use it in GitHub Desktop.
Save ckoehler/999572 to your computer and use it in GitHub Desktop.
Faye fix for Firefox Bad Request
def message_from_request(request)
if request.post?
content_type = request.env['CONTENT_TYPE'].split(';').first
content = request.body.read
# if we get json, just return the body
if content_type == 'application/json'
return content
else
# we don't have JSON but something else, but it's not always in
# request.params['message']. In that case, parse the body ourselves
# and return it.
if request.params['message'].nil?
return Rack::Utils.parse_query(content)['message']
else
return request.params['message']
end
end
else
request.params['message']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment