Created
May 30, 2011 22:21
-
-
Save ckoehler/999572 to your computer and use it in GitHub Desktop.
Faye fix for Firefox Bad Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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