00:00:14.360
so my name is he or she Nakamura and my
00:00:19.410
name is nahi at twitter and github and i'm working at a burial and doing
00:00:26.099
she'll be and Jerry development at my off time and i'm a member as excel dot
00:00:32.940
i'll be we having a week limited and so
00:00:39.780
when you came to when you come to Tokyo Japan please join us you can contact
00:00:46.250
form here today I'll introduce the matrix i created the that shows the
00:00:54.930
advantages and disadvantages of comparison of rubies HTTP client
00:01:00.629
libraries you can see the whole matrix from this URL and please take care to
00:01:10.229
refer this matrix because i'm the author one of those HTTP client it should be
00:01:19.259
client this is agenda at first i'll
00:01:25.409
provide a brief introduction to net HTTP internal and i show 16 Ruby HTTP client
00:01:35.970
libraries I picked and explain the matrix in detail APA style compatibility
00:01:42.990
and supported features and I also provide a performance comparisons and at
00:01:50.340
the last i'll show you my recommendations of loopy HTTP client for
00:01:55.530
purposes this is the class diagram of
00:02:01.229
net HTTP it has HTTP class that
00:02:07.380
represents the common Shin to a server and it has HTTP
00:02:12.690
requests that representing requests and HTTP response for the response to there
00:02:20.850
are lots of derived classes of request and response but these three classes
00:02:30.620
implements the all of net HTTP features
00:02:36.080
do you know what next HTTP proxies it
00:02:41.340
was a class but it now the method that
00:02:48.030
returns the crafted HTTP object that utilizes the proxy connection and it
00:02:55.830
also has net HTTPS lively but all that all it does is require net HTTP and
00:03:04.010
require openssl it's it locates only for
00:03:09.930
backward compatibility now and this simplicity of class and complexity of
00:03:17.790
the implementation causes is the root cause of why developers want to write
00:03:25.950
their own Ruby HTTP client libraries I guess he's 16 it should be great liar
00:03:35.820
libraries I picked their has four groups the first group of green is original
00:03:43.440
implementation it's a nap HTTP is a standard library as I said and II XCOM
00:03:50.280
and HTTP client are the pure ruby implementation an e/m HTTP request is a
00:03:57.030
event machine-based original implementation the second group is HTTP
00:04:03.600
whoppers opening a lie is also a standard library of ruby and HDD party
00:04:11.459
machen eyes roofs burbs west crying and west free a serving is she ull robbers
00:04:21.650
does she you are B and pattern and the
00:04:26.750
last one of leg is adaptable implementation that offers developers to
00:04:36.620
choose the back end HTTP engine and it
00:04:43.270
there are rest and weary and the Faraday and HTTP I sorry there are many HTTP
00:04:56.990
client libraries I didn't evaluate and these are the edge of the client
00:05:04.699
libraries I cannot evaluate because active resource of the reigns is raised
00:05:10.490
to raise specific and HTTP is under development and HTTP requests dot our
00:05:17.360
way it's test doesn't pass and also net nestful has noticed and typhus is one of
00:05:26.900
GU our beloved and it's under heavy writing now so I cannot evaluate this
00:05:35.050
HTTP client and these are I didn't
00:05:40.909
evaluate because these live geez Jen's
00:05:46.330
and updated recently so I think those libraries are obsolete evaluating access
00:05:57.940
project starts and APA style compatibility supported features
00:06:03.949
connection features basic HTTP features and the song and i created a test unit
00:06:11.240
script for the so checking these supported features so you can if you
00:06:16.880
want you can try the test from this URL and this script shows you how you can
00:06:26.000
use the specific feature like
00:06:32.700
pausing March platform and their skills and proxy authentication you can see
00:06:39.150
these tests at the example first I start
00:06:46.140
from project starts these is these 16
00:06:52.640
libraries I evaluated and here is a maintainer and are there anyone in this
00:07:02.700
room I think yeah eric is okay and and I
00:07:09.510
am the author of HTTP client and eric is the maintainer of merchandise and we
00:07:19.920
restate the risk client and rest a are
00:07:24.960
not updated this year two thousand from 2011 so you may need to find latest
00:07:34.760
development folk from github if you want to use these libraries and these starts
00:07:43.200
at get heaven rubygems there are four libraries HD party mechanized respond
00:07:49.740
and fall day those has thousand of get hipsters and hundreds of github folks
00:07:57.270
and millions of downloads next is APA
00:08:04.950
style I summarize the APA style to synchronous and asynchronous and
00:08:12.210
parallel and all of HTTP client libraries had synchronous API I've
00:08:20.250
introduced the all of the APA style and fast it's the synchronous a period such
00:08:26.970
you toys the client instance with these
00:08:33.320
gems developer need to instantiate the client from the provided class and
00:08:43.470
developer can issue the HTTP request from the created instance the next one
00:08:51.780
is client class with this client with these libraries user developer in user
00:09:01.980
issues HTTP request form as the class method but in the inside the class
00:09:10.560
methods instances the internal client instance so there's nothing different
00:09:17.520
from the previous APA style the sunrise whistles with these APR libraries
00:09:27.740
developer instances the results with URL
00:09:32.910
then developer can issue request and the
00:09:38.970
instant method of the created resource without passing the whole URL every time
00:09:46.430
the fourth line is include with these libraries developer can create their own
00:09:56.060
customized HTTP client class like this and use use the utility methods and
00:10:07.470
features from inside of the customized class the last one others opening ally
00:10:15.990
offers like this API and rest is addressing a little bit funny API like
00:10:27.060
this it starts with the ull towing and combative to you li Xing user can issue
00:10:35.580
the HTTP requests at the instance method
00:10:41.460
of the ula object next is a synchronous one the post- call back in HTTP request
00:10:52.100
with HTTP request instances the request but the rig is not
00:10:59.450
issued at this time and developer define the callback for successful lick west
00:11:06.320
and Iran us requests then event machines main slit issues the HTTP requests and
00:11:16.460
when we get finished it involves the either of this callback so developer
00:11:23.120
needs to implement their logics with
00:11:31.280
this callback style the next one is polling with this API client library
00:11:40.670
offers a synchronous API it this is a sample form HTTP client it developer
00:11:49.730
issues this a synchronous APR instead of synchronous one and it returns the
00:11:54.890
connection object developer can poll it's the it requests that it requests
00:12:04.790
finished or not and when a connection is finished developer can with the response
00:12:12.770
from the connection object those lines parallel API govt has imperil API that
00:12:23.800
issues the request all of the requests in simultaneously there are mulk object
00:12:33.350
and developer can add the HTV request to
00:12:38.540
multiple of multi object and the requests are issued at this perform
00:12:47.090
method invocation so the some libraries
00:12:56.510
has a synchronous API and govt has imperil API for mulch leading almost all
00:13:05.380
support multi threading so developer don't need to care about the
00:13:11.210
sweat but net net HTTP and pedal need
00:13:17.080
developer to instantly the object padlet so you need to care this most rate
00:13:24.200
environment there are hundred almost always exceptions wing error happens but
00:13:31.450
with for recipe developer can configure
00:13:36.830
to return error object in Saddam rising exception e m HTTP request requires the
00:13:46.130
rapper back as I shown you before the
00:13:51.440
next is compatibility all of the
00:13:57.890
libraries runs fine on Shelby of course and except she ull extension Lance fine
00:14:08.180
on JRuby as well jerry has C X support
00:14:14.500
experimental CX support but I mark this no because I think it's experimental and
00:14:22.880
I guess it won't be exit from experimental status so if you want to
00:14:31.430
use your application as well as Shelby
00:14:36.830
you should use other HTTP client and for
00:14:42.890
Rubinius patron fails running my test
00:14:47.960
but I think it should work and it should be fixed easily I think there's
00:14:54.500
something bugging patron lower revenues the load connection features in HDD be
00:15:06.200
there are three connection types I explain it first first one is no
00:15:13.490
keepalive collection no with notable connexion client and server create the
00:15:20.030
socket for each HTTP requests and with people I'm
00:15:26.660
collection client and server can use the same connection for multiple requests so
00:15:37.279
it's a little bit officiant for naughty not needed needing socket creation and
00:15:45.589
circuit destruction and for pipelining client don't need to wait the response
00:15:54.589
comes before issuing the next week left and as you see this it's very efficient
00:16:02.710
in contrast to keep alive connections but i think this pipelining processing
00:16:11.900
is difficult so and many web service
00:16:21.230
like apache doesn't support this pipelining request so when you want to
00:16:28.250
use pipelining from you it should be client you should take care if the
00:16:35.150
server supports pipelining or not so and
00:16:40.459
the keepalive is supported on me channels and IM HTTP requests it should
00:16:45.709
be client she will be paid long and fall day and pipelining is supported on en
00:16:52.070
HTTP requests and she will be I show you the keep alive in HTTP requests for for
00:17:03.560
keep a love connection you need to wait the fast response cams before sending
00:17:08.809
the second request so the second request must issued from the first goal box
00:17:14.000
serve the request from second callback so you need to write this kind of cold
00:17:21.020
so I think you don't want to use it in contrast street yeah well pipelining is
00:17:27.589
fine yeah in pipelining client don't need to
00:17:34.890
lay the next request issuing so the client can issue like this and when the
00:17:42.720
era happened just handle the era add here so I think it's feasible I mean
00:17:51.770
keep alive in EMH DDP request is not feasible for general development next is
00:18:01.290
SSL I need water this red cell is means
00:18:12.350
there's no verification by default you
00:18:20.580
know yes no verification by default this is excerpted from a client library it
00:18:30.560
said if the if it trying to connect the
00:18:36.780
ssl server it sets verification module now that doesn't do verification and if
00:18:43.650
options are set it turns on verify pier to do bella fication so the developer
00:18:53.790
can configure to do ssl verification for these libraries but if developer makes a
00:19:02.190
bug about options handling and the options is cleared this it should be
00:19:10.230
lively set verified nine and ten and connect to the ssl server and send users
00:19:19.290
data and secret thing without warning it it's not what assessor is expected if
00:19:27.770
excessive verification is not done and development to verify it should stop
00:19:34.830
sending data so when you want to connect
00:19:40.380
to the server you should use major nice or HTTP client
00:19:45.740
that supports certification relocation to and govt or west and HTTP I proxy
00:19:58.330
almost all supposed proxy and proxy education and basic authentication to
00:20:05.420
the server and some supports digest authentication and windows ntlm
00:20:11.390
authentication to http Fiji's almost all
00:20:21.140
supports get post to delete and open you Ally doesn't support person put delete
00:20:29.420
because it just for downloading a file and some lively supports custom HTTP
00:20:38.000
method like purge it's not good thing but some API server requires you send
00:20:46.630
the this kind of not non standard HTTP
00:20:52.100
request so if you connecting to such kind of service you should use this kind
00:20:59.390
of HTTP libraries ili I Eliza
00:21:05.260
internationalized resource identifier that includes the mulch bite in URL
00:21:13.510
unfortunately you are like are we dating support I are I and addressable gem
00:21:20.840
suppose I are I but also unfortunately addressable you li it's not aim to be a
00:21:30.080
drop in replacement of URL that RV so
00:21:36.179
it should be client library developers need some code to support addressable
00:21:41.759
you are line it's not difficult so you can ask these lively developers do
00:21:49.980
support addressable you Ally response head is sheer we returns response
00:21:58.169
headers in a single swing so if you want to extract the information from HTTP
00:22:06.210
headers you need to pass by yourself and
00:22:11.690
cookie major eyes and HTTP client
00:22:17.009
supports cookie but HTTP client has flow side cooking bug STD client it's this
00:22:25.740
cookie 4.com sigh and send it to all.com
00:22:31.919
side it's not expected because it can cause a security vulnerability like
00:22:39.480
session fixation so and the blotters need to handle this kind of domain and
00:22:46.850
what kind of domain name can store
00:22:51.869
cookie and send a cookie so if you need
00:22:57.499
this cookie hundred properly you should
00:23:02.509
you must use meta nice may generate hundreds these cookies properly like
00:23:09.749
blouses redirect HTTP server could
00:23:17.879
return with direct response that's to inform clients to follow the redirection
00:23:25.230
and many client library suppose the redirection following but some atypical
00:23:33.330
I'm library doesn't have a redirect limit so if the server returned the same
00:23:42.450
will be direction again and again it calls an infinite oh and clashes your Ruby interpreter you
00:23:49.539
you should take care of the distal redirection limit if you going to use
00:23:56.799
this client libraries form URL encoded is with these supported libraries you
00:24:06.100
can pass and clearly HTTP query and the
00:24:11.740
post forum in a hash over our way with that this feature you need to
00:24:18.909
concatenate the parameters with ampersand and equal by yourself sorry
00:24:27.299
Marge bedpost this library supports multi part file post forum posting and
00:24:37.559
streaming upload and download this is a
00:24:43.960
simple form the patterns patron and pattern has a parameter file to specify
00:24:51.639
the file to upload to the server and pattern read the file in shank and send
00:25:00.490
it to the server and the next read the next chunk from file without consuming
00:25:08.860
all of without reading all of the file and consume lots of memories and also
00:25:17.110
for download the sorry butter has get
00:25:23.409
file method and pass the right parameters to write our file into the
00:25:31.240
specified height and without reading all of the response in memory if EMH will be
00:25:38.769
request also had such method and for
00:25:44.919
chance to download em HTTP requests offers a stream Kovac that he lived
00:25:52.619
every chunk read from the server
00:25:59.430
compression a lot of HTTP client library supports compression and decompression
00:26:06.310
and and also for response to set some
00:26:11.680
library set the response encoding of response is doing according to the HTTP
00:26:20.710
response header content type and chatted so you don't need to set you're either
00:26:27.370
need to set you don't need to combat encoding by yourself developments about
00:26:39.960
a response serving is stabbing or
00:26:47.140
response it's the sample from HTTP client it has the rock back response
00:26:52.690
method and can cash the HTTP response body and when you invoke the next week
00:27:01.630
lyst the this string returned from the
00:27:09.640
method without accessing the actual service and HCD client also has an HTTP
00:27:17.230
message stabbing and this is a example
00:27:23.410
for redirecting from to reacting to another URL and the response normal less
00:27:31.600
loss and when this method is invoked this follows this route redirect and get
00:27:38.350
this HTTP response and without accessing
00:27:44.950
this survey some level we have the similar feature and it helps to debug or
00:27:53.530
chest your client but I I'll show I
00:28:00.640
introduced later but you can use the web mock gem for those not supporting
00:28:07.470
libraries so it you may not take care of this line we by
00:28:17.050
using web mock jam are introduced it later some library has wild dump the
00:28:23.890
bark feature it allows you to jump the actual HTTP request string and respond
00:28:31.660
string to writing to the file and it helps debugging such as HTTP server
00:28:40.390
seems to return and blocking response or wrong HTTP response ahead a it helps you
00:28:50.170
to debug such kind of blocking responses
00:28:55.510
i alway like shell Sam has this feature I think I think risk client is the first
00:29:04.410
client that offers this video and with these libraries you can embark the aisle
00:29:12.520
we like shell and in bulk the methods inside form it and you can of course use
00:29:20.920
I rvs history editing feature West
00:29:26.620
client also has an interesting and useful feature and zip replayable log if
00:29:36.370
you set this environment variable and call West gradient methods it danced to
00:29:46.690
the file in the format of the ruby program so you can take this code to
00:29:56.950
your program and after
00:30:03.520
trying to connect to the server like this it's a nice feature I want to
00:30:11.210
implement for it should be client client soon the last advanced features some
00:30:22.040
libraries has request and response that folks the request just before
00:30:30.020
sending to the server and just after
00:30:35.500
receiving response and before the passing good response it's useful for
00:30:43.210
setting head like Oh authentication header or tweaking the HTTP response
00:30:51.910
from the server fixing the chassid
00:30:58.820
header or something and some level it has JSON and XML combat feature it
00:31:08.620
converts the hash over array into JSON or XML before sending and converts it
00:31:18.020
back to hash object from the response JSON or XML payload response guessing is
00:31:27.790
mechanized and risk-free ross verbs and West the features it caches the service
00:31:36.680
response of course in proper manner and each mechanized sent and the server the
00:31:47.150
request if check if the resource is updated or not for if the resource is
00:31:56.240
already downloaded and it it's a very efficient for network bandwidth usage
00:32:06.190
but it's very nice for Plaza like client
00:32:11.600
but I mark this yellow is the reason why I'm mark the yellow is for a ps2 API client it
00:32:21.710
might cause some problem because API server may not want to get if modified
00:32:32.060
since or update check request so for API client you should be care because this
00:32:41.030
feature is enabled by default for major nice is it right Eric yeah for HTML form
00:32:49.010
handling and a mechanized it's shiny methods shiny features of HT so Mitch a
00:32:57.260
nice it allows to get the login form and
00:33:02.620
login page and get login form from it set the email and password and send a
00:33:09.920
proper URL to send the form so its belly
00:33:15.170
useful for testing your web applications
00:33:21.670
testing client as I said before when locks suppose the level 8 web mock is
00:33:29.120
the library for stabbing and setting expectations on HTTP request so and
00:33:35.120
weblog supports the all of the library i reset 16 all libraries so you can use
00:33:42.290
web mock even if the HTTP client library has such peaches and visio is for
00:33:50.270
recording your texts HTTP interactions and we will play then during future
00:33:55.730
tests with help from web mark so these
00:34:01.840
libraries would be a mass for you to develop your HTTP client performance
00:34:12.440
comparisons this is my environment for
00:34:18.919
evaluation and Saba is at West Coast open to and apache 2.2 new client is on
00:34:26.540
east coast and i used we won by CC and i did a multiple
00:34:33.329
downloads of gendered bite and twenty four megabytes but please don't take it
00:34:40.980
serious because it's not comprehensive benchmark so if you want to use evaluate
00:34:49.980
by yourself you can grab my benchmark scripts from here this is multiple 205
00:34:59.309
downloads please see the blue one first the blue one is 30 times download by one
00:35:07.470
sled there's a sling loops the one is
00:35:12.989
and doesn't support keep a live connection the second supports keep
00:35:19.259
alive connection and this sad yes the
00:35:24.749
soul they keep wing the library support keep out of the connection it's really efficient for small file downloads as
00:35:32.369
you see and the cell phone is Ian HTTP request and she'll be multi and because
00:35:40.140
the other libraries and issue this Harry time and savvy HDD request one by one
00:35:49.230
but M HTTP requests and she'll be multi issues the city request at once so it's
00:35:57.210
very fast as you see and the next is red one is with templates and five times
00:36:06.420
download for each thread it's almost the same trend but sled is efficient for all
00:36:19.019
HTTP libraries except EMA cbus and she'll be as I explained those H those
00:36:27.779
libraries issued request at once saw sled doesn't affect doesn't have any
00:36:34.249
effect the next one is comparison of
00:36:41.339
Ruby implementations the blue line is the one I explained in the previous page
00:36:48.779
and read is a Jerry 1.7 point zero and yellow is rubenesque 2.2 2 point 0 point
00:36:57.960
0 def you can see almost the same trend
00:37:04.289
for sherry and Jerry and Rubinius bed for some libraries Resta free and weary
00:37:14.450
Jerry and grooviness runs much slower than others and done silvie and others
00:37:21.869
so I think there's something blow them in a hostage era bien Rubinius about are
00:37:31.079
you handling but i'm not sure and i'm the most interesting things is a bent
00:37:40.049
machine-based p.m. HTTP request Sylvie is fast but for govt and Rubinius it's
00:37:46.769
not first as you see like it's almost the same as HTTP client and machen eyes
00:37:53.719
for veneers and I'm I also think there's
00:37:59.819
something problem in JRuby and Rubinius of handling event machine and as you see
00:38:08.940
even Percy is not updated frequently so it may take some time to fix this
00:38:16.200
problem the last laugh is multiple 24
00:38:24.420
megabyte downloads the blue one is the three times like three times download by
00:38:32.519
one slit and your see almost the same
00:38:38.339
trend for non keep-alive HDD client and keep alive supported HTTP client and for
00:38:48.930
the 24 megabyte downloads mhd blue quest and she'll be marching is not
00:38:54.789
so frustrating others so i think this
00:39:00.929
it's almost the network slow boot issue
00:39:07.650
so keepalive support it HTTP grants can
00:39:13.059
run faster as fast as I am HTTP requests and she will be merciful big date
00:39:20.589
download and the next one is the red bits leaflet and one time download for
00:39:29.229
each as you know this that's almost you
00:39:34.869
you cannot see notable differences of longer without so as I said before it's
00:39:43.809
almost done network slow boot that affect this download time it's a last
00:39:53.410
slide no I talk I'm its forces and practice my recommendations if speed is
00:40:00.640
the king you should use en HTTP request and she will be with multi API if but
00:40:09.640
but but if you are going to download the big file you can use other HTTP client
00:40:17.529
arrival is to avoid to fight with complex API of these HTTP client
00:40:25.269
libraries for HTML operation and cookies you should use major nice and for API
00:40:34.059
client you should use you can use holiday and other adapter based
00:40:40.439
implementations but if you want to connect to ssl server you need to care
00:40:49.559
ssl server verification issue i explained in this slot in this talk and
00:40:55.589
for ssl and barriers connectivity you
00:41:01.299
can check HTTP client first you don't know what server you are going
00:41:09.630
to connect at the development sign you can choose HTTP client for barriers
00:41:15.990
collection features please check the matrix before yeah anyway please check
00:41:22.890
the matrix before you use the libraries and please let me know when you find
00:41:28.410
incorrect cells in it thank you
00:41:43.969
we have four we have four meets west and
00:41:49.169
I can any question I once create created
00:42:02.519
this matrix one and a half years ago for
00:42:10.140
Japanese conference it took three masses and this time I just updated the matrix
00:42:18.449
and remove some it should be client add some it should be client I think almost
00:42:26.839
four week you're welcome yeah hi you
00:42:36.599
recommended which libraries user based on what you learn when you also make any
00:42:43.709
recommendations to developing with libraries exist we're developing a new
00:42:49.259
library would you say that if you should have done this differently this feature is missing this aight guys not good so
00:42:59.130
sorry i didn't understand please say so based on you recommend in which library
00:43:04.919
yes when you make recommendations to the design authors recommendations for the
00:43:14.249
authors yeah the features i right i
00:43:25.409
wrote in this slice something difficult
00:43:34.799
to implement because lots of service implement specs improperly so you need
00:43:45.149
to take care the non standard HTTP response and but I
00:43:55.039
even though you want to write HD declined by yourself you can first
00:44:04.579
define the API because I think you
00:44:16.049
should yeah I'm going to provide some recommendation for hcv client developer
00:44:24.439
osas because there's a lot of HTTP
00:44:33.089
client and the oh there's some has the
00:44:41.099
same API that offers the client instance and get method with how you can specify
00:44:50.369
the query and how you specify the file how do you specify the body and and the
00:44:58.079
web mock gem depends on such interface so i think you should define the API
00:45:08.189
according to the existing one and try to implement your internal implementation
00:45:14.849
by yourself is it oh we recommendations
00:45:25.249
for improvement sample implementation phone HTTP developers ah sorry answer
00:45:39.259
what will your vampire you do for example and the core library or should we scrap it we return it and
00:45:48.530
putting something else yeah the question is how should a good library degraded
00:45:58.120
possible into the API of anything easy to use may be easy to keep the standards
00:46:03.530
what features should have happened what Wendy learned was missing
00:46:18.240
for the Christian is what i learned from
00:46:24.590
various HD quality eyes APA styles it is
00:46:31.170
it yeah I found some not easier to use
00:46:46.619
interface but what I found
00:47:02.770
sorry but all I found is it's not good for it's not good for easy to use but
00:47:14.560
and I just found it's not easy to use like this by including the class method
00:47:24.610
instead of instance method so we I think
00:47:31.320
developers should care not the API itself but if it supports the sledding
00:47:40.000
or passing parameters to how developer
00:47:45.730
cim past diploma ters to the client instance that that's what I found from
00:47:53.380
the learning of the various API client
00:47:59.220
oh thank you
00:48:38.400
you