summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap2
-rw-r--r--rebar.config53
-rw-r--r--src/rebar_pkg_resource.erl2
-rw-r--r--src/rebar_utils.erl10
-rw-r--r--test/rebar_utils_SUITE.erl14
5 files changed, 41 insertions, 40 deletions
diff --git a/bootstrap b/bootstrap
index bacde32..9675e1d 100755
--- a/bootstrap
+++ b/bootstrap
@@ -49,7 +49,7 @@ main(_) ->
code:add_pathsa(DepsPaths),
rebar3:run(["clean", "-a"]),
- rebar3:run(["escriptize"]),
+ rebar3:run(["as", "prod", "escriptize"]),
%% Done with compile, can turn back on error logger
error_logger:tty(true).
diff --git a/rebar.config b/rebar.config
index 12fc8c5..c271f29 100644
--- a/rebar.config
+++ b/rebar.config
@@ -31,7 +31,6 @@
{erl_opts, [{platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^(19|2)", rand_only},
{platform_define, "^2", unicode_str},
- no_debug_info,
warnings_as_errors]}.
%% Use OTP 18+ when dialyzing rebar3
@@ -50,35 +49,27 @@
{bootstrap, []},
- {dialyze, [{overrides, [{add, erlware_commons, [{erl_opts, [debug_info]}]},
- {add, ssl_verify_fun, [{erl_opts, [debug_info]}]},
- {add, certifi, [{erl_opts, [debug_info]}]},
- {add, providers, [{erl_opts, [debug_info]}]},
- {add, getopt, [{erl_opts, [debug_info]}]},
- {add, bbmustache, [{erl_opts, [debug_info]}]},
- {add, relx, [{erl_opts, [debug_info]}]},
- {add, cf, [{erl_opts, [debug_info]}]},
- {add, cth_readable, [{erl_opts, [debug_info]}]},
- {add, eunit_formatters, [{erl_opts, [debug_info]}]}]},
- {erl_opts, [debug_info]}]}
+ {prod, [
+ {overrides, [
+ {override, erlware_commons, [
+ {erl_opts, [{platform_define, "^[0-9]+", namespaced_types},
+ {platform_define, "^R1[4|5]", deprecated_crypto},
+ {platform_define, "^((1[8|9])|2)", rand_module},
+ {platform_define, "^2", unicode_str},
+ no_debug_info,
+ warnings_as_errors]},
+ {deps, []}, {plugins, []}]},
+ {add, ssl_verify_hostname, [{erl_opts, [no_debug_info]}]},
+ {add, certifi, [{erl_opts, [no_debug_info]}]},
+ {add, cf, [{erl_opts, [no_debug_info]}]},
+ {add, cth_readable, [{erl_opts, [no_debug_info]}]},
+ {add, eunit_formatters, [{erl_opts, [no_debug_info]}]},
+ {override, bbmustache, [
+ {erl_opts, [no_debug_info, {platform_define, "^[0-9]+", namespaced_types}]},
+ {deps, []}, {plugins, []}]},
+ {add, getopt, [{erl_opts, [no_debug_info]}]},
+ {add, providers, [{erl_opts, [no_debug_info]}]},
+ {add, relx, [{erl_opts, [no_debug_info]}]}]}
+ ]}
]}.
-%% Overrides
-{overrides, [{override, erlware_commons, [{erl_opts, [{platform_define, "^[0-9]+", namespaced_types},
- {platform_define, "^R1[4|5]", deprecated_crypto},
- {platform_define, "^((1[8|9])|2)", rand_module},
- {platform_define, "^2", unicode_str},
- no_debug_info,
- warnings_as_errors]},
- {deps, []}, {plugins, []}]},
- {add, ssl_verify_hostname, [{erl_opts, [no_debug_info]}]},
- {add, certifi, [{erl_opts, [no_debug_info]}]},
- {add, cf, [{erl_opts, [no_debug_info]}]},
- {add, cth_readable, [{erl_opts, [no_debug_info]}]},
- {add, eunit_formatters, [{erl_opts, [no_debug_info]}]},
- {override, bbmustache, [{erl_opts, [no_debug_info,
- {platform_define, "^[0-9]+", namespaced_types}]},
- {deps, []}, {plugins, []}]},
- {add, getopt, [{erl_opts, [no_debug_info]}]},
- {add, providers, [{erl_opts, [no_debug_info]}]},
- {add, relx, [{erl_opts, [no_debug_info]}]}]}.
diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
index 16ec83f..2cf167e 100644
--- a/src/rebar_pkg_resource.erl
+++ b/src/rebar_pkg_resource.erl
@@ -191,7 +191,7 @@ ssl_opts(Url) ->
ETag :: string(),
Res :: ok.
store_etag_in_cache(Path, ETag) ->
- ok = file:write_file(Path, ETag).
+ _ = file:write_file(Path, ETag).
%%%=============================================================================
%%% Private functions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 9bbe54e..a911cc2 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -854,10 +854,18 @@ set_httpc_options(_, []) ->
ok;
set_httpc_options(Scheme, Proxy) ->
- {ok, {_, UserInfo, Host, Port, _, _}} = http_uri:parse(Proxy),
+ URI = normalise_proxy(Scheme, Proxy),
+ {ok, {_, UserInfo, Host, Port, _, _}} = http_uri:parse(URI),
httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar),
set_proxy_auth(UserInfo).
+normalise_proxy(Scheme, URI) ->
+ case re:run(URI, "://", [unicode]) of
+ nomatch when Scheme =:= https_proxy -> "https://" ++ URI;
+ nomatch when Scheme =:= proxy -> "http://" ++ URI;
+ _ -> URI
+ end.
+
url_append_path(Url, ExtraPath) ->
case http_uri:parse(Url) of
{ok, {Scheme, UserInfo, Host, Port, Path, Query}} ->
diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl
index 8b8769b..e4a5bd3 100644
--- a/test/rebar_utils_SUITE.erl
+++ b/test/rebar_utils_SUITE.erl
@@ -275,11 +275,13 @@ tup_merge(_Config) ->
)
).
-proxy_auth(_Config) ->
- proxy_auth(_Config, "http_proxy"),
- proxy_auth(_Config, "https_proxy").
+proxy_auth(Config) ->
+ proxy_auth(Config, "http://", "http_proxy"),
+ proxy_auth(Config, "https://", "https_proxy"),
+ proxy_auth(Config, "", "http_proxy"),
+ proxy_auth(Config, "", "https_proxy").
-proxy_auth(_Config, ProxyEnvKey) ->
+proxy_auth(_Config, Schema, ProxyEnvKey) ->
Host = "host:",
Port = "1234",
@@ -291,13 +293,13 @@ proxy_auth(_Config, ProxyEnvKey) ->
?assertEqual([], rebar_utils:get_proxy_auth()),
%% proxy auth with regular username/password
- os:putenv(ProxyEnvKey, "http://Username:Password@" ++ Host ++ Port),
+ os:putenv(ProxyEnvKey, Schema++"Username:Password@" ++ Host ++ Port),
rebar_utils:set_httpc_options(),
?assertEqual([{proxy_auth, {"Username", "Password"}}],
rebar_utils:get_proxy_auth()),
%% proxy auth with username missing and url encoded password
- os:putenv(ProxyEnvKey, "http://:%3F!abc%23%24@" ++ Host ++ Port),
+ os:putenv(ProxyEnvKey, Schema++":%3F!abc%23%24@" ++ Host ++ Port),
rebar_utils:set_httpc_options(),
?assertEqual([{proxy_auth, {"", "?!abc#$"}}],
rebar_utils:get_proxy_auth()),