A high-performance HTTP client for Ruby with TLS fingerprinting capabilities. This gem is a Ruby binding to the blazing-fast Rust rquest
HTTP client.
- Fast performance using Rust's
rquest
HTTP client - API compatible with http.rb
- Browser TLS fingerprinting support
- HTTP/2 support
- Thread-safe
Add this line to your application's Gemfile:
gem 'rquest-rb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rquest-rb
This gem is designed as a drop-in replacement for the http.rb gem. Here are some examples:
require 'rquest-rb'
# Simple GET request
response = HTTP.get("https://httpbin.org/get")
puts response.status # => 200
puts response.body # => JSON response body
# Adding custom headers
response = HTTP
.headers(accept: "application/json", user_agent: "My App/1.0")
.get("https://httpbin.org/headers")
# Chain methods together
response = HTTP
.headers(accept: "application/json")
.follow(true) # enable redirects
.get("https://httpbin.org/get")
# Using a proxy for requests
response = HTTP
.proxy("http://proxy.example.com:8080")
.get("https://httpbin.org/get")
# Chain proxy with other options
response = HTTP
.proxy("http://proxy.example.com:8080")
.headers(accept: "application/json")
.get("https://httpbin.org/get")
# Using proxy with authentication
response = HTTP
.proxy("http://username:password@proxy.example.com:8080")
.get("https://httpbin.org/get")
# POST with a body
response = HTTP.post(
"https://httpbin.org/post",
body: "This is the request body"
)
# POST with JSON
response = HTTP
.headers(content_type: "application/json")
.post(
"https://httpbin.org/post",
body: JSON.generate({ name: "Example", value: 123 })
)
# PUT request
HTTP.put("https://httpbin.org/put", body: "Updated content")
# DELETE request
HTTP.delete("https://httpbin.org/delete")
# HEAD request
HTTP.head("https://httpbin.org/get")
# PATCH request
HTTP.patch("https://httpbin.org/patch", body: "Patched content")
rquest-rb is designed to be a high-performance alternative to other Ruby HTTP clients. Here's how it compares:
The project includes benchmarks to compare rquest-rb with other popular Ruby HTTP clients.
$ bundle exec ruby benchmark/http_clients_benchmark.rb
This will run a benchmark making 5,000 requests to a test endpoint with concurrency, comparing multiple HTTP clients.
Recent benchmark results:
Comparison:
curb: 59.7 i/s
typhoeus: 47.6 i/s - 1.25x slower
rquest-rb: 19.5 i/s - 3.07x slower
http.rb: 10.6 i/s - 5.61x slower
httpx: 9.0 i/s - 6.64x slower
As shown above, curb is the fastest client, with typhoeus following closely. Rquest-rb provides excellent performance, significantly outperforming both http.rb and httpx in sequential operations.
Benchmarks are automatically run on every push to the master branch using GitHub Actions. This allows us to track performance over time and ensure rquest-rb maintains its performance advantage.
Benchmark charts are generated for multiple Ruby versions (2.7, 3.0, 3.1, 3.2, 3.3) to track performance across different Ruby implementations.
The following chart shows how rquest-rb compares to other HTTP clients across all tested Ruby versions:
As shown in our latest benchmarks, curb is the fastest client, with typhoeus being a close second. Rquest-rb provides excellent performance, significantly outperforming both HTTP.rb and httpx across all Ruby versions.
For performance charts of other Ruby versions, see the benchmark summary page.
Note: These charts are automatically generated during CI runs. The latest charts can be found in the GitHub Actions artifacts.
You can find historical benchmark results in the GitHub Actions artifacts. Each run stores:
- A detailed benchmark result for each Ruby version
- CSV files with historical benchmark data for each Ruby version
- Graphviz charts in PNG and SVG formats
To visualize benchmark history, download the benchmark-history-{ruby_version}.csv
artifact and use the provided script:
$ script/visualize_benchmarks.rb -f benchmark-history-2.7.csv
Options:
-f, --file FILE
- Specify the CSV file path-m, --metric TYPE
- Metric to visualize (time or requests_per_second)-l, --limit NUM
- Limit to last N entries
After checking out the repo, install dependencies and build the extension:
$ bundle install
$ bundle exec rake compile
To run tests:
$ bundle exec rake test
- Fork it
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -am 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Create a new Pull Request
The gem is available as open source under the terms of the MIT License.