Slide 1

Slide 1 text

RUBY HTTP CLIENTS comparison by zoran.majstorovic@promdm.com Professional Mobile Device Management

Slide 2

Slide 2 text

RUBY HTTP CLIENTS • What they are? • Why do we need them? • Which one to choose for your next ruby project?

Slide 3

Slide 3 text

RUBY HTTP CLIENT • can be used in ruby code

Slide 4

Slide 4 text

RUBY HTTP CLIENT • can be used in ruby code • to perform HTTP requests

Slide 5

Slide 5 text

Hypertext Transfer Protocol -- HTTP/1.1 RFC 2616 Abstract The Hypertext Transfer Protocol (HTTP) is
 an application-level protocol for distributed,
 collaborative, hypermedia information systems.
 ... RUBY HTTP CLIENT

Slide 6

Slide 6 text

RUBY HTTP CLIENT RFC 2616 1.3 Terminology

Slide 7

Slide 7 text

A Service-Oriented Approach to System Design

Slide 8

Slide 8 text

https://gist.github.com/zmajstor/94b85c7821b129f71ad6 pure HTTP/1.1 RFC 2616 RUBY HTTP CLIENT github.com/ruby/ruby/blob/trunk/ext/socket/ socket.c ~2k LoC by Yukihiro Matsumoto

Slide 9

Slide 9 text

RUBY HTTP CLIENTS found in Gemfile.lock

Slide 10

Slide 10 text

Net::HTTP Typhoeus Faraday HTTParty Curb Patron HTTP.rb Rest- Client EM- HTTP- Request Excon HTTP
 Client RUBY HTTP CLIENTS The Universe of

Slide 11

Slide 11 text

about
 4 years ago by Hiroshi Nakamura http://bit.ly/RubyHTTPClients2012 RUBY HTTP CLIENTS

Slide 12

Slide 12 text

taxonomy based on library dependecy • Net::HTTP, HTTPClient based on TCPSocket (Ruby C library) • HTTParty, HTTP.rb, Rest-Client based on Net::HTTP • Typhoeus, Curb, Patron based on libcurl (C library) • EM-HTTP-Request, Excon based on eventmachine 
 (C++ library) • Faraday "the wrapper gem" with adapters for: 
 Net::HTTP (default), HTTPClient, Typhoeus, Patron, 
 EM-HTTP-Request, Excon RUBY HTTP CLIENTS

Slide 13

Slide 13 text


 
 
 
 
 
 
 
 
 
 TCPSocket
 Ruby C lib 
 libcurl C library Net::HTTP Typhoeus Faraday HTTParty Curb Patron HTTP.rb Rest- Client eventmachine C++ library EM- HTTP- Request Excon HTTP
 Client RUBY HTTP CLIENTS taxonomy
 based on library dependecy © 2016 Zoran Majstorović

Slide 14

Slide 14 text

Avdi's Survey http://devblog.avdi.org/2015/10/16/results-of-ruby-http-client-library-survey about RUBY HTTP CLIENTS

Slide 15

Slide 15 text

Avdi's Survey http://devblog.avdi.org/2015/10/16/results-of-ruby-http-client-library-survey 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

Slide 16

Slide 16 text

RUBY HTTP CLIENTS Avdi's Survey GithHub Stars * HTTParty 25.5% 3.661 Faraday 24.9% 3.119 Net::HTTP 12.7% - Rest-Client 10.9% 3.385 Typhoeus 6% 2.798 HTTPClient 5.2% 517 HTTP.rb 3.5% 1.540 Excon 3.3% 725 Curb 2.9% 973 Patron 0.9% 472 * GithHub Stars count on 01 June 2016

Slide 17

Slide 17 text

Code Samples for Top 5 HTTParty Faraday Net::HTTP Rest-Client Typhoeus RUBY HTTP CLIENTS

Slide 18

Slide 18 text

HTTParty

Slide 19

Slide 19 text

Faraday

Slide 20

Slide 20 text

Faraday adapters Survey GitHub Stars HTTParty 25.5% 3.661 Faraday 24.9% 3.119 Net::HTTP 12.7% - Rest-Client 10.9% 3.385 Typhoeus 6% 2.798 HTTPClient 5.2% 517 HTTP.rb 3.5% 1.540 Excon 3.3% 725 Curb 2.9% 973 Patron 0.9% 472 em-http-request - 3.661

Slide 21

Slide 21 text

Net::HTTP

Slide 22

Slide 22 text

Net::HTTP https://github.com/augustl/net-http-cheat-sheet

Slide 23

Slide 23 text

Rest-Client a simple DSL for accessing HTTP and REST resources

Slide 24

Slide 24 text

Typhoeus

Slide 25

Slide 25 text

Speed Tests RUBY HTTP CLIENTS https://github.com/httprb/http/blob/master/README.md

Slide 26

Slide 26 text

https://github.com/httprb/http/blob/master/README.md Speed Tests by @tarcieri RUBY HTTP CLIENTS

Slide 27

Slide 27 text

Speed Tests by @nahi

Slide 28

Slide 28 text

Speed Tests by @nahi

Slide 29

Slide 29 text

that's all thanks RUBY HTTP CLIENTS