Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
H
httpx
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4
    • Issues 4
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 0
    • Merge Requests 0
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • HoneyryderChuck
  • httpx
  • Wiki
  • Compression

Last edited by HoneyryderChuck Oct 15, 2020
Page history

Compression

The compression plugin allows to reduce transferred data between client and server by enabling compression.

It also allows one to compress the body of requests.

By default it supports "gzip" and "deflate", but one can optionally use "br" by installing the brotli gem (caveat: it can't run in JRuby).

http = HTTPX.plugin(:compression)
http.get("https://www.google.com") #=> response with "content-type" as "gzip" or "deflate", response is decoded automatically

Compressing the request payload is a matter of just adding the content-encoding header with the desired compression (again, only supports the already mentioned ones):

http = HTTPX.plugin(:compression)
http.with(headers: {"content-encoding" => "gzip"}).post("https://filmupload.com", body: File.open("path/to/file"))

:compression_threshold_size

When set, it means: byte size threshold until which request payload won't be compressed.

Sometimes, most of your payloads are so small that there is no gain in compressing (in some cases the resulting compressed payload size is higher), so you'd like to activate it only when you see fit.

Next: Server Push

Clone repository
  • Authentication
  • Compression
  • Connections
  • Cookies
  • Custom Plugins
  • DNS Resolvers
  • Datadog Adapter
  • Debugging
  • Error Handling
  • Expect
  • FAQ
  • Faraday Adapter
  • Follow Redirects
  • H2C Upgrade
  • Make Requests
View All Pages