Skip to content

Add early data to seekable request bodies - #194

Open
guoye-zhang wants to merge 1 commit into
apple:mainfrom
guoye-zhang:early-data
Open

guoye-zhang wants to merge 1 commit into
apple:mainfrom
guoye-zhang:early-data

Conversation

@guoye-zhang

Copy link
Copy Markdown
Collaborator

A client that sends a request in TLS early data (0-RTT, RFC 8470) has to send the start of the body with the request head, before the connection is established, and a seekable body's produce(offset:into:) can only deliver it after the client has a writer for the connection. HTTPEarlyData holds the first bytes of a body and whether they're the whole body, and a seekable body can provide it through earlyData, an optional async closure. A client that sends the early data continues the body from its end with produce(offset:into:), unless it was the whole body; nil means none is available and the body is produced from the start.

seekable(knownLength:earlyData:_:) takes it, defaulting to nil; restartable bodies have none; mapping a body to another writer keeps it.

A client that sends a request in TLS early data (0-RTT, RFC 8470) has to
send the start of the body with the request head, before the connection is
established, and a seekable body's `produce(offset:into:)` can only deliver
it after the client has a writer for the connection. `HTTPEarlyData` holds
the first bytes of a body and whether they're the whole body, and a
seekable body can provide it through `earlyData`, an optional async
closure. A client that sends the early data continues the body from its
end with `produce(offset:into:)`, unless it was the whole body; nil means
none is available and the body is produced from the start.

`seekable(knownLength:earlyData:_:)` takes it, defaulting to nil;
restartable bodies have none; mapping a body to another writer keeps it.
@guoye-zhang guoye-zhang added the ⚠️ semver/major Breaks existing public API. label Oct 14, 2026
@FranzBusch

Copy link
Copy Markdown
Member

Why do we limit this to seekable requests only?

@guoye-zhang

Copy link
Copy Markdown
Collaborator Author

When early data is accepted but it’s not the complete body, we need to continue uploading from where it ended so it must be seekable. We usually send the first ~10KB in early data.

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

Labels

⚠️ semver/major Breaks existing public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants