replace lua-socket depedency with lua-http
At the moment we are using two packages for HTTP requests from Lua:
- lua-socket (Lua library
- lua-http (Lua library
This complicates packaging and is generally unnecessary.
It seems that package lua-socket (Lua library
ssl.https) offers only blocking API, and that is causing problems like e.g. #512 (closed), so let's replace
It should "accidentally" fix #512 (closed) and also make packaging easier.
- prefill (#512 (closed))
- trust_anchors bootstrap
- possibly others
Example of a non-blocking HTTP request:
function blacklist_reload() local url = 'https://raw.githubusercontent.com/CSNOG/MFCR-blacklist/master/blacklist.txt' local headers, stream = http_request.new_from_uri(uri):go() assert(headers, 'HTTP client library error') assert(tonumber(headers:get(':status')) == 200, string.format('HTTP status %s instead of expected 200\n', headers:get(':status'))) local tmpfile = stream:get_body_as_file(5) assert(tmpfile, 'error while getting blacklist HTTP body in limit 5 seconds') end worker.bg_worker.cq:wrap(blacklist_reload)
Error handling needs more work etc.