Skip to content

bodrovis/faraday-gzip

 
 

Repository files navigation

Faraday Gzip

CI Gem Gem Total Downloads

The Gzip middleware for Faraday 1 and 2 adds the necessary Accept-Encoding headers and automatically decompresses the response. If the "Accept-Encoding" header isn't set in the request, it defaults to gzip,deflate and appropriately handles the server's compressed response. This functionality resembles what Ruby does internally in Net::HTTP#get. If Brotli is included in your Gemfile, the middleware also adds br to the header for Brotli support.

Prerequisites

This gem is tested with Ruby 2.7+ and JRuby 9.4+. It supports both Faraday 1 and 2.

Installation

Add this line to your application's Gemfile:

gem 'faraday-gzip', '~> 2'

And then execute:

bundle install

Or install it yourself as:

gem install faraday-gzip

Usage

To enable the middleware in your Faraday connection, add it as shown below:

require 'faraday/gzip' # <=== Add this line

conn = Faraday.new(...) do |f|
  f.request :gzip # <=== Add this line
  # Additional configuration...
end

Development

To contribute or make changes:

  • Clone the repo
  • Run bundle to install dependencies
  • Implement your feature
  • Write and run tests using rspec .
  • Use rake build to build the gem locally if needed
  • Create a new PR with your changes

Contributing

Bug reports and pull requests are welcome on GitHub.

License

This gem is available as open source under the terms of the MIT License.

About

The Gzip middleware for Faraday 1 and 2 adds appropriate Accept-Encoding headers and automatically decompresses supported, non-streaming response bodies.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages