Skip to content

Instantly share code, notes, and snippets.

@dsdstudio
Last active October 19, 2018 22:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dsdstudio/e8a51b950747238368cb25c62fb7b122 to your computer and use it in GitHub Desktop.
Rails request body gzip deflate

Rails5.x config/initializers/mime_types.rb

Mime::Type.register "gzip/json", :gzipjson

ActionDispatch::Http::Parameters::DEFAULT_PARSERS[:gzipjson] = lambda do |raw_body|
  body = ActiveSupport::Gzip.decompress(raw_body)
  JSON.parse(body)
end

ActionDispatch::Request.parameter_parsers = ActionDispatch::Request::DEFAULT_PARSERS

http client

  • add content type header Content-Type:gzip/json
  • add Content encoding header Content-Encoding:gzip
  • gzip inflate to request body
  • request !!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment