Problem
For a response without Content-Length, calling body_reader(max_chunk_size) enters the streaming branch of _body_reader.
If sock:receive(max_chunk_size) returns a non-closed error such as:
the current implementation skips the special closed branch and then yields only str, which is nil:
local str, err, partial = sock:receive(max_chunk_size)
if not str and err == "closed" then
co_yield(partial, err)
end
max_chunk_size = tonumber(co_yield(str) or default_chunk_size)
The caller therefore observes nil, nil, which is indistinguishable from a successful end of body. The original error and any partial data are discarded.
This behavior is present in both v0.2.3 and the current master branch.
Expected behavior
A timeout or other socket read failure should be returned to the caller rather than being reported as a successful end of body. The behavior for connection-close-delimited EOF should remain distinguishable so consumers can handle that framing correctly.
Reproduction shape
Use a response with no Content-Length and no chunked transfer encoding, send fewer bytes than the requested reader size, and keep the connection open beyond the configured read timeout:
local chunk, err = res.body_reader(8192)
-- Current: chunk == nil, err == nil
-- Expected: err == "timeout"
A focused reader test with a socket stub returning nil, "timeout", "partial" should also reproduce the issue.
Problem
For a response without
Content-Length, callingbody_reader(max_chunk_size)enters the streaming branch of_body_reader.If
sock:receive(max_chunk_size)returns a non-closederror such as:the current implementation skips the special
closedbranch and then yields onlystr, which isnil:The caller therefore observes
nil, nil, which is indistinguishable from a successful end of body. The original error and any partial data are discarded.This behavior is present in both
v0.2.3and the currentmasterbranch.Expected behavior
A timeout or other socket read failure should be returned to the caller rather than being reported as a successful end of body. The behavior for connection-close-delimited EOF should remain distinguishable so consumers can handle that framing correctly.
Reproduction shape
Use a response with no
Content-Lengthand no chunked transfer encoding, send fewer bytes than the requested reader size, and keep the connection open beyond the configured read timeout:A focused reader test with a socket stub returning
nil, "timeout", "partial"should also reproduce the issue.