actix-http: h1: stop pipelining when not reading full requests#3721
Merged
JohnTitor merged 8 commits intoactix:masterfrom Oct 5, 2025
Merged
Conversation
The existing pipelining behavior of the h1 dispatcher can cause client timeouts if the entire request body isn't read. It puts the dispatcher into a state where it refuses to read more (payload dropped) but there are still bytes in the buffer from the request body. This solution adds the SHUTDOWN flag in addition to the FINISHED flag when completing a response when both the following are true: 1. There are no messages in `this.messages` 2. There is still a payload in `this.payload` This combination implies two things. First, that we have not parsed a pipelined request after the request we have just responded to. Second, that the current request payload has not been fed an EOF. Because there are no pipelined requests, we know that the current request payload belongs to the request we have just responded to, and because the request payload has not been fed an EOF, we know we never finished reading it. When this occurs, adding the SHUTDOWN flag to the dispatcher triggers a `flush` and a `poll_shutdown` on the IO resource on the next poll.
robjtede
approved these changes
Aug 29, 2025
Contributor
Author
|
I've added a test that fails without the change and passes with the change. specifically the line that fails the test is the one that panics if the poll of h1 is not pending. With the change present, calling poll with an unfinished request shuts down the dispatcher. |
Contributor
Author
|
Is there anything else you want me to do on this PR? I see you approved it but I don't have permission to merge it :p |
Member
|
Nothing on top of mind, I just havent checked out the added test yet. |
5 tasks
JohnTitor
approved these changes
Oct 5, 2025
Member
JohnTitor
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the fix and detailed explanation!
5 tasks
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.
An alternate solution to #3715
The existing pipelining behavior of the h1 dispatcher can cause client timeouts if the entire request body isn't read. It puts the dispatcher into a state where it refuses to read more (payload dropped) but there are still bytes in the buffer from the request body.
This solution adds the SHUTDOWN flag in addition to the FINISHED flag when completing a response when both the following are true:
this.messagesthis.payloadThis combination implies two things. First, that we have not parsed a pipelined request after the request we have just responded to. Second, that the current request payload has not been fed an EOF. Because there are no pipelined requests, we know that the current request payload belongs to the request we have just responded to, and because the request payload has not been fed an EOF, we know we never finished reading it.
When this occurs, adding the SHUTDOWN flag to the dispatcher triggers a
flushand apoll_shutdownon the IO resource on the next poll.PR Type
Bug Fix
PR Checklist
Overview