|
|
@ -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"])), |
|
|
|