Skip to content
No GUI edited this page Apr 7, 2018 · 3 revisions

Automatic deflating

The HTTP.use(:auto_deflate) option can be used for automatically compressing the request body before writing it to the socket:

response = HTTP.use(:auto_deflate)
               .post("http://example.org/upload", body: body)

By default gzip encoding will be used, but deflate is also supported:

response = HTTP.use(:auto_deflate => {:method => :deflate})
               .post("http://example.org/upload", body: body)

Automatic inflating

The HTTP.use(:auto_inflate) option can be used for automatically decompressing the response body:

response = HTTP.use(:auto_inflate).headers("Accept-Encoding" => "gzip")
               .get("http://example.org/large-file")