Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bodrovis/faraday-gzip
The Gzip middleware for Faraday 1 and 2 adds the necessary Accept-Encoding headers and automatically decompresses the response
https://github.com/bodrovis/faraday-gzip
faraday gem ruby
Last synced: about 2 months ago
JSON representation
The Gzip middleware for Faraday 1 and 2 adds the necessary Accept-Encoding headers and automatically decompresses the response
- Host: GitHub
- URL: https://github.com/bodrovis/faraday-gzip
- Owner: bodrovis
- License: mit
- Created: 2022-02-03T17:16:38.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-18T14:50:35.000Z (2 months ago)
- Last Synced: 2024-07-18T18:46:13.320Z (2 months ago)
- Topics: faraday, gem, ruby
- Language: Ruby
- Homepage:
- Size: 42 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-faraday - gzip - decompress responses (needed for some non-default adapters) (Middleware)
README
# Faraday Gzip
![CI](https://github.com/bodrovis/faraday-gzip/actions/workflows/ci.yaml/badge.svg)
[![Gem](https://img.shields.io/gem/v/faraday-gzip.svg?style=flat-square)](https://rubygems.org/gems/faraday-gzip)
![Gem Total Downloads](https://img.shields.io/gem/dt/faraday-gzip)The `Gzip` middleware for Faraday 1 and 2 adds the necessary `Accept-Encoding` headers and automatically decompresses the response. If the "Accept-Encoding" header wasn't set in the request, this sets it to "gzip,deflate" and appropriately handles the compressed response from the server. This resembles what Ruby does internally in Net::HTTP#get. If [Brotli](https://github.com/miyucy/brotli) is added to the Gemfile, it will also add "br" to the header.
## Prerequisites
This gem is tested with Ruby 2.6+ and JRuby 9.3+. Faraday 1 and 2 is supported.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'faraday-gzip'
```And then execute:
```shell
bundle install
```Or install it yourself as:
```shell
gem install faraday-gzip
```## Usage
```ruby
require 'faraday/gzip' # <=== add this lineconn = Faraday.new(...) do |f|
f.request :gzip # <=== add this line
#...
end
```## Development
After checking out the repo, run `bin/setup` to install dependencies.
Then, run `bin/test` to run the tests.
To install this gem onto your local machine, run `rake build`.
To release a new version, make a commit with a message such as "Bumped to 0.0.2" and then run `rake release`.
See how it works [here](https://bundler.io/guides/creating_gem.html#releasing-the-gem).## Contributing
Bug reports and pull requests are welcome on GitHub.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).