Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: elp #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
{minimum_otp_vsn, "23.0"}.

{deps, [
{worker_pool, "6.0.0"},
{metrics, "2.5.0"}
{worker_pool, "6.0.1"},
{metrics, "2.5.0"},
{eqwalizer_support,
{git_subdir,
"[email protected]:whatsapp/eqwalizer.git",
{branch, "main"},
"eqwalizer_support"}}
]}.

{profiles,
Expand Down Expand Up @@ -47,3 +52,11 @@
{coveralls_service_name, "travis-ci"}.

{hex, [{doc, #{provider => edoc}}]}.

{project_plugins, [
{eqwalizer_rebar3,
{git_subdir,
"[email protected]:whatsapp/eqwalizer.git",
{branch, "main"},
"eqwalizer_rebar3"}}
]}.
13 changes: 9 additions & 4 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{"1.2.0",
[{<<"metrics">>,{pkg,<<"metrics">>,<<"2.5.0">>},0},
{<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.0.0">>},0}]}.
[{<<"eqwalizer_support">>,
{git_subdir,"[email protected]:whatsapp/eqwalizer.git",
{ref,"c76956d720add1cd7eefebba945a5e17a4b5b0a9"},
"eqwalizer_support"},
0},
{<<"metrics">>,{pkg,<<"metrics">>,<<"2.5.0">>},0},
{<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.0.1">>},0}]}.
[
{pkg_hash,[
{<<"metrics">>, <<"268D218D56529CB5F070D74BBFC3AF64C668379B5B18FAFDA88959442F790C57">>},
{<<"worker_pool">>, <<"F7B442B30121EED6D8C828833533E5C15DB61E4AB2EF343C8B67824267656822">>}]},
{<<"worker_pool">>, <<"CA262C2DFB3B4AF661B206C82065D86F83922B7227508AA6E0BC34D3E5AE5135">>}]},
{pkg_hash_ext,[
{<<"metrics">>, <<"AE061938C8C3BDE97D17BE9A792B63E15C1E1EFFE16598AB87A62384F5F3714B">>},
{<<"worker_pool">>, <<"F9D95B85E80C5C27B7AB2E60BF780DA70A5E26DD9E6D30BE45032742FC039CC5">>}]}
{<<"worker_pool">>, <<"772E12CCB26909EA7F804B52E86E733DF66BB8150F683B591B0A762196494C74">>}]}
].
36 changes: 26 additions & 10 deletions src/katipo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@
-type status() :: pos_integer().
-type header() :: {binary(), iodata()}.
-type headers() :: [header()].
-type req_headers() :: [binary()].
-opaque cookiejar() :: [binary()].
-type qs_vals() :: [{unicode:chardata(), unicode:chardata() | true}].
-type req_body() :: iodata() | qs_vals().
-type body() :: binary().
-type body() :: iodata().
-type connecttimeout_ms() :: pos_integer().
%% See [https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html]
-type ssl_verifyhost() :: boolean().
Expand Down Expand Up @@ -349,6 +350,21 @@
curl_http_version_2_0 |
curl_http_version_2tls |
curl_http_version_2_prior_knowledge.

-define(CURL_HTTP_VERSION_NONE, 0).
-define(CURL_HTTP_VERSION_1_0, 1).
-define(CURL_HTTP_VERSION_1_1, 2).
-define(CURL_HTTP_VERSION_2_0, 3).
-define(CURL_HTTP_VERSION_2TLS, 4).
-define(CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE, 5).

-type curlopt_http_version_int() :: ?CURL_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.

%% HTTP protocol version to use
%% see [https://curl.se/libcurl/c/CURLOPT_HTTP_VERSION.html]
-type curlmopts() :: [{max_pipeline_length, non_neg_integer()} |
Expand Down Expand Up @@ -386,7 +402,7 @@
-record(req, {
method = ?GET :: method_int(),
url :: undefined | binary(),
headers = [] :: headers(),
headers = [] :: req_headers(),
cookiejar = [] :: cookiejar(),
body = <<>> :: body(),
connecttimeout_ms = ?DEFAULT_REQ_TIMEOUT :: pos_integer(),
Expand All @@ -409,7 +425,7 @@
lock_data_ssl_session = ?LOCK_DATA_SSL_SESSION_FALSE ::
?LOCK_DATA_SSL_SESSION_FALSE | ?LOCK_DATA_SSL_SESSION_TRUE,
doh_url = undefined :: undefined | doh_url(),
http_version = curl_http_version_none :: curlopt_http_version(),
http_version = ?CURL_HTTP_VERSION_NONE :: curlopt_http_version_int(),
verbose = ?VERBOSE_FALSE :: ?VERBOSE_FALSE | ?VERBOSE_TRUE,
sslcert = undefined :: undefined | binary() | file:name_all(),
sslkey = undefined :: undefined | binary() | file:name_all(),
Expand Down Expand Up @@ -705,7 +721,7 @@ get_mopts(Opts) ->
{error, {bad_opts, Opts}}
end.

-spec mopt_supported({curlmopt(), any()}) -> false | {true, any()}.
-spec mopt_supported({curlmopt(), any()}) -> false | {true, string()}.
mopt_supported({max_pipeline_length, Val})
when is_integer(Val) andalso Val >= 0 ->
{true, "--max-pipeline-length " ++ integer_to_list(Val)};
Expand Down Expand Up @@ -805,17 +821,17 @@ opt(lock_data_ssl_session, false, {Req, Errors}) ->
opt(doh_url, DOHURL, {Req, Errors}) when ?DOH_URL_AVAILABLE andalso is_binary(DOHURL) ->
{Req#req{doh_url=DOHURL}, Errors};
opt(http_version, curl_http_version_none, {Req, Errors}) ->
{Req#req{http_version=0}, Errors};
{Req#req{http_version=?CURL_HTTP_VERSION_NONE}, Errors};
opt(http_version, curl_http_version_1_0, {Req, Errors}) ->
{Req#req{http_version=1}, Errors};
{Req#req{http_version=?CURL_HTTP_VERSION_1_0}, Errors};
opt(http_version, curl_http_version_1_1, {Req, Errors}) ->
{Req#req{http_version=2}, Errors};
{Req#req{http_version=?CURL_HTTP_VERSION_1_1}, Errors};
opt(http_version, curl_http_version_2_0, {Req, Errors}) ->
{Req#req{http_version=3}, Errors};
{Req#req{http_version=?CURL_HTTP_VERSION_2_0}, Errors};
opt(http_version, curl_http_version_2tls, {Req, Errors}) ->
{Req#req{http_version=4}, Errors};
{Req#req{http_version=?CURL_HTTP_VERSION_2TLS}, Errors};
opt(http_version, curl_http_version_2_prior_knowledge, {Req, Errors}) ->
{Req#req{http_version=5}, Errors};
{Req#req{http_version=?CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE}, Errors};
opt(verbose, true, {Req, Errors}) ->
{Req#req{verbose=?VERBOSE_TRUE}, Errors};
opt(verbose, false, {Req, Errors}) ->
Expand Down