Skip to content

Release a partially read HTTP/1 request body after the response - #256

Closed
andrewfader wants to merge 1 commit into
socketry:mainfrom
andrewfader:release-partially-read-request-body
Closed

andrewfader wants to merge 1 commit into
socketry:mainfrom
andrewfader:release-partially-read-request-body

Conversation

@andrewfader

@andrewfader andrewfader commented Oct 23, 2026 •

Copy link
Copy Markdown

When an application reads part of an HTTP/1 request body and then responds without reading the rest (for example, rejecting an upload), Finishable#wait waits for that body to close, with no timeout. The connection hangs until the client goes away. See #213.

This changes wait to release a partially read body after the response is sent, the same way it already handles an unread one: discard it when the connection is persistent, otherwise close it. Test added.

This breaks 2 existing tests, both the shared "an echo client" example: test/protocol/http/body/stream.rb and test/protocol/http/body/streamable.rb (HTTP/1). That app closes its response and then keeps reading the request body in another task, which this change discards out from under it, so the tests time out. Opening as a draft to ask which layer you'd rather fix this in: async-http's Finishable here, or protocol-rack's response handling (socketry/protocol-rack#41).

Signed-off-by: Andrew Fader <fader@yagni.co>
@ioquatix

Copy link
Copy Markdown
Member

If you partially read an input body, you must either (1) completely read it or (2) close it.

@andrewfader
andrewfader deleted the release-partially-read-request-body branch October 23, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants