Search code examples
ruby-on-railsrubygzipthin

Thin GZIP decode on local machine


I'm using thin as a Rails server, and I want to send some JSON data gzipped, but in localhost it falls with MultiJson error (unknown symbols).

How can I enable gzip support for local thin using without nginx or apache?

Error text:

15:46:09 web.1     | Started PUT "/api/me" for 192.168.192.8 at 2011-11-25 15:46:09 +0600
15:46:09 web.1     | Error occurred while parsing request parameters.
15:46:09 web.1     | Contents:
15:46:09 web.1     | 
15:46:09 web.1     | 
15:46:09 web.1     | MultiJson::DecodeError (743: unexpected token at ''):

Solution

  • Rack includes a middleware called Rack::Deflater which is what you want.

    include config.middleware.use Rack::Deflater in your config/application.rb