Skip to content

fix(body-reader): do not call sock:receive for reading 0 bytes - #313

Open
Tieske wants to merge 2 commits into
ledgetech:masterfrom
Tieske:fix/zero-length
Open

fix(body-reader): do not call sock:receive for reading 0 bytes#313
Tieske wants to merge 2 commits into
ledgetech:masterfrom
Tieske:fix/zero-length

Conversation

@Tieske

@Tieske Tieske commented Mar 18, 2024

Copy link
Copy Markdown
Contributor

Some sockets can block if called to read 0 bytes until actual bytes are available to read.

@Tieske

Tieske commented Mar 18, 2024

Copy link
Copy Markdown
Contributor Author

note that in the same code, slightly further down; we only read if length > 0

@Tieske

Tieske commented May 8, 2024

Copy link
Copy Markdown
Contributor Author

@pintsized any chance to get this merged?

Comment thread lib/resty/http.lua Outdated
Comment thread lib/resty/http.lua
@sriemer
sriemer self-requested a review August 11, 2026 09:11
@sriemer sriemer self-assigned this Aug 11, 2026
@sriemer

sriemer commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@Tieske Thanks for your contribution. Hi, I'm a new maintainer and drove the latest 0.18 release.
Seems like this is still relevant to you. Can you please add a test that fails without the fix and succeeds with the fix? TIA
For the development setup you can follow https://github.com/ledgetech/lua-resty-http/blob/master/DOCKER_BUILD.md for your convenience. TIA

@sriemer sriemer added the bugfix label Aug 11, 2026
@Tieske

Tieske commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

I've just recently looked into this again. And it seems that actually luasocket is at fault. POSIX defines that a 0-byte read should return immediately, which luasocket doesn't do.

Tieske added 2 commits August 11, 2026 23:36
Some sockets can block if called to read 0 bytes until actual
bytes are available to read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants