From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH http-server 2/2] AnyEvent/websocket_proxy: drop handling of websocket subprotocols
Date: Mon, 17 May 2021 15:07:35 +0200 [thread overview]
Message-ID: <20210517130735.17568-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210517130735.17568-1-d.csapak@proxmox.com>
We do not support any, and we only ever send binary frames, so drop
trying to parse the header.
For compatibility with current clients (novnc, pve-xtermjs), we have
to reply with the protocols it sent.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/PVE/APIServer/AnyEvent.pm | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index a7d31cc..6f0abb7 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -650,11 +650,13 @@ sub websocket_proxy {
# todo: use stop_read/start_read if write buffer grows to much
+ # for backwards, compatibility, we have to reply with the websocket
+ # subprotocol from the request
my $res = "$proto 101 Switching Protocols\015\012" .
"Upgrade: websocket\015\012" .
"Connection: upgrade\015\012" .
"Sec-WebSocket-Accept: $wsaccept\015\012" .
- "Sec-WebSocket-Protocol: $wsproto\015\012" .
+ ($wsproto ne "" ? "Sec-WebSocket-Protocol: $wsproto\015\012" : "") .
"\015\012";
$self->dprint($res);
@@ -902,14 +904,7 @@ sub handle_api2_request {
die "unable to upgrade to protocol '$upgrade'\n" if !$upgrade || ($upgrade ne 'websocket');
my $wsver = $r->header('sec-websocket-version');
die "unsupported websocket-version '$wsver'\n" if !$wsver || ($wsver ne '13');
- my $wsproto_str = $r->header('sec-websocket-protocol');
- die "missing websocket-protocol header" if !$wsproto_str;
- my $wsproto;
- foreach my $p (PVE::Tools::split_list($wsproto_str)) {
- $wsproto = $p if !$wsproto && $p eq 'base64';
- $wsproto = $p if $p eq 'binary';
- }
- die "unsupported websocket-protocol protocol '$wsproto_str'\n" if !$wsproto;
+ my $wsproto = $r->header('sec-websocket-protocol') // "";
my $wskey = $r->header('sec-websocket-key');
die "missing websocket-key\n" if !$wskey;
# Note: Digest::SHA::sha1_base64 has wrong padding
--
2.20.1
next prev parent reply other threads:[~2021-05-17 13:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 13:07 [pve-devel] [PATCH http-server 0/2] remove unnecessary websocket code Dominik Csapak
2021-05-17 13:07 ` [pve-devel] [PATCH http-server 1/2] AnyEvent/websocket_proxy: remove 'base64' handling Dominik Csapak
2021-05-17 13:07 ` Dominik Csapak [this message]
2021-05-18 8:33 ` [pve-devel] applied-series: [PATCH http-server 0/2] remove unnecessary websocket code Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210517130735.17568-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox