Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

http

HTTP (The Gem! a.k.a. http.rb) - a fast Ruby HTTP client with a chainable API, streaming support, and timeouts

Subscribe to updates I use http


Statistics on http

Number of watchers on Github 1921
Number of open issues 40
Average time to close an issue 13 days
Main language Ruby
Average time to merge a PR 1 day
Open pull requests 20+
Closed pull requests 29+
Last commit about 1 year ago
Repo Created over 7 years ago
Repo Last Updated about 1 year ago
Size 1.39 MB
Organization / Authorhttprb
Contributors40
Page Updated
Do you use http? Leave a review!
View open issues (40)
View http activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating http for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

http.rb

Gem Version Build Status Code Climate Coverage Status MIT licensed

NOTE: This is the 4.x development branch. For the 3.x stable branch, please see:

https://github.com/httprb/http/tree/3-x-stable

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 http_parser.rb, a fast HTTP parsing native extension based on the Node.js parser and a Java port thereof. This library isn't just yet another wrapper around Net::HTTP. It implements the HTTP protocol natively and outsources the parsing to native extensions.

Another Ruby HTTP library? Why should I care?

There are a lot of HTTP libraries to choose from in the Ruby ecosystem. So why would you choose this one?

Top three reasons:

  1. Clean API: http.rb offers an easy-to-use API that should be a breath of fresh air after using something like Net::HTTP.

  2. Maturity: http.rb is one of the most mature Ruby HTTP clients, supporting features like persistent connections and fine-grained timeouts.

  3. Performance: using native parsers and a clean, lightweight implementation, http.rb achieves the best performance of any Ruby HTTP library which implements the HTTP protocol in Ruby instead of C:

| HTTP client | Time | Implementation | |--------------------------|--------|-----------------------| | curb (persistent) | 2.519 | libcurl wrapper | | em-http-request | 2.731 | EM + http_parser.rb | | Typhoeus | 2.851 | libcurl wrapper | | StreamlyFFI (persistent) | 2.853 | libcurl wrapper | | http.rb (persistent) | 2.970 | Ruby + http_parser.rb | | http.rb | 3.588 | Ruby + http_parser.rb | | HTTParty | 3.931 | Net::HTTP wrapper | | Net::HTTP | 3.959 | Pure Ruby | | Net::HTTP (persistent) | 4.043 | Pure Ruby | | open-uri | 4.479 | Net::HTTP wrapper | | Excon (persistent) | 4.618 | Pure Ruby | | Excon | 4.701 | Pure Ruby | | RestClient | 26.838 | Net::HTTP wrapper |

Benchmarks performed using excon's benchmarking tool

DISCLAIMER: Most benchmarks you find in READMEs are crap, including this one. These are out-of-date. If you care about performance, benchmark for yourself for your own use cases!

Help and Discussion

If you need help or just want to talk about the http.rb, visit the http.rb Google Group:

https://groups.google.com/forum/#!forum/httprb

You can join by email by sending a message to:

httprb+subscribe@googlegroups.com

If you believe you've found a bug, please report it at:

https://github.com/httprb/http/issues

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

Supported Ruby Versions

This library aims to support and is tested against the following Ruby versions:

  • Ruby 2.2.x
  • Ruby 2.3.x
  • Ruby 2.4.x
  • JRuby 9.1.x.x

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.

Contributing to http.rb

  • 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 (c) 2011-2018 Tony Arcieri, Alexey V. Zapparov, Erik Michaels-Ober, Zachary Anker. See LICENSE.txt for further details.

http open issues Ask a question     (View All Issues)
  • over 2 years config URI normalization by default
  • over 2 years Use http2bin.org
  • over 2 years Connection closes even though it's supposed to be a persistent connection.
  • over 2 years HTTP::Client overwrites body if it isn't read before another request is performed
  • almost 3 years read_nonblock with exception: false also return :wait_writable
  • almost 3 years http_proxy and https_proxy (and probably no_proxy) not supported out of the box
  • almost 3 years HTTP header injection
  • about 3 years Headers with leading underscore being rewritten to dashes
  • about 3 years Content-Length not being set for POST requests?
  • about 3 years ssl_context in default options
  • over 3 years HTTP::Session
  • over 3 years Extract asynchronous I/O layer (e.g. for Celluloid::IO support)
  • over 3 years API for connection auto-close
  • over 3 years Following redirects drops cookies.
  • over 3 years Nested URI params for GET requests not constructed properly
  • about 4 years Caching spport
  • about 4 years Refactor Options
  • about 4 years WebMock integration is broken
  • about 4 years Add support for events.
  • about 5 years Support for Gzip/Inflate
http open pull requests (View All Pulls)
  • Added update_timeout API to reconfigure timeouts on the fly
  • faster string manipulation in response status
  • Support extra non-assigned HTTP statuses
  • Support to log.
  • Add HTTP::Response#connection
  • connect_ssl uses connect_timeout (Closes #359)
  • loading proxy if set in the environment (http{s}_proxy variables, no_…
  • back to io/wait
  • [WIP] Convert async I/O backend to Socketry
  • Support for Gzip/Inflate
  • Enable request body streaming with an IO object
  • test uri behavior on travis
  • Return response body chunks in specified encoding
  • Make deflate work with any body
  • Fix query string building for string with newlines
  • Add pronunciation for httprb.
  • Remove http-form_data pre-release from gemspec
  • Fix HTTP parsing
  • Add support for dumping SSL master keys
  • Fix #readpartial not respecting max length argument
http questions on Stackoverflow (View All Questions)
  • HTTP digest authentication with HttpUrlConnection
  • Retrieve list of places using http get or post in android
  • External http connections fail (ports open)
  • Why I am getting this error: EEException: Server returned HTTP code: 404 using Google App Engine and Google Earth
  • HTTP 404 error while trying to browse web site created on IIS 7.5
  • How to password protect http://example.com:7474/webadmin
  • Wordpress adding extra slash to img url after http
  • HTTP POST and GET android facebook
  • Removing/Hiding/Disabling excessive HTTP response headers in Azure/IIS7 without UrlScan
  • Angular 2 Service Error - No provider for Http
  • HTTP Status 404 The requested resource is not available error despite tomcat running and jsp available?
  • Send HTTP request and receive HTTP response using javascript
  • Swagger gives me HTTP Error 403.14 - Forbidden
  • Write JSON to Solr via HTTP/Post
  • Can HTML imports be specified using the Link HTTP header, or only with a <link> tag?
  • AWS Elastic Beanstalk: HTTP Header not appearing in Flask application
  • MAMP PRO 3.5 having ssl turned on i only can configure the https variant but not the http
  • PHP CRON job, not output HTTP headers
  • HTTP Post request body marshaling for Play Framework
  • How to set default HTTP header in Angular2?
  • How to decrypt `.signed` when the encrypted value is found in the http header instead of in a cookie?
  • Problems with PayPal API Http call
  • How to make HTTP/2 requests via API
  • What is extension-method in http request per RFC
  • No mapping found for HTTP request with URI Spring MVC
  • HTTP Status 405 - Request method 'POST' not supported Spring Security Java Config
  • LibGDX http responses behaving differently when debugging from Eclipse
  • Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
  • What HTTP response code should be used for an OPTION request?
  • How to download a HTTP resource to a file with Akka Streams and HTTP?
http list of languages used
Other projects in Ruby