From b931d668e20d3822d667e576b6b4f632e9c84881 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 29 May 2026 21:48:29 -0400 Subject: [PATCH] Fix pcall return value handling in HTTP client pcall wraps socket.http.request returns as: true, 1, status_code, headers, status_line The old code captured '1' as the status code instead of the actual HTTP status. Added '_' to skip the first return. --- BookhoardAPI.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BookhoardAPI.lua b/BookhoardAPI.lua index 8aedcec..d3b1d2f 100644 --- a/BookhoardAPI.lua +++ b/BookhoardAPI.lua @@ -59,23 +59,23 @@ function BookhoardAPI:_request(method, path, body, timeouts) socketutil:set_timeout(timeouts[1], timeouts[2]) - local ok, code + local ok, _, code if url:match("^https://") then if ssl_ok then - ok, code = pcall(ssl_https.request, request) + ok, _, code = pcall(ssl_https.request, request) else socketutil:reset_timeout() return false, { error = "HTTPS not supported on this device" } end else - ok, code = pcall(http.request, request) + ok, _, code = pcall(http.request, request) end socketutil:reset_timeout() if not ok then - logger.warn("BookhoardAPI: request failed:", code) - return false, { error = tostring(code) } + logger.warn("BookhoardAPI: request failed:", _) + return false, { error = tostring(_) } end local response_body = table.concat(sink)