Skip to content

Instantly share code, notes, and snippets.

@dsdstudio

dsdstudio/t0.md

Last active Oct 19, 2018
Embed
What would you like to do?
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