Skip to content

exconvshttp.rb

MIT 27 19 1,154
2.8 million (month) Oct 31 2009 0.110.0(4 months ago)
2,994 10 95 NA
Mar 20 2015 447 (month) 0.12.0(6 years ago)

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.

http is an HTTP library for Ruby, it's a fork of the Ruby standard library Net::HTTP. It is designed to provide a more modern and consistent API for making HTTP requests and handling responses.

One of the main goals of http is to simplify the process of making HTTP requests and handling responses. It provides a consistent API for making requests and handling responses across different versions of Ruby and different HTTP libraries, making it easier to write cross-compatible code.

http supports all the standard HTTP methods such as GET, POST, PUT, DELETE, and PATCH, and allows you to set headers, query parameters, and request bodies.

Example Use


require 'excon'

# GET requests
response = Excon.get('https://jsonplaceholder.typicode.com/posts/1')
puts response.body
puts response.status
puts response.headers

# POST requests
response = Excon.post('https://jsonplaceholder.typicode.com/posts',
  :body => { :title => 'foo', :body => 'bar', :userId => 1 }.to_json,
  :headers => { 'Content-Type' => 'application/json' } )
puts response.body
require 'http'

# GET request
response = HTTP.get("http://httpbin.org/get")
puts response.body
puts response.status
puts response.headers

# POST request
response = HTTP.post("http://httpbin.org/post", json: { title: 'foo', body: 'bar', userId: 1 })
puts response.body

Alternatives / Similar


Was this page helpful?