Closed gaoyia closed 2 months ago
I am using rocket_ws. I need to fetch the Token from the request header and calculate the value of accept_key. How should I do this?
#[get("/echo")]
fn echo(ws: rocket_ws::WebSocket) -> rocket_ws::Stream!['static] {
let get_accept_key = ws.get_accept_key();
let request = ....request;
rocket_ws::Stream! { ws =>
for await message in ws {
yield message?;
}
}
}
Why do you need the Sec-WebSocket-Key
? I'm not opposed to exposing it, as there is no security implication, but the key should be a likely protocol-level concern, so it's curious that you would need the value.
I personally prefer using it as a connection ID and manually maintaining the uniqueness of Sec-WebSocket-Key.
I also want to know how to get the "Request" in WebSocket.
thanks a lot.
Merged.
return accept_key