diff --git a/.gitmodules b/.gitmodules index d8fc5ee..c0e0c62 100644 --- a/.gitmodules +++ b/.gitmodules @@ -105,5 +105,5 @@ ignore = dirty [submodule "deps/corehttp"] path = deps/corehttp - url = https://github.com/FreeRTOS/coreHTTP.git + url = https://github.com/alis-is/coreHTTP.git ignore = dirty diff --git a/config.hjson b/config.hjson index 252f7ab..a88d331 100644 --- a/config.hjson +++ b/config.hjson @@ -1,5 +1,5 @@ { - version: 0.32.0-dev + version: 0.32.0-dev.2 global_modules: false //disables global modules loading (only looks up for modules in cwd) minify: true compress: true diff --git a/deps/corehttp b/deps/corehttp index 76e516c..4f888ea 160000 --- a/deps/corehttp +++ b/deps/corehttp @@ -1 +1 @@ -Subproject commit 76e516c9116a9a04b6f8a144db526e0471cb687b +Subproject commit 4f888eaafc4fb6bdaacc96e82f10b747b7d9206a diff --git a/deps/lua-corehttp b/deps/lua-corehttp index 1a4d737..852ed06 160000 --- a/deps/lua-corehttp +++ b/deps/lua-corehttp @@ -1 +1 @@ -Subproject commit 1a4d737d40657488cbb36d54d4aa0f22f2c81c40 +Subproject commit 852ed06b690a83f232b76e3aa4729b8e49f84fef diff --git a/lib/eli/util.lua b/lib/eli/util.lua index 58e4c13..020a688 100644 --- a/lib/eli/util.lua +++ b/lib/eli/util.lua @@ -116,8 +116,8 @@ function util.generate_safe_functions(fnTable) if type(v) == "function" and not k:match"^safe_" then res["safe_" .. k] = function (...) local result = table.pack(pcall(v, ...)) - local msg, code = util.extract_error_info(result[2]) if not result[1] then + local msg, code = util.extract_error_info(result[2]) return result[1], msg, code end return table.unpack(result) diff --git a/lib/tests/net.lua b/lib/tests/net.lua index c39bca2..8ab5a5c 100644 --- a/lib/tests/net.lua +++ b/lib/tests/net.lua @@ -1,5 +1,6 @@ local test = TEST or require"u-test" local ok, eliNet = pcall(require, "eli.net") +local eliFs = require"eli.fs" -- https://postman-echo.com/ ? local HTTPBIN_URL = os.getenv"HTTPBIN_URL" or "https://httpbin.org/" @@ -56,6 +57,21 @@ test["download (progress)"] = function () test.assert(_printed:match"(%d+)%%", "no progress detected") end +test["download_large_file"] = function () + -- https://github.com/tez-capital/tezpay/releases/download/0.8.5-alpha/tezpay-linux-arm64 + -- 07728dbf002a5857d4ecb4b30995fac46d09ea2768680852678fbc222d2cf26e + + local ok, error = eliNet.safe_download_file( + "https://github.com/tez-capital/tezpay/releases/download/0.8.5-alpha/tezpay-linux-arm64", + "tmp/tezpay", { followRedirects = true }) + test.assert(ok, error) + + local ok, hash = eliFs.safe_hash_file("tmp/tezpay", { type = "sha256", hex = true }) + test.assert(ok, hash) + test.assert(hash == "07728dbf002a5857d4ecb4b30995fac46d09ea2768680852678fbc222d2cf26e", + "hashes do not match (" .. tostring(hash) .. "<>07728dbf002a5857d4ecb4b30995fac46d09ea2768680852678fbc222d2cf26e)") +end + test["download_file"] = function () local ok, error = eliNet.safe_download_file("https://raw.githubusercontent.com/alis-is/eli/main/LICENSE", "tmp/LICENSE") diff --git a/tools/patches/deps.lua b/tools/patches/deps.lua index 6915c76..c2eebb9 100644 --- a/tools/patches/deps.lua +++ b/tools/patches/deps.lua @@ -246,32 +246,32 @@ message( ${ZLIBINCLUDEDIR} ) return file end, }, - [CORE_HTTP_CLIENT_H] = { - validate = function (file) - return file:match"define CORE_HTTP_CLIENT_H_" - end, - patch = function (file) - -- injected code starts with /* injected eli corehttp patch */ - local injectedStart = file:find"/%* injected eli corehttp patch %*/" - if injectedStart then - file = file:sub(1, injectedStart - 1) - end - return file .. lustache:render(templates.CORE_HTTP_CLIENT_H, { config = config }) - end, - }, - [CORE_HTTP_CLIENT_C] = { - validate = function (file) - return file:match"sendHttpHeaders" and file:match"sendHttpHeaders" and file:match"sendHttpData" - end, - patch = function (file) - -- injected code starts with /* injected eli corehttp patch */ - local injectedStart = file:find"/%* injected eli corehttp patch %*/" - if injectedStart then - file = file:sub(1, injectedStart - 1) - end - return file .. lustache:render(templates.CORE_HTTP_CLIENT_C, { config = config }) - end, - }, + -- [CORE_HTTP_CLIENT_H] = { + -- validate = function (file) + -- return file:match"define CORE_HTTP_CLIENT_H_" + -- end, + -- patch = function (file) + -- -- injected code starts with /* injected eli corehttp patch */ + -- local injectedStart = file:find"/%* injected eli corehttp patch %*/" + -- if injectedStart then + -- file = file:sub(1, injectedStart - 1) + -- end + -- return file .. lustache:render(templates.CORE_HTTP_CLIENT_H, { config = config }) + -- end, + -- }, + -- [CORE_HTTP_CLIENT_C] = { + -- validate = function (file) + -- return file:match"sendHttpHeaders" and file:match"sendHttpHeaders" and file:match"sendHttpData" + -- end, + -- patch = function (file) + -- -- injected code starts with /* injected eli corehttp patch */ + -- local injectedStart = file:find"/%* injected eli corehttp patch %*/" + -- if injectedStart then + -- file = file:sub(1, injectedStart - 1) + -- end + -- return file .. lustache:render(templates.CORE_HTTP_CLIENT_C, { config = config }) + -- end, + -- }, [LUA_COREHTTP_CONFIG_H] = { validate = function (file) return file:match"HTTP_USER_AGENT_VALUE"