Skip to content

Commit

Permalink
[minor] Prevent opening handshake headers from being overridden
Browse files Browse the repository at this point in the history
Ensure that the `Connection`, `Sec-WebSocket-Key`,
`Sec-WebSocket-Version`, and `Upgrade` headers are not overridden.

Refs: #2048 (comment)
  • Loading branch information
lpinca committed Jun 20, 2022
1 parent 982b782 commit 3b6af82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,11 @@ function initAsClient(websocket, address, protocols, options) {
? parsedUrl.hostname.slice(1, -1)
: parsedUrl.hostname;
opts.headers = {
...opts.headers,
'Sec-WebSocket-Version': opts.protocolVersion,
'Sec-WebSocket-Key': key,
Connection: 'Upgrade',
Upgrade: 'websocket',
...opts.headers
Upgrade: 'websocket'
};
opts.path = parsedUrl.pathname + parsedUrl.search;
opts.timeout = opts.handshakeTimeout;
Expand Down

0 comments on commit 3b6af82

Please sign in to comment.