-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BodyTimeout middleware #295
Labels
A-new-middleware
Area: new middleware proposals
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
E-easy
Call for participation: Experience needed to fix: Easy / not much
Comments
seanmonstar
added
A-new-middleware
Area: new middleware proposals
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
E-easy
Call for participation: Experience needed to fix: Easy / not much
labels
Sep 28, 2022
@82marbag here's what we discussed. We can add more details here if needed. |
It would be nice if this middleware could also handle streams that respond but only send a drip feed of data |
I made a draft PR a while back that looked into this a bit, linking here in case it's useful |
82marbag
pushed a commit
to 82marbag/tower-http
that referenced
this issue
Oct 11, 2022
Closes tower-rs#295 Add a timeout on inactive bodies, both on request and response bodies. Signed-off-by: Daniele Ahmed <[email protected]> Co-authored-by: Harry Barber <[email protected]>
Merged
LucioFranco
pushed a commit
that referenced
this issue
Oct 31, 2022
## Motivation Explained in #295. This PR closes #295. ## Solution Wrap the body in a `TimeoutBody`. `TimeoutBody` will poll a sleep future to check whether the body is inactive and register itself to be awoken. The sleep future is polled and checked right after creation to avoid a potential delay in execution making the executor to never poll the sleep future again. That is, if between creation and `poll` on sleep the time runs out and the sleep is done, a timeout error is immediately returned Co-authored-by: Daniele Ahmed <[email protected]> Co-authored-by: Harry Barber <[email protected]>
Turbo87
added a commit
to Turbo87/crates.io
that referenced
this issue
Oct 20, 2023
This middleware acts roughly similar to http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout and ensures that there is a timeout applied when reading request bodies. see tower-rs/tower-http#295
Turbo87
added a commit
to Turbo87/crates.io
that referenced
this issue
Oct 20, 2023
Turbo87
added a commit
to Turbo87/crates.io
that referenced
this issue
Oct 20, 2023
This middleware acts roughly similar to http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout and ensures that there is a timeout applied when reading request bodies. see tower-rs/tower-http#295
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-new-middleware
Area: new middleware proposals
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
E-easy
Call for participation: Experience needed to fix: Easy / not much
Feature Request
Motivation
Besides the larger service timeouts, it's also common for people to want to add a timeout to the reading of chunks from a body, either for the request as a server, or for the response of a client.
Proposal
timeout
module a folder, with service and body timeout files.struct TimeoutBody<B>
.Body for TimeoutBody<B> where B: Body
, such that polling for data will check the inner body poll, and also a timeout.RequestBodyTimeout
andResponseBodyTimeout
layers can be added (Service
andLayer
) which essentially do whatMapRequest
andMapResponse
do, wrapping theRequest<B>
intoRequest<TimeoutBody<B>>
(and same with response).The text was updated successfully, but these errors were encountered: