feat(android): add httpPost bridge for mod.postLog log sends

Android ships no curl and the JNI bridge was GET-only, so mod.postLog
failed there with 'no POST transport on this platform' (HostShell.lua).
Add the mirror of httpDownload: GameActivity.httpPost (https-only,
hand-followed redirects re-POSTing the body, one-way), the JNI bridge
with the same old-APK-skew tolerance, the love.system.httpPost binding,
and the HostShell arm that rides it when curl is absent. The body
crosses the JNI as raw bytes (jbyteArray) so a log ring with arbitrary
UTF-8 cannot corrupt through modified-UTF-8 jstring conversion.
This commit is contained in:
Shane McGovern
2026-08-16 20:23:19 +01:00
parent 46f73b7bb3
commit 0b00faf38e
7 changed files with 177 additions and 3 deletions
+15 -3
View File
@@ -452,9 +452,11 @@ end
-- POST returning success/failure. Strictly one-way: the response body is
-- discarded, only the HTTP status class is surfaced (postLog callers never
-- trust the reply). curl --data-binary reads the payload from a pipe, so a
-- large body never lands in the command line; the Android bridge has no POST
-- transport, and httpPost reports that instead of half-working through
-- httpDownload (a GET round-trip to a POST endpoint would be a lie).
-- large body never lands in the command line; where curl is absent (Android
-- and the other bridge-only platforms) the POST rides the JNI bridge --
-- love.system.httpPost, the dedicated POST arm added beside httpDownload --
-- instead of half-working through httpDownload (a GET round-trip to a POST
-- endpoint would be a lie).
function HostShell.httpPost(url, body, contentType, userAgent, maxTime)
if type(url) ~= "string" or url == "" then return nil, "missing url" end
if type(body) ~= "string" then return nil, "missing body" end
@@ -530,6 +532,16 @@ function HostShell.httpPost(url, body, contentType, userAgent, maxTime)
if not haveBridge() then
return nil, "no network transport on this platform"
end
-- The GET bridge has no POST; the dedicated love.system.httpPost arm
-- (GameActivity.httpPost) is the transport where curl is missing. A
-- build without it reports the same "no POST transport" a missing curl
-- would -- the old-APK skew path in the JNI bridge returns false.
if love.system and type(love.system.httpPost) == "function" then
local ok, sent = pcall(love.system.httpPost, url, body, contentType,
userAgent)
if ok and sent then return true end
return nil, "log post rejected"
end
return nil, "no POST transport on this platform"
end