Skip to content

Commit

Permalink
fix(body-reader): do not call sock:receive for reading 0 bytes
Browse files Browse the repository at this point in the history
Some sockets can block if called to read 0 bytes until actual
bytes are available to read.
  • Loading branch information
Tieske committed Mar 18, 2024
1 parent 1833103 commit 8311216
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/resty/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ local function _body_reader(sock, content_length, default_chunk_size)

elseif not max_chunk_size then
-- We have a length and potentially keep-alive, but want everything.
if content_length == 0 then
co_yield("")
end
co_yield(sock:receive(content_length))

else
Expand Down

0 comments on commit 8311216

Please sign in to comment.