]> git.proxmox.com Git - pve-http-server.git/commitdiff
AnyEvent/websocket_proxy: drop handling of websocket subprotocols
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 17 May 2021 13:07:35 +0000 (15:07 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 18 May 2021 07:24:16 +0000 (09:24 +0200)
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

index a7d31cc476b602cc28058e15307c0a8beb8892ef..6f0abb7fbc1fd8d00b00132a70045f25851f0748 100644 (file)
@@ -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