Skip to content

feat(server): separate H1 idle timeout to supplement header read timeout - #4293

Open
finnbear wants to merge 2 commits into
hyperium:masterfrom
finnbear:idle_timeout2
Open

finnbear wants to merge 2 commits into
hyperium:masterfrom
finnbear:idle_timeout2

Conversation

@finnbear

@finnbear finnbear commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The motivation (which doesn't apply to my use case, but does implicate my earlier header read timeout PR) is to make hyper servers more friendly for clients that send requests with gaps in between (by supporting a long idle timeout), without exposing a server to DoS (by forcing a long header timeout). See #3828 (comment) for more.

Behavior

Changes in bold.

  1. client connects
  2. start header read timeout [new: the timer allocation is re-used from a request]
    • if it elapses, connection is closed
  3. client sends request
  4. server responds
  5. start idle timeout [new, this used to be start header read timeout]
    • if it elapses, connection is closed
  6. server sees the client sent at least 4 bytes towards another request
  7. repeat (back to step 2, which starts a new header read timer) [new, the old header read timeout used to cover both the idle period and the request transmission]

This is behavior is similar to Go's net/http.

The default idle timeout is set at 60s, next to a default of 30s for header read timeout.

Implications

Security

A user who lowered header_read_timeout to mitigate DoS must consider whether idle_timeout must also be lowered to mitigate DoS.

Performance

According to a benchmark in #4285, timer allocation re-use may double throughput when timers are used. I did not benchmark this PR separately.

Future work

  • hyper_util needs a setter for idle_timeout.

Links

Idle timeout (commit 1)

This PR is a followup to #3828 (comment) and #3828 (comment)
Related #1628
Supersedes #2827
Fixes #2355 better
Simplification of #3743

Timer allocation reuse (commit 2)

Fixes #4280
Supersedes #4288
Supersedes #4285

Attestation

@zhniu zhniu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I think this PR can fixes my issue.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP/1 server: the header read timer is re-created for every request add conn_idle_timeout for server

2 participants