Ruby HTTP clients
Full Stack Landscape
Report by Hiroshi Nakamura
http://bit.ly/RubyHTTPClients2012
http://jvns.ca/blog/2016/03/04/whats-up-with-ruby-http-libraries/
Taxonomy by Hiroshi Nakamura
http://bit.ly/RubyHTTPClients2012
My Taxonomy
• gems based on TCPSocket (a Ruby C library):

Net::HTTP (built-in Ruby) , HTTPClient
• gems based on eventmachine (C++ library):

EM-HTTP-Request, Excon
• 3 groups of "wrapper gems":
• HTTParty, HTTP.rb, Rest-Client use Net::HTTP as "backend"
• Typhoeus, Curb, Patron use libcurl (a C library)
• Faraday have adapter for: Net::HTTP (default), HTTPClient,
EM-HTTP-Request, Excon, Typhoeus, Patron
Avdi's Survey
http://devblog.avdi.org/2015/10/16/results-of-ruby-http-client-library-survey/
Avdi's Survey (Top 10)
• HTTParty "simplicity and ease of use"
• Faraday "ability to modify its behavior with middlewares, swap backend libraries"
• Net::HTTP "built-in, no extra dependency, robustness and stability"
• Rest-Client “easy api, just works, can do file uploads”
• HTTPClient “thread-safe, uses keepalive, fast, supports http streaming.”
• Excon “easy to use, customize, easy to handle errors, has feature to debug”
• HTTP.rb “thread safety (jRuby), a sane API for SSL (e.g. mutual auth)”
• Typhoeus “concurrent requests and multipart posts actually work.”
• Curb “benchmarks showed that curb is by far the fastest one.”
• Patron “nicer API than Curb, easy to set timeout, easy to log and do REST actions.”
http://devblog.avdi.org/2015/10/16/results-of-ruby-http-client-library-survey/
Popularity (Top 5)
Survey Stars
HTTParty 25.5% 3.569
Faraday 24.9% 3.027
Net::HTTP 12.7% -
Rest-Client 10.9% 3.258
Typhoeus 6% 2.737
HTTPClient 5.2% 501
HTTP.rb 3.5% 1.206
Excon 3.3% 710
Curb 2.9% 945
Patron 0.9% 466
Samples
for Top 5
HTTParty
Faraday
Faraday adapters
Survey Stars
HTTParty 25.5% 3.569
Faraday 24.9% 3.027
Net::HTTP 12.7% -
Rest-Client 10.9% 3.258
Typhoeus 6% 2.737
HTTPClient 5.2% 501
HTTP.rb 3.5% 1.206
Excon 3.3% 710
Curb 2.9% 945
Patron 0.9% 466
em-http-request - 1.064
Rest-Client
a simple DSL for accessing HTTP and REST resources
Typhoeus
Speed Test by @nahi
Speed Test by @nahi
Speed Test by @tarcieri
https://github.com/httprb/http/blob/master/README.md
Net::HTTP implementation
The Simples HTTP Get
require 'net/http'

puts Net::HTTP.get('www.google.com', '/')
"pure TCP socket" HTTP GET

(without Net::HTTP)

based on RFC 2616
https://gist.github.com/zmajstor/
94b85c7821b129f71ad6
https://github.com/ruby/ruby/blob/
trunk/ext/socket/socket.c
TCPServer - TCPSocket
https://gist.github.com/
zmajstor/
94b85c7821b129f71ad6
The End

Ruby HTTP clients

  • 1.
    Ruby HTTP clients FullStack Landscape
  • 2.
    Report by HiroshiNakamura http://bit.ly/RubyHTTPClients2012 http://jvns.ca/blog/2016/03/04/whats-up-with-ruby-http-libraries/
  • 3.
    Taxonomy by HiroshiNakamura http://bit.ly/RubyHTTPClients2012
  • 4.
    My Taxonomy • gemsbased on TCPSocket (a Ruby C library):
 Net::HTTP (built-in Ruby) , HTTPClient • gems based on eventmachine (C++ library):
 EM-HTTP-Request, Excon • 3 groups of "wrapper gems": • HTTParty, HTTP.rb, Rest-Client use Net::HTTP as "backend" • Typhoeus, Curb, Patron use libcurl (a C library) • Faraday have adapter for: Net::HTTP (default), HTTPClient, EM-HTTP-Request, Excon, Typhoeus, Patron
  • 5.
  • 6.
    Avdi's Survey (Top10) • HTTParty "simplicity and ease of use" • Faraday "ability to modify its behavior with middlewares, swap backend libraries" • Net::HTTP "built-in, no extra dependency, robustness and stability" • Rest-Client “easy api, just works, can do file uploads” • HTTPClient “thread-safe, uses keepalive, fast, supports http streaming.” • Excon “easy to use, customize, easy to handle errors, has feature to debug” • HTTP.rb “thread safety (jRuby), a sane API for SSL (e.g. mutual auth)” • Typhoeus “concurrent requests and multipart posts actually work.” • Curb “benchmarks showed that curb is by far the fastest one.” • Patron “nicer API than Curb, easy to set timeout, easy to log and do REST actions.” http://devblog.avdi.org/2015/10/16/results-of-ruby-http-client-library-survey/
  • 7.
    Popularity (Top 5) SurveyStars HTTParty 25.5% 3.569 Faraday 24.9% 3.027 Net::HTTP 12.7% - Rest-Client 10.9% 3.258 Typhoeus 6% 2.737 HTTPClient 5.2% 501 HTTP.rb 3.5% 1.206 Excon 3.3% 710 Curb 2.9% 945 Patron 0.9% 466
  • 8.
  • 9.
  • 10.
  • 11.
    Faraday adapters Survey Stars HTTParty25.5% 3.569 Faraday 24.9% 3.027 Net::HTTP 12.7% - Rest-Client 10.9% 3.258 Typhoeus 6% 2.737 HTTPClient 5.2% 501 HTTP.rb 3.5% 1.206 Excon 3.3% 710 Curb 2.9% 945 Patron 0.9% 466 em-http-request - 1.064
  • 12.
    Rest-Client a simple DSLfor accessing HTTP and REST resources
  • 13.
  • 14.
  • 15.
  • 16.
    Speed Test by@tarcieri https://github.com/httprb/http/blob/master/README.md
  • 17.
  • 18.
    The Simples HTTPGet require 'net/http'
 puts Net::HTTP.get('www.google.com', '/') "pure TCP socket" HTTP GET
 (without Net::HTTP)
 based on RFC 2616 https://gist.github.com/zmajstor/ 94b85c7821b129f71ad6 https://github.com/ruby/ruby/blob/ trunk/ext/socket/socket.c
  • 19.
  • 20.