Http.rb 0.7.0: a fast, streaming HTTP library with a chainable API

http.rb is an HTTP client library which exposes an easy-to-use chainable
API for constructing HTTP requests:

To install it:

gem install http

To use it:

require 'http'
HTTP.get("https://www.google.com").to_s

It’s that easy!

http.rb was previously named “The HTTP Gem” and located under “tarcieri”
on
Github, however we have rebranded and put it under its own organization
in
hopes of improving discoverability and SEO.

This library implements the HTTP protocol from-scratch without any
dependencies on Ruby’s Net::HTTP. It uses the http_parser.rb library, a
native extension containing the Node.js parser for CRubies and a Java
port
thereof for JRuby.

The entire library has been written from the ground up to support
end-to-end streaming.

The API is inspired in part by the Requests library from Python:

http://docs.python-requests.org/

Full change log below:

  • Fix handling of EOF which caused infinite loop. See #163, #166 and
    #152.
    (@mickm, @ixti)
  • Drop Ruby 1.8.7 support. (@ixti)
  • Fix default Host header value. See #150. (@ixti)
  • Remove BearerToken authorization header. (@ixti)
  • #auth sugar now accepts only string value of Authorization header.
    Calling #auth(:basic, opts) is deprecated, use #basic_auth(opts)
    instead.
    (@ixti)
  • Fix handling of chunked responses without Content-Length header.
    (@ixti)
  • Remove HTTP::Request#method and deprecate HTTP::Request#__method__
    (@sferik)
  • Deprecate HTTP::Response::STATUS_CODES,
    use HTTP::Response::Status::REASONS instead (@ixti)
  • Deprecate HTTP::Response::SYMBOL_TO_STATUS_CODE (@ixti)
  • Deprecate HTTP::Response#status_code (@ixti)
  • HTTP::Response#status now returns HTTP::Response::Status. (@ixti)
  • HTTP::Response#reason and HTTP::Response#code are proxies them
    to corresponding methods of HTTP::Response#status (@ixti)
  • Rename HTTP.with_follow to HTTP.follow and mark former one as
    being
    deprecated (@ixti)
  • Delegate HTTP::Response#readpartial to HTTP::Response::Body
    (@ixti)