actix-web/actix-http/src/h1
asonix 4df9953c86
actix-http: h1: stop pipelining when not reading full requests (#3721)
* actix-http: h1: stop pipelining when not reading full requests

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.

* Remove printlns from dispatcher

* Add test that fails without changes & passes with changes

* Add changelog entry for h1 shutdown

---------

Co-authored-by: Rob Ede <robjtede@icloud.com>
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2025-10-05 01:07:35 +00:00
..
chunked.rs address clippy lints 2023-01-01 20:56:34 +00:00
client.rs update bitflags to v2 2023-05-06 11:38:51 +01:00
codec.rs build(deps): bump taiki-e/install-action from 2.26.18 to 2.27.2 (#3294) 2024-02-19 12:31:10 +00:00
decoder.rs build(deps): bump taiki-e/install-action from 2.26.18 to 2.27.2 (#3294) 2024-02-19 12:31:10 +00:00
dispatcher.rs actix-http: h1: stop pipelining when not reading full requests (#3721) 2025-10-05 01:07:35 +00:00
dispatcher_tests.rs actix-http: h1: stop pipelining when not reading full requests (#3721) 2025-10-05 01:07:35 +00:00
encoder.rs chore: address clippy lints 2025-05-09 20:21:02 +01:00
expect.rs split request and response modules (#2530) 2021-12-19 17:05:27 +00:00
mod.rs apply standard formatting 2023-07-17 02:38:12 +01:00
payload.rs fix(http): Wake Payload when feeding error or EOF (#3749) 2025-08-29 02:47:03 +00:00
service.rs chore: disallow e bindings 2024-08-10 05:15:49 +01:00
timer.rs use tracing in actix-http 2022-03-10 03:12:29 +00:00
upgrade.rs split request and response modules (#2530) 2021-12-19 17:05:27 +00:00
utils.rs relax unpin bounds on payload types (#2545) 2021-12-24 17:47:47 +00:00