@@ -23,7 +23,7 @@ local HTTP_MAX_BODY = tonumber(os.getenv "ARWEAVE_HTTP_MAX_BODY" or "1048576") -
2323local EXPECT_RESPONSE_HASH = os.getenv " ARWEAVE_EXPECT_RESPONSE_HASH"
2424local FORCE_ERROR = os.getenv " ARWEAVE_FORCE_ERROR" == " 1"
2525local RESPONSE_PATTERN = os.getenv " ARWEAVE_RESPONSE_PATTERN" or ' ^%s*%{"'
26- local ok_cjson_safe , cjson_safe = pcall (require , " cjson.safe" )
26+ local _ , cjson_safe = pcall (require , " cjson.safe" )
2727local cjson = cjson_safe or require " cjson" -- required dependency
2828local schema = require " ao.shared.schema"
2929local openssl_ok , openssl = pcall (require , " openssl" )
@@ -93,10 +93,15 @@ local function http_post(serialized, tx)
9393 local response_path = string.format (" %s/%s-response.json" , REQUEST_LOG , tx )
9494 local auth_header = API_KEY and (' -H "Authorization: Bearer ' .. API_KEY .. ' "' ) or " "
9595 local signer_header = SIGNER and (' -H "' .. HTTP_SIGNER_HEADER .. " : " .. SIGNER .. ' "' ) or " "
96+ local curl_fmt = table.concat ({
97+ ' echo %q | curl -s -o "%s" -w "%%{http_code}"' ,
98+ ' -H "Content-Type: application/json"%s%s' ,
99+ ' --max-time %d -X POST "%s" --data-binary @-' ,
100+ }, " " )
96101 local status
97102 for attempt = 1 , HTTP_RETRIES do
98103 local cmd = string.format (
99- ' echo %q | curl -s -o "%s" -w "%%{http_code}" -H "Content-Type: application/json"%s%s --max-time %d -X POST "%s" --data-binary @- ' ,
104+ curl_fmt ,
100105 serialized ,
101106 response_path ,
102107 auth_header ,
@@ -270,12 +275,7 @@ if MODE == "http" then
270275 local httpStatus , response_path
271276 if FORCE_ERROR then
272277 httpStatus = 500
273- elseif
274- HTTP_REAL
275- and ENDPOINT
276- and has_curl ()
277- and not (os.getenv " ARWEAVE_HTTP_DRYRUN" == " 1" )
278- then
278+ elseif HTTP_REAL and ENDPOINT and has_curl () and os.getenv " ARWEAVE_HTTP_DRYRUN" ~= " 1" then
279279 if not signer_exists () then
280280 log_request (tx , {
281281 endpoint = ENDPOINT or " <missing-endpoint>" ,
@@ -328,7 +328,7 @@ if MODE == "http" then
328328 end
329329 local ok_schema , err_schema = schema .validate (" arweaveResponse" , parsed )
330330 if not ok_schema then
331- log_request (tx , { warning = " response_schema_invalid" })
331+ log_request (tx , { warning = " response_schema_invalid" , errors = err_schema })
332332 return nil , " http_response_schema_invalid"
333333 end
334334 local resp_hash = sha256 (body )
0 commit comments