fix(server): start h1 header read timeout when conn is idle, a de facto idle timeout#3828
Merged
seanmonstar merged 3 commits intohyperium:masterfrom Jan 27, 2025
Merged
Conversation
8 tasks
Member
|
For the record (even if just for future me), merging this allows a potential future addition of an |
seanmonstar
approved these changes
Jan 27, 2025
GlenDC
added a commit
to plabayo/rama
that referenced
this pull request
Feb 20, 2025
- ext: add ext::on_informational() callback extension (<hyperium/hyper#3818>) (<hyperium/hyper@8ce1fcf>, closes <hyperium/hyper#2565>) - server: add http1::Builder::ignore_invalid_headers(bool) option (<hyperium/hyper#3824>) (<hyperium/hyper@3817a79>) - server: - start http1 header read timeout when conn is idle (<hyperium/hyper#3828>) (<hyperium/hyper@10b09ff>, closes <hyperium/hyper#3780>, <hyperium/hyper#3781>) - change max_local_error_reset_streams function to &mut self (#3820) (e981a91e) - http2::Builder::max_local_error_reset_streams() now takes &mut self and returns &mut Self. In practice, this shouldn't break almost anyone. It was the wrong receiver and return types. (<hyperium/hyper@e981a91>) Co-authored-by: Sean McArthur <[email protected]> Co-authored-by: Finn Bear <[email protected]> Co-authored-by: tottoto <[email protected]>
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.
Motivation
Currently, the header read timeout is started before any part of the first request is received. This allows closing the connection if no requests are received. However, after the first request, the connection can remain open indefinitely. This change ensures that the header read timeout is started immediately after the connection is idle, following the transmission of the response, before the first part of the subsequent request is received.
This is particularly relevant in the case that browsers open 6+ h1 connections when a page loads and then neglect to close any of them, distracting, in my case, from DDoS attackers.
This is kind of like an "idle timeout"
Changes
header_read_timeoutwhen waiting for subsequent requestsError::is_timeoutreturns true onHeaderTimeoutTests
header_read_timeout_slow_writesheader_read_timeout_slow_writes_multiple_requestsOpen question
Should the documentation of
header_read_timeoutchange? It currently doesn't say when the timeout is started, only when it finishes (client transmits entire header).Related
Related: #1628
Related/Fixes: #2355
Related #3185 (comment)
Builds on and supersedes/Closes #3781 (credit to @T-aian)
Fixes #3780
Supersedes #3743 (this PR required additional complexity, but allowed a different value for the header read timeout and the idle timeout)