lib/faye/adapters/rack_adapter.rb in faye-0.6.0 vs lib/faye/adapters/rack_adapter.rb in faye-0.6.1

- old
+ new

@@ -1,9 +1,10 @@ require 'rubygems' require 'json' require 'rack' require 'thin' +require 'cgi' require Faye::ROOT + '/thin_extensions' module Faye class RackAdapter @@ -95,16 +96,19 @@ end private def message_from_request(request) - if request.post? - content_type = request.env['CONTENT_TYPE'].split(';').first - content_type == 'application/json' ? - request.body.read : - request.params['message'] - else - request.params['message'] + return request.params['message'] unless request.post? + + # Some clients do not send a content-type, e.g. + # Internet Explorer when using cross-origin-long-polling + content_type = request.env['CONTENT_TYPE'] || '' + + case content_type.split(';').first + when 'application/json' then request.body.read + when 'text/plain' then CGI.parse(request.body.read)['message'][0] + else request.params['message'] end end def handle_upgrade(request) socket = Faye::WebSocket.new(request)