Forum: Ruby The HTTP Gem 0.5.0: HTTP (and streaming) should be easy!

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tony Arcieri (Guest)
on 2013-09-14 20:20
(Received via mailing list)
The HTTP Gem provides an easy-to-use JQuery-like chaining API for
constructing HTTP requests. It's similar to the Requests library from

    gem install http

Find it on Github at:

The HTTP Gem is also compatible with Celluloid::IO and can be used to
multiple parallel requests easily, similar to what you can do with gems
like Typhoeus.

Here's how you can write a parallel HTTP fetcher that runs in a single
thread using Celluloid::IO:

-- snip --

require 'celluloid/io'
require 'http'

class HttpFetcher

  include Celluloid::IO

  def fetch(url)
    HTTP.get(url, socket_class: Celluloid::IO::TCPSocket).response

fetcher =

urls = %w(

# Kick off a bunch of future calls to HttpFetcher to grab the URLs in
futures = { |u| [u, fetcher.future.fetch(u)] }

# Consume the results as they come in
futures.each do |url, future|
  # Wait for HttpFetcher#fetch to complete for this request
  response = future.value
  puts "Got #{url}: #{response.inspect}"

-- snip --

Full CHANGELOG follows:

* Add query string support
* New response delegator allows HTTP.get(uri).response
* HTTP::Chainable#stream provides a shorter alias for
* Better string inspect for HTTP::Response
* Curb compatibility layer removed
This topic is locked and can not be replied to.