Skip to content

Commit 3b6af82

Browse files
committed
[minor] Prevent opening handshake headers from being overridden
Ensure that the `Connection`, `Sec-WebSocket-Key`, `Sec-WebSocket-Version`, and `Upgrade` headers are not overridden. Refs: #2048 (comment)
1 parent 982b782 commit 3b6af82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/websocket.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,11 @@ function initAsClient(websocket, address, protocols, options) {
713713
? parsedUrl.hostname.slice(1, -1)
714714
: parsedUrl.hostname;
715715
opts.headers = {
716+
...opts.headers,
716717
'Sec-WebSocket-Version': opts.protocolVersion,
717718
'Sec-WebSocket-Key': key,
718719
Connection: 'Upgrade',
719-
Upgrade: 'websocket',
720-
...opts.headers
720+
Upgrade: 'websocket'
721721
};
722722
opts.path = parsedUrl.pathname + parsedUrl.search;
723723
opts.timeout = opts.handshakeTimeout;

0 commit comments

Comments
 (0)