Skip to content

Commit 6c7c96e

Browse files
[AUTO] [ RTI-14085 ] Update Dependencies (#44)
* Update dependencies * Thank you, Elvis! --------- Co-authored-by: Brujo Benavides Rodriguez <[email protected]>
1 parent 1c03941 commit 6c7c96e

8 files changed

+203
-300
lines changed

CHANGELOG

-77
This file was deleted.

include/lhttpc_types.hrl

-42
This file was deleted.

rebar.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
{project_plugins,
3434
[{rebar3_hex, "~> 7.0.4"},
3535
{rebar3_format, "~> 1.2.1"},
36-
{rebar3_lint, "~> 2.0.1"},
36+
{rebar3_lint, "~> 3.0.0"},
3737
{rebar3_hank, "~> 1.3.0"},
3838
{rebar3_sheldon, "~> 0.4.2"}]}.

src/lhttpc.erl

+40-18
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
-dialyzer([{no_missing_return, [start/2]}]).
3636

3737
%% catch X is used as a way to fire and forget, ignoring errors if there are any
38-
-elvis([{elvis_style, no_catch_expressions, disable}]).
38+
-elvis([{elvis_style, no_catch_expressions, disable},
39+
{elvis_style, max_function_arity, #{max_arity => 9}}]).
3940

4041
-behaviour(application).
4142

@@ -60,11 +61,24 @@
6061
request/9, send_body_part/2, send_body_part/3, send_trailers/2, send_trailers/3,
6162
get_body_part/1, get_body_part/2]).
6263

63-
-include("lhttpc_types.hrl").
64-
64+
-type header() :: {string() | atom(), string()}.
65+
-type headers() :: [header()].
66+
-type option() ::
67+
{connect_options, list()} |
68+
{connect_timeout, timeout()} |
69+
{connection_timeout, non_neg_integer() | infinity} |
70+
{max_connections, non_neg_integer()} |
71+
{send_retry, non_neg_integer()} |
72+
{stream_to, pid()} |
73+
{partial_upload, non_neg_integer() | infinity} |
74+
{partial_download, pid(), non_neg_integer() | infinity}.
75+
-type options() :: [option()].
76+
-type window_size() :: non_neg_integer() | infinity.
6577
-type result() ::
6678
{ok, {{pos_integer(), string()}, headers(), binary()}} | {error, atom()}.
6779

80+
-export_type([headers/0, options/0, result/0, window_size/0]).
81+
6882
%% @hidden
6983
-spec start(any(), any()) -> {ok, pid()}.
7084
start(_, Opts) when is_list(Opts) ->
@@ -190,25 +204,25 @@ request(URL, Method, Hdrs, Body, Timeout) ->
190204
%% Reason = connection_closed | connect_timeout | timeout
191205
%% @doc Sends a request with a body.
192206
%% Would be the same as calling <pre>
193-
%% {Host, Port, Path, Ssl} = lhttpc_lib:parse_url(URL),
194-
%% request(Host, Port, Path, Ssl, Method, Hdrs, Body, Timeout, Options).
207+
%% {Host, Port, Path, SSL} = lhttpc_lib:parse_url(URL),
208+
%% request(Host, Port, Path, SSL, Method, Hdrs, Body, Timeout, Options).
195209
%% </pre>
196210
%%
197211
%% `URL' is expected to be a valid URL:
198212
%% `scheme://host[:port][/path]'.
199213
%% @end
200214
%% @see request/9
201-
-spec request(string(), string() | atom(), headers(), iolist(), timeout(), [option()]) ->
215+
-spec request(string(), string() | atom(), headers(), iolist(), timeout(), options()) ->
202216
result().
203217
request(URL, Method, Hdrs, Body, Timeout, Options) ->
204-
{Host, Port, Path, Ssl} = lhttpc_lib:parse_url(URL),
205-
request(Host, Port, Ssl, Path, Method, Hdrs, Body, Timeout, Options).
218+
{Host, Port, Path, SSL} = lhttpc_lib:parse_url(URL),
219+
request(Host, Port, SSL, Path, Method, Hdrs, Body, Timeout, Options).
206220

207-
%% @spec (Host, Port, Ssl, Path, Method, Hdrs, RequestBody, Timeout, Options) ->
221+
%% @spec (Host, Port, SSL, Path, Method, Hdrs, RequestBody, Timeout, Options) ->
208222
%% Result
209223
%% Host = string()
210224
%% Port = integer()
211-
%% Ssl = boolean()
225+
%% SSL = boolean()
212226
%% Path = string()
213227
%% Method = string() | atom()
214228
%% Hdrs = [{Header, Value}]
@@ -243,7 +257,7 @@ request(URL, Method, Hdrs, Body, Timeout, Options) ->
243257
%% use the following:<br/>
244258
%% `Host' = `"example.com"'<br/>
245259
%% `Port' = `80'<br/>
246-
%% `Ssl' = `false'<br/>
260+
%% `SSL' = `false'<br/>
247261
%% `Path' = `"/foobar"'<br/>
248262
%% `Path' must begin with a forward slash `/'.
249263
%%
@@ -346,25 +360,33 @@ request(URL, Method, Hdrs, Body, Timeout, Options) ->
346360
headers(),
347361
iolist(),
348362
timeout(),
349-
[option()]) ->
363+
options()) ->
350364
result().
351-
request(Host, Port, Ssl, Path, Method, Hdrs, Body, Timeout, Options) ->
365+
request(Host, Port, SSL, Path, Method, Hdrs, Body, Timeout, Options) ->
352366
ok = verify_options(Options),
353367
ReqId = make_ref(),
354-
BaseArgs = [Host, Port, Ssl, Path, Method, Hdrs, Body, Options],
368+
BaseArg =
369+
#{host => Host,
370+
port => Port,
371+
ssl => SSL,
372+
path => Path,
373+
method => Method,
374+
headers => Hdrs,
375+
body => Body,
376+
options => Options},
355377
case proplists:is_defined(stream_to, Options) of
356378
true ->
357379
StreamTo = proplists:get_value(stream_to, Options),
358-
Args = [ReqId, StreamTo | BaseArgs],
359-
Pid = spawn(lhttpc_client, request, Args),
380+
Arg = BaseArg#{id => ReqId, from => StreamTo},
381+
Pid = spawn(lhttpc_client, request, [Arg]),
360382
spawn(fun() ->
361383
R = kill_client_after(Pid, Timeout),
362384
StreamTo ! {response, ReqId, Pid, R}
363385
end),
364386
{ReqId, Pid};
365387
false ->
366-
Args = [ReqId, self() | BaseArgs],
367-
Pid = spawn_link(lhttpc_client, request, Args),
388+
Arg = BaseArg#{id => ReqId, from => self()},
389+
Pid = spawn_link(lhttpc_client, request, [Arg]),
368390
receive
369391
{response, ReqId, Pid, R} ->
370392
R;

0 commit comments

Comments
 (0)