Skip to content


MIT 18 4 1,218
247.3 thousand (month) Oct 25 2009 1.1.7(3 years ago)
1,152 19 24 MIT
0.110.0(24 days ago) Oct 31 2009 2.7 million (month)

em-http-request is a Ruby gem for making asynchronous HTTP requests using EventMachine. It allows you to perform multiple requests simultaneously and handle the responses as they come in, rather than waiting for each request to complete before making the next one.

In short it supports: - Asynchronous HTTP API for single & parallel request execution - Keep-Alive and HTTP pipelining support - Auto-follow 3xx redirects with max depth - Automatic gzip & deflate decoding - Streaming response processing - Streaming file uploads - HTTP proxy and SOCKS5 support - Basic Auth & OAuth - Connection-level & global middleware support - HTTP parser via http_parser.rb - Works wherever EventMachine runs: Rubinius, JRuby, MRI

Excon is a Ruby library for making HTTP requests. It is designed to be fast and efficient, and is often used as a building block for other Ruby libraries and frameworks.

One of the main features of Excon is its support for persistent connections, which allows it to reuse the same connection for multiple requests, reducing the overhead of establishing a new connection for each request.

Excon also supports streaming requests and responses, which allows you to read or write data to the server incrementally, without having to load the entire response into memory at once.

Example Use {
  http ='').get :query => {'keyname' => 'value'}

  # add callback for errors:
  http.errback { p 'Uh oh'; EM.stop }

  # add callback for successful requests
  http.callback {
    p http.response_header.status
    p http.response_header
    p http.response

require 'excon'

# GET requests
response = Excon.get('')
puts response.body
puts response.status
puts response.headers

# POST requests
response ='',
  :body => { :title => 'foo', :body => 'bar', :userId => 1 }.to_json,
  :headers => { 'Content-Type' => 'application/json' } )
puts response.body

Alternatives / Similar