feat: polymorphic helper for request body streaming#485
Open
tank-bohr wants to merge 3 commits intoelixir-mint:mainfrom
Open
feat: polymorphic helper for request body streaming#485tank-bohr wants to merge 3 commits intoelixir-mint:mainfrom
tank-bohr wants to merge 3 commits intoelixir-mint:mainfrom
Conversation
Remove a redundant HTTP/1 test (HTTP/1 only permits one streaming request at a time, so the "different ref while streaming" case collapses into the existing make_ref() test). Add an HTTP/2 end-to-end test that exercises the documented streaming loop across multiple iterations with a body larger than the initial window, processing WINDOW_UPDATE frames between chunks.
ericmj
reviewed
Apr 30, 2026
Member
ericmj
left a comment
There was a problem hiding this comment.
This looks great, thanks for pushing this through and for sticking with this through multiple revisions.
I left two comments about documentation only.
| flow-control mechanism: any amount of body data is protocol-valid. The | ||
| operating-system socket send buffer may still cause `stream_request_body/3` | ||
| to block once it fills up, but that is a transport concern and not | ||
| reflected here. |
Member
There was a problem hiding this comment.
This is a good note to make but it's not H1 specific. In general we cannot guarantee non-blocking unless you set send_timeout on the socket through transport_opts.
| with {:ok, conn} <- Mint.HTTP.stream_request_body(conn, ref, chunk) do | ||
| stream_body(conn, ref, rest) | ||
| end | ||
| end |
Member
There was a problem hiding this comment.
There are two issues with this code example.
- We can return 0 from
request_body_window/2so you can attempt to send an empty binary. - There is no backpressure, if there is no window available we will be busy looping, consuming CPU resources.
The latter can be hard to express in a code example because there are many different solutions to it depending on context, so maybe we should just call it out?
Contributor
Author
There was a problem hiding this comment.
Great catch! Fixed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #484 (comment) for details