diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2016-05-30 13:56:13 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2016-05-30 13:56:13 +0100 |
commit | dba74f394e9e35d81c5ae6419fd9ccb0715a8547 (patch) | |
tree | dd910896f7bba86cdc6dc71d350397912688ac94 /lib | |
parent | 705bd90caf11f97943374a14fa898a82f3ca52a9 (diff) | |
download | gitano-dba74f394e9e35d81c5ae6419fd9ccb0715a8547.tar.gz |
Ensure curl operations are pcall'd
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitano/actions.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitano/actions.lua b/lib/gitano/actions.lua index 06b5af7..264fa48 100644 --- a/lib/gitano/actions.lua +++ b/lib/gitano/actions.lua @@ -42,7 +42,7 @@ local function update_actions(conf, repo, tags) return true end -local function curl_txn(url, headers, body, content_type) +local function _curl_txn(url, headers, body, content_type) local method = (body and body ~= "") and "POST" or "GET" local args = { "curl", "--max-filesize", tostring(1024*1024), "--insecure", "-X", method, "-D-", "-s" } @@ -90,6 +90,13 @@ local function curl_txn(url, headers, body, content_type) return code, msg, headers, content end +local function curl_txn(...) + local ok, code, msg, headers, content = pcall(_curl_txn, ...) + if not ok then + code, msg, headers, content = "500", code, {}, "" + end + return code, msg, headers, content +end local function http_get(host, path) log.warn("Hook using legacy http_get or http.get, please update to use new fetch() interface") |