Skip to content

feat(client): Add Expect: 100-continue body wrapper - #321

Open
bountis wants to merge 1 commit into
hyperium:masterfrom
bountis:feat/client-expect-continue
Open

bountis wants to merge 1 commit into
hyperium:masterfrom
bountis:feat/client-expect-continue

Conversation

@bountis

@bountis bountis commented Sep 12, 2026

Copy link
Copy Markdown

Add a request body wrapper which handles the Expect: 100-continue header flow.
https://www.rfc-editor.org/rfc/rfc9110.html#name-expect

Also adds a utility wrap which wraps a request body in ExpectContinueBody, adds the Expect: 100-continue header if not present, adds an on_informational hook which signals to release the body.
The poll_frame implementation parks the body until a signal is received/cancelled or a configured timeout elapses.

Tests and a small example are added which demonstrate the behavior.

Closes hyperium/hyper#3833

/// Registers an `on_informational` hook that releases the body on a 100.
pub fn wrap<B>(
req: Request<B>,
sleep: Option<Pin<Box<dyn Sleep>>>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why accept an Option? Should we not nudge people harder to supply a timeout?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hmm, yes, this should probably be stricter and require a timeout as the RFC also states that client SHOULD NOT wait for an indefinite period before sending the content.

I can modify wrap then to accept a timer + a duration. ExpectContinueBody::new can probably continue to accept the option since it's private to the crate and the signal/cancel tests use None, or do you want me to change that too?

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.

Add hyper-util helpers to support handling expect: 100-continue header

2 participants