Skip to content

[Help] How to copy Request<Incoming> for useing sender.send_request and hyper::upgrade::on for web soket proxy at the same time #3352

Closed Answered by seanmonstar
thedtvn asked this question in Q&A
Discussion options

You must be logged in to vote

So, first you need to make req be mut req in the argument list, in order to mutate it. You don't need to grab the upgrade future and await it at the same time. So, you could do:

let on_req_upgrade = hyper::upgrade::on(&mut req);
// ...
let mut resp = sender.send_request(req).await?;
tokio::task::spawn(async move {
    let _upgraded_req = on_req_upgrade.await;
    let _upgraded_resp = hyper::upgrade::on(&mut resp).await;
});

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@thedtvn
Comment options

Answer selected by thedtvn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3349 on October 18, 2023 12:47.