diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-11-10 16:50:06 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-11-10 16:50:06 +0000 |
commit | d05f19b2ad19507200d956825bb7596577cc0c84 (patch) | |
tree | 48eadfb3ecdee18dc7249e73780666b27b0805c0 | |
parent | 49ac5dc701e8d5628284a50ada4e49c3febe9ea1 (diff) | |
download | gitano-d05f19b2ad19507200d956825bb7596577cc0c84.tar.gz |
ACTIONS: Remove assert()s from the HTTP client to increase resilience
-rw-r--r-- | lib/gitano/actions.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/gitano/actions.lua b/lib/gitano/actions.lua index d6f70f7..4f99878 100644 --- a/lib/gitano/actions.lua +++ b/lib/gitano/actions.lua @@ -65,16 +65,24 @@ local function http_txn(method, host, path, headers, body) local req = table.concat(req_lines, "\r\n") log.ddebug("Write request") log.ddebug(req) - assert(sock:write(req)) + local ok, msg = sock:write(req) + if not ok then + sock:close() + return "500", msg, {}, "" + end if body and body ~= "" then log.ddebug("Writing body of request:") log.ddebug(body) - assert(sock:write(body)) + ok, msg = sock:write(body) + if not ok then + sock:close() + return "500", msg, {}, "" + end end log.ddebug("Read response") local response = assert(sock:read "*a") - assert(sock:close()) + sock:close() local code, msg, _headers, content = response:match("^HTTP/1.[01] (...) ?([^\r\n]+)\r?\n(.-)\r?\n\r?\n(.*)$") local headers = {} |