Excon is a simple HTTP 1.1 client for Ruby

Excon is a simple HTTP 1.1 client for Ruby
Average rating: 1
(1 votes)

Thanks! You’ve rated this material!

Ruby is all about simplicity. But even using Ruby you can find some solutions that will make your routine even simpler! Today we prepared something special for you. Excited? Excon is a simple HTTP 1.1 client for Ruby.

Excon was designed to be simple, fast and performant. It works great as a general HTTP client and is well suited to usage in API clients.

The easiest way to get started is by using one-off requests. Supported one-off request methods are connectdeletegetheadoptionspostput, and trace. Requests return a response object which has bodyheadersremote_ip and status attributes.

For API clients or other ongoing usages, reuse a connection across multiple requests to share options and improve performance.

connection = Excon.new('http://geemus.com')
get_response = connection.get
post_response = connection.post(:path => '/foo')
delete_response = connection.delete(:path => '/bar')

By default, each connection is non-persistent. This means that each request made against a connection behaves like a one-off request. Each request will establish a socket connection to the server, then close the socket once the request is complete.

You can make use of HTTP pipelining to improve performance. Instead of the normal request cycle. You can take advantage of this using the requestsmethod, which takes an array of params where each is a hash like a request would receive and returns an array of responses.

Please find more detailed information here.

And some awesome news about one famous book you have to read. Meet ‘The Well-Grounded Rubyist‘. The 3rd edition.

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

*By submitting this form you agree with our Privacy Policy.

Mailing & Legal Address

Syndicode Inc. 340 S Lemon Ave #3299, Walnut CA, 91789, USA

Visiting & Headquarters address
Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
Email info@syndicode.com
Phone (+1) 9035021111