diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2018-04-20 18:28:03 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2018-04-20 18:28:03 -0400 |
commit | 01eeda6c2c46a83ac2b288c0602cfc320e849a88 (patch) | |
tree | 446a26dd255234ebbfe84d16db6fad431494f70f | |
parent | c48435a09f4b43ef1cf59a8ff6157b223550437c (diff) |
Handle Schemaless Proxy URLs in ENV vars
We've had multiple tickets opened because of unclear PROXY settings when
the scheme is missing form the URI. To be helpful, we instead add them
dynamically whenever they're missing.
Example issues:
- https://github.com/erlang/rebar3/issues/1747
- https://github.com/erlang/rebar3/issues/1697
-rw-r--r-- | src/rebar_utils.erl | 10 |
1 files changed, 9 insertions, 1 deletions
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}} -> |