https://github.com/httprb/http
HTTP (The Gem! a.k.a. http.rb) - a fast Ruby HTTP client with a chainable API, streaming support, and timeouts
https://github.com/httprb/http
Keywords
client http http-client ruby
Keywords from Contributors
activerecord mvc activejob rack rubygems crash-reporting rspec rubocop background-jobs code-formatter
Last synced: about 2 hours ago
JSON representation
Repository metadata
HTTP (The Gem! a.k.a. http.rb) - a fast Ruby HTTP client with a chainable API, streaming support, and timeouts
- Host: GitHub
- URL: https://github.com/httprb/http
- Owner: httprb
- License: mit
- Created: 2011-10-06T04:19:10.000Z (over 14 years ago)
- Default Branch: main
- Last Pushed: 2026-04-20T18:20:44.000Z (10 days ago)
- Last Synced: 2026-04-27T19:33:01.972Z (3 days ago)
- Topics: client, http, http-client, ruby
- Language: Ruby
- Homepage:
- Size: 2.3 MB
- Stars: 3,088
- Watchers: 43
- Forks: 326
- Open Issues: 24
- Releases: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Security: SECURITY.md
README.md
About
HTTP (The Gem! a.k.a. http.rb) is an easy-to-use client library for making requests
from Ruby. It uses a simple method chaining system for building requests, similar to
Python's Requests.
Under the hood, http.rb uses the llhttp parser, a fast HTTP parsing native extension.
This library isn't just yet another wrapper around Net::HTTP. It implements the HTTP
protocol natively and outsources the parsing to native extensions.
Why http.rb?
-
Clean API: http.rb offers an easy-to-use API that should be a
breath of fresh air after using something like Net::HTTP. -
Maturity: http.rb is one of the most mature Ruby HTTP clients, supporting
features like persistent connections and fine-grained timeouts. -
Performance: using native parsers and a clean, lightweight implementation,
http.rb achieves high performance while implementing HTTP in Ruby instead of C.
Installation
Add this line to your application's Gemfile:
gem "http"
And then execute:
$ bundle
Or install it yourself as:
$ gem install http
Inside of your Ruby program do:
require "http"
...to pull it in as a dependency.
Documentation
Please see the http.rb wiki
for more detailed documentation and usage notes.
The following API documentation is also available:
Basic Usage
Here's some simple examples to get you started:
>> HTTP.get("https://github.com").to_s
=> "\n\n\n<!DOCTYPE html>\n<html lang=\"en\" class=\"\">\n <head prefix=\"o..."
That's all it takes! To obtain an HTTP::Response object instead of the response
body, all we have to do is omit the #to_s on the end:
>> HTTP.get("https://github.com")
=> #<HTTP::Response/1.1 200 OK {"Server"=>"GitHub.com", "Date"=>"Tue, 10 May...>
We can also obtain an HTTP::Response::Body object for this response:
>> HTTP.get("https://github.com").body
=> #<HTTP::Response::Body:3ff756862b48 @streaming=false>
The response body can be streamed with HTTP::Response::Body#readpartial.
In practice, you'll want to bind the HTTP::Response::Body to a local variable
and call #readpartial on it repeatedly until it returns nil:
>> body = HTTP.get("https://github.com").body
=> #<HTTP::Response::Body:3ff756862b48 @streaming=false>
>> body.readpartial
=> "\n\n\n<!DOCTYPE html>\n<html lang=\"en\" class=\"\">\n <head prefix=\"o..."
>> body.readpartial
=> "\" href=\"/apple-touch-icon-72x72.png\">\n <link rel=\"apple-touch-ic..."
# ...
>> body.readpartial
=> nil
Pattern Matching
Response objects support Ruby's pattern matching:
case HTTP.get("https://api.example.com/users")
in { status: 200..299, body: body }
JSON.parse(body.to_s)
in { status: 404 }
nil
in { status: 400.. }
raise "request failed"
end
Pattern matching is also supported on HTTP::Response::Status, HTTP::Headers,
HTTP::ContentType, and HTTP::URI.
Base URI
Set a base URI to avoid repeating the scheme and host in every request:
api = HTTP.base_uri("https://api.example.com/v1")
api.get("users") # GET https://api.example.com/v1/users
api.get("users/1") # GET https://api.example.com/v1/users/1
Relative paths are resolved per RFC 3986.
Combine with persistent to reuse the connection:
HTTP.base_uri("https://api.example.com/v1").persistent do |http|
http.get("users")
http.get("posts")
end
Thread Safety
Configured sessions are safe to share across threads:
# Build a session once, use it from any thread
session = HTTP.headers("Accept" => "application/json")
.timeout(10)
.auth("Bearer token")
threads = 10.times.map do
Thread.new { session.get("https://example.com/api/data") }
end
threads.each(&:join)
Chainable configuration methods (.headers, .timeout, .auth, etc.) return
an HTTP::Session, which creates a fresh HTTP::Client for every request.
Persistent connections (HTTP.persistent) return an HTTP::Session that pools
one HTTP::Client per origin. The session itself is not thread-safe. For
thread-safe persistent connections, use the
connection_pool gem:
pool = ConnectionPool.new(size: 5) { HTTP.persistent("https://example.com") }
pool.with { |http| http.get("/path") }
Cross-origin redirects are handled transparently — the session opens a separate
persistent connection for each origin encountered during a redirect chain:
HTTP.persistent("https://example.com").follow do |http|
http.get("/moved-to-other-domain") # follows redirect across origins
end
Supported Ruby Versions
This library aims to support and is [tested against][build-link]
the following Ruby versions:
- Ruby 3.2
- Ruby 3.3
- Ruby 3.4
- Ruby 4.0
If something doesn't work on one of these versions, it's a bug.
This library may inadvertently work (or seem to work) on other Ruby versions,
however support will only be provided for the versions listed above.
If you would like this library to support another Ruby version or
implementation, you may volunteer to be a maintainer. Being a maintainer
entails making sure all tests run and pass on that implementation. When
something breaks on your implementation, you will be responsible for providing
patches in a timely fashion. If critical issues for a particular implementation
exist at the time of a major release, support for that Ruby version may be
dropped.
Upgrading
See UPGRADING.md for a detailed migration guide between major versions.
Security
See SECURITY.md for reporting vulnerabilities.
Contributing to http.rb
See CONTRIBUTING.md for guidelines, or the quick version:
- Fork http.rb on GitHub
- Make your changes
- Ensure all tests pass (
bundle exec rake) - Send a pull request
- If we like them we'll merge them
- If we've accepted a patch, feel free to ask for commit access!
Copyright
Copyright © 2011-2026 Tony Arcieri, Erik Berlin, Alexey V. Zapparov, Zachary Anker.
See LICENSE.txt for further details.
Owner metadata
- Name: http.rb
- Login: httprb
- Email:
- Kind: organization
- Description: Projects implementing HTTP in pure Ruby
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/10374575?v=4
- Repositories: 5
- Last ynced at: 2024-03-25T20:35:05.614Z
- Profile URL: https://github.com/httprb
GitHub Events
Total
- Release event: 1
- Delete event: 12
- Pull request event: 18
- Fork event: 8
- Issues event: 43
- Watch event: 76
- Issue comment event: 63
- Push event: 54
- Gollum event: 1
- Pull request review event: 14
- Pull request review comment event: 10
- Create event: 13
Last Year
- Release event: 1
- Delete event: 12
- Pull request event: 13
- Fork event: 5
- Issues event: 38
- Watch event: 52
- Issue comment event: 44
- Push event: 51
- Pull request review comment event: 7
- Pull request review event: 8
- Create event: 13
Committers metadata
Last synced: 24 days ago
Total Commits: 1,289
Total Committers: 129
Avg Commits per committer: 9.992
Development Distribution Score (DDS): 0.666
Commits in past year: 104
Committers in past year: 5
Avg Commits per committer in past year: 20.8
Development Distribution Score (DDS) in past year: 0.115
| Name | Commits | |
|---|---|---|
| Aleksey V Zapparov | i****i@m****g | 430 |
| Tony Arcieri | b****e@g****m | 277 |
| Erik Berlin | s****k@g****m | 157 |
| Janko Marohnić | j****c@g****m | 47 |
| Sam Phippen | s****n@g****m | 39 |
| Bernard Lambeau | b****u@g****m | 34 |
| Peter Williams | p****a@b****g | 31 |
| Zach Anker | z****r@s****m | 26 |
| Tony Arcieri | t****i@s****m | 19 |
| Piotr Boniecki | p****r@p****m | 10 |
| jwinter | j****r@g****m | 9 |
| Paul Sadauskas | p****s@g****m | 9 |
| Juanito Fatas | k****0@g****m | 8 |
| Ezekiel Templin | z****e@t****n | 7 |
| Connor Dunn | c****d@s****m | 7 |
| Christian Schmidt | g****b@c****k | 5 |
| Jason Nochlin | h****t@g****m | 5 |
| Olle Jonsson | o****n@g****m | 5 |
| Ori Pekelman | o****i@p****m | 5 |
| Joshua Flanagan | j****n@g****m | 4 |
| Kyle King | k****g@g****m | 4 |
| Rick Song | r****g@g****m | 4 |
| Ryan Hosford | t****d@g****m | 4 |
| Bryan Powell | b****n@m****m | 4 |
| Tyler Montgomery | t****y@g****m | 3 |
| Smudge | n****n@n****m | 3 |
| Nicolas Leger | n****r | 3 |
| Mike Evans | m****e@u****m | 3 |
| Michael Gee | m****e@g****m | 3 |
| Matthew Witek | m****t@m****m | 3 |
| and 99 more... | ||
Committer domains:
- squareup.com: 5
- yandex.ru: 2
- beskow.de: 2
- rubycoder.pl: 1
- highstreetapp.com: 1
- benubois.com: 1
- alexcwatt.com: 1
- nopressure.co.uk: 1
- drewlee.com: 1
- mrhead.sk: 1
- swisscom.com: 1
- kurtisrainboltgreene.name: 1
- xing.com: 1
- merciless.me: 1
- me.com: 1
- mwitekdesign.com: 1
- urlgonomics.com: 1
- ngriffith.com: 1
- metabahn.com: 1
- pekelman.com: 1
- chsc.dk: 1
- templ.in: 1
- prograils.com: 1
- barelyenough.org: 1
- dnil.net: 1
- jyn.dev: 1
- bitserf.org: 1
- linusmarton.com: 1
- pobox.com: 1
- foca.io: 1
- starkast.net: 1
- ajsharma.com: 1
- dannyben.com: 1
- nestegg.com: 1
- ruders.org: 1
- 418sec.com: 1
- jc00ke.com: 1
- alotofnoodles.com: 1
- afroken.org: 1
- a16m.se: 1
- nevada.net.nz: 1
- abshere.net: 1
- envato.com: 1
- lecavelier.name: 1
- quantcast.com: 1
- tomify.me: 1
- restorm.com: 1
- legitscript.com: 1
- member.fsf.org: 1
Issue and Pull Request metadata
Last synced: about 1 month ago
Total issues: 91
Total pull requests: 117
Average time to close issues: over 1 year
Average time to close pull requests: 5 months
Total issue authors: 72
Total pull request authors: 60
Average comments per issue: 4.75
Average comments per pull request: 2.44
Merged pull request: 85
Bot issues: 0
Bot pull requests: 0
Past year issues: 11
Past year pull requests: 19
Past year average time to close issues: about 8 hours
Past year average time to close pull requests: 14 days
Past year issue authors: 9
Past year pull request authors: 6
Past year average comments per issue: 1.36
Past year average comments per pull request: 1.0
Past year merged pull request: 14
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- ixti (11)
- tarcieri (5)
- ksylvest (2)
- bkuhlmann (2)
- nomis (2)
- stoivo (2)
- shaicoleman (2)
- souk4711 (1)
- hugopassos (1)
- tablecell (1)
- james-em (1)
- unikitty37 (1)
- Linuus (1)
- chrismanderson (1)
- alanhala (1)
Top Pull Request Authors
- ixti (16)
- tarcieri (12)
- c960657 (7)
- hakanensari (5)
- benubois (4)
- sebyx07 (4)
- koheisg (3)
- bryanp (3)
- CallieAvery (2)
- drwl (2)
- tomprats (2)
- omkarmoghe (2)
- sferik (2)
- TheBlackArroVV (2)
- Bertg (2)
Top Issue Labels
- Improvement (10)
- Bug (6)
- Feature (4)
- Pick Me! (3)
- Security (3)
- Discussion (2)
- Not a bug (1)
- Regression (1)
- Question (1)
Top Pull Request Labels
- Feature (3)
- Discussion (1)
Package metadata
- Total packages: 13
-
Total downloads:
- rubygems: 395,399,707 total
- Total docker downloads: 3,641,498,960
- Total dependent packages: 814 (may contain duplicates)
- Total dependent repositories: 17,404 (may contain duplicates)
- Total versions: 316
- Total maintainers: 3
- Total advisories: 1
gem.coop: http
An easy-to-use client library for making requests from Ruby. It uses a simple method chaining system for building requests, similar to Python's Requests.
- Homepage: https://github.com/httprb/http
- Documentation: http://www.rubydoc.info/gems/http/
- Licenses: MIT
- Latest release: 6.0.2 (published about 1 month ago)
- Last Synced: 2026-04-06T16:21:34.002Z (24 days ago)
- Versions: 110
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 197,728,989 Total
- Docker Downloads: 1,820,749,480
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Downloads: 0.129%
- Average: 0.341%
- Stargazers count: 0.428%
- Forks count: 1.147%
- Maintainers (3)
rubygems.org: http
An easy-to-use client library for making requests from Ruby. It uses a simple method chaining system for building requests, similar to Python's Requests.
- Homepage: https://github.com/httprb/http
- Documentation: http://www.rubydoc.info/gems/http/
- Licenses: MIT
- Latest release: 6.0.2 (published about 1 month ago)
- Last Synced: 2026-04-05T22:00:55.946Z (25 days ago)
- Versions: 110
- Dependent Packages: 814
- Dependent Repositories: 17,404
- Downloads: 197,670,718 Total
- Docker Downloads: 1,820,749,480
-
Rankings:
- Dependent packages count: 0.059%
- Docker downloads count: 0.07%
- Downloads: 0.137%
- Dependent repos count: 0.272%
- Average: 0.449%
- Stargazers count: 0.657%
- Forks count: 1.502%
- Maintainers (3)
- Advisories:
proxy.golang.org: github.com/httprb/http
- Homepage:
- Documentation: https://pkg.go.dev/github.com/httprb/http#section-documentation
- Licenses: mit
- Latest release: v6.0.2+incompatible (published about 1 month ago)
- Last Synced: 2026-04-06T16:21:36.154Z (24 days ago)
- Versions: 86
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 6.999%
- Average: 8.173%
- Dependent repos count: 9.346%
ubuntu-24.04: ruby-http
- Homepage: https://github.com/httprb/http
- Licenses:
- Latest release: 4.4.1-5 (published 3 months ago)
- Last Synced: 2026-03-06T15:59:47.279Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-20.04: ruby-http
- Homepage: https://github.com/httprb/http
- Licenses:
- Latest release: 3.3.0-2 (published 3 months ago)
- Last Synced: 2026-03-13T20:24:29.437Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-10: ruby-http
- Homepage: https://github.com/httprb/http
- Documentation: https://packages.debian.org/buster/ruby-http
- Licenses:
- Latest release: 3.3.0-2 (published 3 months ago)
- Last Synced: 2026-03-13T19:04:01.711Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-22.04: ruby-http
- Homepage: https://github.com/httprb/http
- Licenses:
- Latest release: 4.4.1-5 (published 3 months ago)
- Last Synced: 2026-03-13T23:37:31.306Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-11: ruby-http
- Homepage: https://github.com/httprb/http
- Documentation: https://packages.debian.org/bullseye/ruby-http
- Licenses:
- Latest release: 4.4.1-4 (published 3 months ago)
- Last Synced: 2026-03-14T04:24:18.046Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.10: ruby-http
- Homepage: https://github.com/httprb/http
- Licenses:
- Latest release: 4.4.1-5 (published 3 months ago)
- Last Synced: 2026-03-14T03:14:33.389Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-http
- Homepage: https://github.com/httprb/http
- Licenses:
- Latest release: 4.4.1-5 (published 3 months ago)
- Last Synced: 2026-03-11T15:28:35.473Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-24.10: ruby-http
- Homepage: https://github.com/httprb/http
- Licenses:
- Latest release: 4.4.1-6 (published 3 months ago)
- Last Synced: 2026-03-09T17:06:31.756Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-http
- Homepage: https://github.com/httprb/http
- Documentation: https://packages.debian.org/bookworm/ruby-http
- Licenses:
- Latest release: 4.4.1-5 (published 3 months ago)
- Last Synced: 2026-03-13T03:29:03.951Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-13: ruby-http
- Homepage: https://github.com/httprb/http
- Documentation: https://packages.debian.org/trixie/ruby-http
- Licenses:
- Latest release: 4.4.1-6 (published 3 months ago)
- Last Synced: 2026-03-14T18:09:45.224Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- actions/checkout v3 composite
- coverallsapp/github-action v1.1.2 composite
- coverallsapp/github-action master composite
- ruby/setup-ruby v1 composite
- backports >= 0 development
- certificate_authority ~> 1.0 development
- fuubar >= 0 development
- guard-rspec >= 0 development
- kramdown >= 0 development
- nokogiri >= 0 development
- pry >= 0 development
- pry-byebug >= 0 development
- rspec ~> 3.10 development
- rspec-its >= 0 development
- rubocop ~> 1.30.0 development
- rubocop-performance >= 0 development
- rubocop-rake >= 0 development
- rubocop-rspec >= 0 development
- simplecov >= 0 development
- simplecov-lcov >= 0 development
- yard >= 0 development
- yardstick >= 0 development
- rake >= 0
- webrick >= 0
- bundler ~> 2.0 development
- addressable ~> 2.8
- http-cookie ~> 1.0
- http-form_data ~> 2.2
- llhttp-ffi ~> 0.4.0
Score: 35.021580762674816
