[ANN] HTTP (The Gem!) 1.0.0: a fast, elegant HTTP client for Ruby

1,020 views
Skip to first unread message

Tony Arcieri

unread,
Dec 25, 2015, 2:10:34 PM12/25/15
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API, ruby-talk ML
Merry Christmas! After 4 years, the "http" gem (a.k.a. http.rb) has finally hit 1.0:

    gem install http


http.rb provides an elegant, chainable interface for building HTTP requests, similar to Python's "Requests" library. Think JQuery for building HTTP requests. Its API is hopefully intuitive and just does what you expect (unlike, say, Net::HTTP).

This gem provides an almost pure Ruby implementation of the HTTP protocol, except for its use of http_parser.rb, which uses the Node.js HTTP parser written in C (and a Java port thereof on JRuby). This means http.rb has no reliance on Net::HTTP, and thanks to the native HTTP parser is faster than pure Ruby implementations of the HTTP protocol such as excon. It's use of a native parser is somewhat analogous to a client side Mongrel or Unicorn vs a pure Ruby WEBrick.

In the past year it's gained a number of features, most notably: support for persistent "keep-alive" connections and fine-grained timeouts implemented using asynchronous I/O instead of timeout.rb's thread-based approach. This gem is now the main client for service-to-service HTTP communication for Ruby apps at Square.

I'd like to thank Zach Anker for his many contributions to this library in the past year, as well as Alexey V. Zapparov and Erik Michaels-Ober for their ongoing contributions.

--
Tony Arcieri

KING SABRI

unread,
Dec 25, 2015, 5:05:31 PM12/25/15
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API, ruby...@ruby-lang.org
It's really the most elegant way of http things 

I wish this was used instead of open-uri std lib

Abhimanyu Aryan

unread,
Dec 27, 2015, 10:15:44 AM12/27/15
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
How can something written in Ruby be faster than written in C

From Github:

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

Tony Arcieri

unread,
Dec 27, 2015, 12:15:12 PM12/27/15
to Abhimanyu Aryan, http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
On Sun, Dec 27, 2015 at 7:15 AM, Abhimanyu Aryan <abhiman...@gmail.com> wrote:
How can something written in Ruby be faster than written in C

That's saying http.rb is the fastest (mostly) Ruby implementation of HTTP, aside from the parser being native code (C or Java).

The libraries that are faster than http.rb rely on C implementations of HTTP (e.g. curb, Typhoeus)

--
Tony Arcieri
Reply all
Reply to author
Forward
0 new messages