http module swallows io.ReadAll error on response body #169
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Where
internal/atis/http.go, inhttpReq(around lines 148-160):Reason
isErris a local variable that was already used and settled earlier in the function, during header validation (header.ForEach(...)), and isfalseat this point in the code (otherwise the function would already have returned). The real error fromio.ReadAll(resp.Body)is bound toerrbut is never actually checked — the code checks the staleisErrflag instead.As a result, if reading the response body fails (connection drop mid-read, timeout, etc.), the function silently returns success (
nilerror) with a partial or emptybody, and the calling Lua script has no way to know the read failed.Suggested fix
Check the actual error from the read:
(Note:
resp.Body.Close()is currently deferred after the read — fine functionally, but worth moving before the read/right after checkingrespis non-nil, for clarity/consistency with the rest of the codebase.)