aboutsummaryrefslogtreecommitdiffstats
path: root/core/core.mk
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-05-10 12:25:00 +0300
committerLoïc Hoguin <[email protected]>2015-05-10 12:25:00 +0300
commita61e6a06b59e7836f479c14af13c94f3c04beedb (patch)
tree30b31aeea614fe801843746c45e96799b0b75cd9 /core/core.mk
parentd996a413b5fed3bada2fc6ada762292fa7ce0a88 (diff)
downloaderlang.mk-a61e6a06b59e7836f479c14af13c94f3c04beedb.tar.gz
erlang.mk-a61e6a06b59e7836f479c14af13c94f3c04beedb.tar.bz2
erlang.mk-a61e6a06b59e7836f479c14af13c94f3c04beedb.zip
Convert the Erlang version of core_http_get to an Erlang snippet
Diffstat (limited to 'core/core.mk')
-rw-r--r--core/core.mk17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/core.mk b/core/core.mk
index a240abd..473013f 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -99,8 +99,23 @@ define core_http_get
wget --no-check-certificate -O $(1) $(2)|| rm $(1)
endef
else
+define core_http_get.erl
+ ssl:start(),
+ inets:start(),
+ case httpc:request(get, {"$(2)", []}, [{autoredirect, true}], []) of
+ {ok, {{_, 200, _}, _, Body}} ->
+ case file:write_file("$(1)", Body) of
+ ok -> ok;
+ {error, R1} -> halt(R1)
+ end;
+ {error, R2} ->
+ halt(R2)
+ end,
+ halt(0).
+endef
+
define core_http_get
- $(ERL) -eval 'ssl:start(), inets:start(), case httpc:request(get, {"$(2)", []}, [{autoredirect, true}], []) of {ok, {{_, 200, _}, _, Body}} -> case file:write_file("$(1)", Body) of ok -> ok; {error, R1} -> halt(R1) end; {error, R2} -> halt(R2) end, halt(0).'
+ $(call erlang,$(call core_http_get.erl,$(1),$(2)))
endef
endif