mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-06 15:02:46 +00:00
proxmox-http/websocket: remove subprotocol handling
we do not support websocket subprotocols, but for compatibility with current clients (novnc, pve-xtermjs) we have to reply with the one requested, else this is a protocol error and browsers will error out Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
232d87531e
commit
0786b4b98c
@ -671,13 +671,6 @@ impl WebSocket {
|
|||||||
.ok_or_else(|| format_err!("missing websocket key"))?
|
.ok_or_else(|| format_err!("missing websocket key"))?
|
||||||
.to_str()?;
|
.to_str()?;
|
||||||
|
|
||||||
let ws_proto = headers
|
|
||||||
.get(SEC_WEBSOCKET_PROTOCOL)
|
|
||||||
.ok_or_else(|| format_err!("missing websocket key"))?
|
|
||||||
.to_str()?;
|
|
||||||
|
|
||||||
let text = ws_proto == "text";
|
|
||||||
|
|
||||||
if protocols != "websocket" {
|
if protocols != "websocket" {
|
||||||
bail!("invalid protocol name");
|
bail!("invalid protocol name");
|
||||||
}
|
}
|
||||||
@ -693,13 +686,19 @@ impl WebSocket {
|
|||||||
sha1.update(data.as_bytes());
|
sha1.update(data.as_bytes());
|
||||||
let response_key = base64::encode(sha1.finish());
|
let response_key = base64::encode(sha1.finish());
|
||||||
|
|
||||||
let response = Response::builder()
|
let mut response = Response::builder()
|
||||||
.status(StatusCode::SWITCHING_PROTOCOLS)
|
.status(StatusCode::SWITCHING_PROTOCOLS)
|
||||||
.header(UPGRADE, HeaderValue::from_static("websocket"))
|
.header(UPGRADE, HeaderValue::from_static("websocket"))
|
||||||
.header(CONNECTION, HeaderValue::from_static("Upgrade"))
|
.header(CONNECTION, HeaderValue::from_static("Upgrade"))
|
||||||
.header(SEC_WEBSOCKET_ACCEPT, response_key)
|
.header(SEC_WEBSOCKET_ACCEPT, response_key);
|
||||||
.header(SEC_WEBSOCKET_PROTOCOL, ws_proto)
|
|
||||||
.body(Body::empty())?;
|
// We currently do not support any subprotocols and we always send binary frames,
|
||||||
|
// but for backwards compatibilty we need to reply the requested protocols
|
||||||
|
if let Some(ws_proto) = headers.get(SEC_WEBSOCKET_PROTOCOL) {
|
||||||
|
response = response.header(SEC_WEBSOCKET_PROTOCOL, ws_proto)
|
||||||
|
}
|
||||||
|
|
||||||
|
let response = response.body(Body::empty())?;
|
||||||
|
|
||||||
Ok((Self, response))
|
Ok((Self, response))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user