の一つ?まだ10日程いじってみた程度。
https://github.com/wycats/net-http
・現時点では動かない
・有望なのは間違いない
・mergeでモメそう
Hiroshi Nakamura / @nahi / nahi@ruby-lang.org / https://github.com/nahi
Asakusa.rb / Sarion Systems Research
Summary
・net/httpには派生と代替がたくさんある。
APIが難しく、仕組みが簡単だから。
・net/httpの派生で、net/httpの機能を素直に派生できている
ものはない。簡単すぎて拡張しにくい。
・既存のHTTPクライアントの実装機能には差がある。
用途で選ぶ(企業内から?バッチ処理?REST連携?)
・APIにも差がある。凝ったことをすると統一感がなくなる。
・既存のものに性能差はほとんどない。ただしKeep-Aliveと
gzip圧縮ダウンロードには気を使う価値がある。
・性能最重視ならEventmachine。
・C拡張は使用に注意。
Ruby 1.4 (1999/8)
Ruby 1.2 (1998/12)
Ruby 1.9.1 (2009/1)
Ruby 1.8 (2003/8)
Ruby 1.8.6 (2007/3)
Ruby 1.6 (2000/9)
Ruby 1.8.7 (2008/6)
Ruby 1.9.2 (2010/8)
バッチ転送用途に特化。リトライ、ログ、リカバリー用フックなど。
net/http (1999/12)
REST向け機能を追加。Last-Modified、ETagに基づくキャッシュ実装あり。
http://www.ruby-lang.org/ja/
http://www.yahoo.com/
open-uri (2002/12)
httparty (2008/7)
httparty
(connection
problem?)
patron
rest-client (2008/3)
net/http派生の先駆け。Rails 1.x時代から。
最近は使われない。
rufus-verbs
net/httpベ派生としては著名。使いやすいAPIが評価されている。
simplehttp
rest-client
wrest
open-uri
curb
httparty
right_http_connection (2007/5)
rest-client
excon
curb
rufus-verbs
simplehttp
httpclient
net/http
r_h_c
open-uri
excon
typhoeus
wrest
rufus-verbs (2008/3)
faraday
httpclient
typhoeus
r_h_c
net/http
eventmachine
simplehttp (2007/1)
eventmachine
faraday
File.openを拡張し、ファイル名とURLを同じように扱える。
Rails 2から入ったRESTクライアント。決定版になりきれなかった?
activeresource (2008/1)
curb (2006/12)
patron (2009/7)
Rails 3のリファクタリングを
リードしたwycats先生の次回作!
typhoues (2009/7)
Rubyベースの代替。net/httpより古くから開発が続いている。
eventmachine (2006/4)
http://localhost/
http://www.rakuten.co.jp/
http-access2 (2002/10)
http-access (1999/3)
excon (2009/10)
RackのようなミドルウェアベースのHTTPクライアントを目指している。
patron
curb
Rails 1.x時代によく使われた。元はMongrelのテスト用途。
Rubyベースの代替。Rubinius、MacRubyでもテストされている。
simplehttp
rest-client
httparty
rufus-verbs
open-uri
httpclient (2007/7)
curb
立ち位置はnet/httpベースと同じ
Pure RubyでAPI拡張
excon
KNClient (1999/3)
wrest
net/http
r_h_c
httpclient
typhoeus
faraday (2009/12)
JSON/XML自動解析機能を追加。
APIが独特。
"http://~".to_uri.post(...)
イベントベース。機能が著しく限定されているが、用途がハマると素晴らしい性能。
faraday
eventmachine
wrest (2009/4)
rfuzz (2006/7)
libcurlベースの代替の先駆け。APIが使い辛いと言われるが、libcurlのAPIに忠実。元が悪い。
Rails 1.0 (2005/12)
Rails 2.0 (2007/12)
Rails 3.0 (2010/8)
libcurlベースで消えていったものは他にも
これはこれで乱立
libcurlベースの中では一番APIがスマートで使い易くwrapされている。ただし現時点ではblocking。
Performance
Feature matrix
Ruby HTTP clients
net/http
Development timeline
3人しか出てこない。簡単だよね。
では、なぜ派生がたくさんできる?
・複雑だから?
・簡単だから?
以下、比較していきます。
$repo/perf/bm.rb
- ・Linode (Xen VPS)
- ・at Fremont CA
- measured 'Real' time
$repo/sample/sample_*.rb
$repo/feature/test_*.rb
$repo/scripts/install_gem.rb
http://j.mp/OdrkHTTPClient (This slide)
http://j.mp/RubyHTTPClients (Feature matrix)
http://j.mp/OdrkHTTPClientRepo (Sources repository)
Disclaimer: I'm the author of httpclient gem
Makimono Img: http://e-poket.com/illust/maki26.htm