A plethora of HTTP clients
Nothing embodies "the more the merrier" better than Ruby's HTTP client ecosystem. There are dozens of libraries to choose from, each with its own unique features and quirks. To name a few:
- net-http - the one in the Ruby standard library
- rest-client - once set the bar with its seductively simple API, only to lose steam about a decade ago
- httparty - makes HTTP fun again, allegedly
- typhoeus - a wrapper around ethon, has an unspellable name
- ethon - a wrapper around libcurl, but you only really use this via typhoeus
- async-http - for those who actually figured out what the fiber scheduler is all about
- em-http-request - remember eventmachine?
- http - the one whose name is the envy of all the others
- excon - that one used by the Heroku SDK
- faraday - a wrapper around all the others, so that you don't have to choose
- httpi - like faraday, but deprecated
- seahorse - the one that doesn't show up in your dependency tree, but does HTTP in the AWS SDK
- httpx - the one made to rule them all, only it came too late to gain traction
It's perhaps the one area where Ruby can rival the npm for options. Having so many choices is really just fantastic. It means that you can pick the right tool for the job.
Which one to choose?
Well, odds are at least a handful of these are in your dependency tree via transitive dependencies already, so go ahead and try them out, see what sticks.
History
net-http, which started it all, was introduced in Ruby 1.4.4 in 2000.
We really owe it to the core team for creating such a universally unpopular HTTP client. Without net-http, there would have been no need for the others to exist, and we would have been stuck with a single option for all our HTTP needs.
Tomorrow, on the 2nd of April, we'll return to our regular programming with some... actual more reasons to love Ruby 🫶