Feature request: send proto upgrade `Response` from handler.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.3k
- Forks
- 1.8k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 14
Description
The upgrade example from 1.0.0-rc.3 looks odd (in my opinion).
In web socket context, If the server decides to upgrade the connection, It just send a 101 Switching Protocols response, and immediately use internal TCP as WebSocket protocol.
No need for extra task::spawn:
https://github.com/hyperium/hyper/blob/9ed175d1545fa338b6212c4f48be9b3d12821c7a/examples/upgrades.rs#L58-L59
Sure, Its only possible, If there is an option to write response directly (rather then returning writable Response object)
Maybe add such API ?
For example:
async handle(req: Request<Incoming>) -> Result<Response<..> {
match hyper::upgrade::send_response_and_upgrade(resp_body, req).await {
Err(msg) => eprintln!("upgrade error: {msg}"),
Ok(upgraded) => { ... }
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/upgrades.rs and the linked upgrade flow to understand why the extra task::spawn is used. Evaluate the proposed hyper::upgrade::send_response_and_upgrade API against the current handler response model. Done means a supported way to send the 101 response and obtain the upgraded connection directly, with the upgrade example reflecting the resulting flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design, networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100