Parcourir la source

Added support to http and https proxies on bootstrap. Variables are read from environment vars http_proxy and https_proxy.

pull/579/head
CarlosEDP il y a 9 ans
Parent
révision
9906fdc25e
1 fichiers modifiés avec 42 ajouts et 0 suppressions
  1. +42
    -0
      bootstrap

+ 42
- 0
bootstrap Voir le fichier

@ -82,6 +82,7 @@ extract(Binary) ->
{ok, Contents}.
request(Url) ->
setHttpcOptions(),
case httpc:request(get, {Url, []},
[{relaxed, true}],
[{body_format, binary}]) of
@ -91,6 +92,47 @@ request(Url) ->
Error
end.
setHttpcOptions() ->
%% Get http_proxy and https_proxy environment variables
case os:getenv("http_proxy") of
false ->
Http = "";
Http ->
Http
end,
case os:getenv("https_proxy") of
false ->
Https = "";
Https ->
Https
end,
%% Parse the variables to extract host and port
Opts = [],
case http_uri:parse(Http) of
{ok,{_, [], Host, Port, _, []}} ->
Opts1 = Opts ++ [{proxy, {{Host, Port}, []}}];
{error, _} ->
Opts1 = Opts
end,
case http_uri:parse(Https) of
{ok,{_, [], Host2, Port2, _, []}} ->
Opts2 = Opts1 ++ [{https_proxy, {{Host2, Port2}, []}}];
{error, _} ->
Opts2 = Opts1
end,
io:format("Opts: ~p~n", [Opts2]),
case Opts2 of
[] ->
ok;
_ ->
httpc:set_options(Opts2),
ok
end.
compile(App, FirstFiles) ->
Dir = filename:join(filename:absname("_build/default/lib/"), App),
filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])),

Chargement…
Annuler
Enregistrer