Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

HTTP2 client for Erlang based on libcurl and libevent

License

NotificationsYou must be signed in to change notification settings

puzza007/katipo

Repository files navigation

An HTTP/HTTP2 client library for Erlang built around libcurl-multi and libevent.

Status

build statusHex pmHex Docs

Usage

{ok,_}=application:ensure_all_started(katipo).Pool=api_server,{ok,_}=katipo_pool:start(Pool,2, [{pipelining,multiplex}]).Url= <<"https://example.com">>.ReqHeaders= [{<<"User-Agent">>, <<"katipo">>}].Opts= #{headers=>ReqHeaders,body=> <<"0d5cb3c25b0c5678d5297efa448e1938">>,connecttimeout_ms=>5000,proxy=> <<"http://127.0.0.1:9000">>,ssl_verifyhost=>false,ssl_verifypeer=>false},{ok, #{status :=200,headers :=RespHeaders,cookiejar :=CookieJar,body :=RespBody}}=katipo:post(Pool,Url,Opts).

Or passing the entire request as a map

{ok,_}=application:ensure_all_started(katipo).Pool=api_server,{ok,_}=katipo_pool:start(Pool,2, [{pipelining,multiplex}]).ReqHeaders= [{<<"User-Agent">>, <<"katipo">>}].Req= #{url=> <<"https://example.com">>.method=>post,headers=>ReqHeaders,body=> <<"0d5cb3c25b0c5678d5297efa448e1938">>,connecttimeout_ms=>5000,proxy=> <<"http://127.0.0.1:9000">>,ssl_verifyhost=>false,ssl_verifypeer=>false},{ok, #{status :=200,headers :=RespHeaders,cookiejar :=CookieJar,body :=RespBody}}=katipo:req(Pool,Req).

Why

We wanted a compatible and high-performance HTTP client so tookadvantage of the 15+ years of development that has gone into libcurl.To allow large numbers of simultaneous connections libevent is usedalong with the libcurl-multi interface.

Documentation

API

-typemethod()::get |post |put |head |options.katipo_pool:start(Name::atom(),size::pos_integer(),PoolOptions::proplist()).katipo_pool:stop(Name::atom()).katipo:req(Pool::atom(),Req::map()).katipo:Method(Pool::atom(),URL::binary()).katipo:Method(Pool::atom(),URL::binary(),ReqOptions::map()).

Application Config

OptionValuesDefaultNotes
mod_metricsfolsom | exometer | noopnoopseeerlang-metrics

Request options

OptionTypeDefaultNotes
headers[{binary(), iodata()}][]
cookiejaropaque (returned in response)[]
bodyiodata()<<>>
connecttimeout_mspos_integer()30000docs
followlocationboolean()falsedocs
ssl_verifyhostboolean()truedocs
ssl_verifypeerboolean()truedocs
capathbinary()undefined
cacertbinary()undefined
timeout_mspos_integer()30000
maxredirsnon_neg_integer()9
proxybinary()undefineddocs
return_metricsboolean()false
tcp_fastopenboolean()falsedocs curl >= 7.49.0
interfacebinary()undefineddocs
unix_socket_pathbinary()undefineddocs curl >= 7.40.0
lock_data_ssl_sessionboolean()falsedocs curl >= 7.23.0
doh_urlbinary()undefineddocs curl >= 7.62.0
http_versioncurl_http_version_none
curl_http_version_1_0
curl_http_version_1_1
curl_http_version_2_0
curl_http_version_2tls
curl_http_version_2_prior_knowledge
curl_http_version_nonedocs curl >= 7.62.0
sslcertbinary()undefineddocs
sslkeybinary()undefineddocs
sslkey_blobbinary() (DER format)undefineddocs curl >= 7.71.0
keypasswdbinary()undefineddocs
http_authbasic
digest
ntlm
negotiate
undefineddocs
userpwdbinary()undefineddocs

Responses

{ok, #{status :=pos_integer(),headers :=headers(),cookiejar :=cookiejar(),body :=body(),metrics=>proplist()}}{error, #{code :=atom(),message :=binary()}}

Pool Options

OptionTypeDefaultNote
pipeliningnothing
http1
multiplex
nothingHTTP pipeliningCURLMOPT_PIPELINING
max_pipeline_lengthnon_neg_integer()100
max_total_connectionsnon_neg_integer()0 (no limit)docs

Metrics

  • ok
  • error
  • status.XXX
  • total_time
  • curl_time
  • namelookup_time
  • connect_time
  • appconnect_time
  • pretransfer_time
  • redirect_time
  • starttransfer_time

System dependencies

  • libevent-dev
  • libcurl4-openssl-dev
  • make
  • curl
  • libssl-dev
  • gcc

Testing

The official Erlang Dockerimagehas everything needed to build and test Katipo

TODO

  • A more structured way to ifdef features based on curl version

[8]ページ先頭

©2009-2025 Movatter.jp