Skip to content

Don't re-arm the read header timeout while a response is in flight - #154

Merged
fabianfett merged 2 commits into
swift-server:mainfrom
fabianfett:ff-read-header-timeout-streaming
Oct 22, 2026
Merged

fabianfett merged 2 commits into
swift-server:mainfrom
fabianfett:ff-read-header-timeout-streaming

Conversation

@fabianfett

Copy link
Copy Markdown
Member

Motivation

On HTTP/1.1, the read header timeout was re-armed on request .end. For bodyless requests, that happens before the response is written, so any response streaming longer than 30s (e.g. Server-Sent Events) was closed.

Changes

RequestTimeoutHandler now also observes outbound response parts. It re-arms the header timeout only after both the request and the response have ended.

Result

Streaming responses stay open. Keep-alive connections are still protected between requests.

### Motivation

On HTTP/1.1, the read header timeout was re-armed on request `.end`. For bodyless requests, that happens before the response is written, so any response streaming longer than 30s (e.g. Server-Sent Events) was closed.

### Changes

`RequestTimeoutHandler` now also observes outbound response parts. It re-arms the header timeout only after both the request and the response have ended.

### Result

Streaming responses stay open. Keep-alive connections are still protected between requests.
@fabianfett fabianfett added the 🔨 semver/patch No public API change. label Oct 21, 2026
Comment thread Sources/NIOHTTPServer/TimeoutHandlers.swift Outdated
Co-authored-by: Aryan Shah <aryan_shah@apple.com>
@fabianfett
fabianfett enabled auto-merge (squash) October 22, 2026 12:17
@fabianfett
fabianfett merged commit 7e38711 into swift-server:main Oct 22, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants