|
|
@ -910,8 +910,7 @@ get_http_vars(Scheme) -> |
|
|
|
|
|
|
|
-ifdef (OTP_RELEASE). |
|
|
|
-if(?OTP_RELEASE >= 23). |
|
|
|
-compile({nowarn_deprecated_function, [{http_uri, parse, 1}, |
|
|
|
{http_uri, decode, 1}]}). |
|
|
|
-compile({nowarn_deprecated_function, [{http_uri, decode, 1}]}). |
|
|
|
-endif. |
|
|
|
-endif. |
|
|
|
|
|
|
@ -924,7 +923,10 @@ set_httpc_options(_, []) -> |
|
|
|
|
|
|
|
set_httpc_options(Scheme, Proxy) -> |
|
|
|
URI = normalise_proxy(Scheme, Proxy), |
|
|
|
{ok, {_, UserInfo, Host, Port, _, _}} = http_uri:parse(URI), |
|
|
|
Parts = rebar_uri:parse(URI), |
|
|
|
Host = maps:get(host, Parts, []), |
|
|
|
Port = maps:get(port, Parts, []), |
|
|
|
UserInfo = maps:get(userinfo, Parts, []), |
|
|
|
httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar), |
|
|
|
set_proxy_auth(UserInfo). |
|
|
|
|
|
|
@ -935,14 +937,30 @@ normalise_proxy(Scheme, URI) -> |
|
|
|
_ -> URI |
|
|
|
end. |
|
|
|
|
|
|
|
%% OTP 21+ |
|
|
|
-ifdef (OTP_RELEASE). |
|
|
|
url_append_path(Url, ExtraPath) -> |
|
|
|
case http_uri:parse(Url) of |
|
|
|
{ok, {Scheme, UserInfo, Host, Port, Path, Query}} -> |
|
|
|
case rebar_uri:parse(Url) of |
|
|
|
#{path := Path} = Map -> |
|
|
|
FullPath = filename:join(Path, ExtraPath), |
|
|
|
{ok, uri_string:recompose(maps:update(path, FullPath, Map))}; |
|
|
|
_ -> |
|
|
|
error |
|
|
|
end. |
|
|
|
-else. |
|
|
|
url_append_path(Url, ExtraPath) -> |
|
|
|
case rebar_uri:parse(Url) of |
|
|
|
#{scheme := Scheme, userinfo := UserInfo, host := Host, port := Port, path := Path, query := Query} -> |
|
|
|
PrefixedQuery = case Query of |
|
|
|
[] -> []; |
|
|
|
Other -> lists:append(["?", Other]) |
|
|
|
end, |
|
|
|
{ok, lists:append([atom_to_list(Scheme), "://", UserInfo, Host, ":", integer_to_list(Port), |
|
|
|
filename:join(Path, ExtraPath), Query])}; |
|
|
|
filename:join(Path, ExtraPath), PrefixedQuery])}; |
|
|
|
_ -> |
|
|
|
error |
|
|
|
end. |
|
|
|
-endif. |
|
|
|
|
|
|
|
%% escape\ as\ a\ shell\? |
|
|
|
escape_chars(Str) when is_atom(Str) -> |
|
|
@ -1028,8 +1046,7 @@ ssl_opts(Url) -> |
|
|
|
ssl_opts(ssl_verify_enabled, Url) -> |
|
|
|
case check_ssl_version() of |
|
|
|
true -> |
|
|
|
{ok, {_, _, Hostname, _, _, _}} = |
|
|
|
http_uri:parse(rebar_utils:to_list(Url)), |
|
|
|
#{host := Hostname} = rebar_uri:parse(rebar_utils:to_list(Url)), |
|
|
|
VerifyFun = {fun ssl_verify_hostname:verify_fun/3, |
|
|
|
[{check_hostname, Hostname}]}, |
|
|
|
CACerts = certifi:cacerts(), |
|
|
|