summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlosEDP <me@carlosedp.com>2015-07-01 13:58:40 -0300
committerCarlosEDP <me@carlosedp.com>2015-07-03 16:40:24 -0300
commit9906fdc25e3769d07b0de78a18501c7a681e6dc9 (patch)
treec6efb0ec932d235ab959f04726c0f74d75a95e97
parent3908c20aae55242e666f61fbbfd5985a4b69d824 (diff)
Added support to http and https proxies on bootstrap. Variables are read from environment vars http_proxy and https_proxy.
-rwxr-xr-xbootstrap42
1 files changed, 42 insertions, 0 deletions
diff --git a/bootstrap b/bootstrap
index 41d9725..ca40489 100755
--- a/bootstrap
+++ b/bootstrap
@@ -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"])),