Comparing version 8.4.2 to 8.5.0
@@ -52,2 +52,4 @@ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */ | ||
* @param {Function} [options.verifyClient] A hook to reject connections | ||
* @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket` | ||
* class to use. It must be the `WebSocket` class or class that extends it | ||
* @param {Function} [callback] A listener for the `listening` event | ||
@@ -71,2 +73,3 @@ */ | ||
port: null, | ||
WebSocket, | ||
...options | ||
@@ -361,3 +364,3 @@ }; | ||
const ws = new WebSocket(null); | ||
const ws = new this.options.WebSocket(null); | ||
@@ -364,0 +367,0 @@ if (protocols.size) { |
@@ -769,2 +769,41 @@ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */ | ||
if (opts.followRedirects) { | ||
if (websocket._redirects === 0) { | ||
websocket._originalHost = parsedUrl.host; | ||
const headers = options && options.headers; | ||
// | ||
// Shallow copy the user provided options so that headers can be changed | ||
// without mutating the original object. | ||
// | ||
options = { ...options, headers: {} }; | ||
if (headers) { | ||
for (const [key, value] of Object.entries(headers)) { | ||
options.headers[key.toLowerCase()] = value; | ||
} | ||
} | ||
} else if (parsedUrl.host !== websocket._originalHost) { | ||
// | ||
// Match curl 7.77.0 behavior and drop the following headers. These | ||
// headers are also dropped when following a redirect to a subdomain. | ||
// | ||
delete opts.headers.authorization; | ||
delete opts.headers.cookie; | ||
delete opts.headers.host; | ||
opts.auth = undefined; | ||
} | ||
// | ||
// Match curl 7.77.0 behavior and make the first `Authorization` header win. | ||
// If the `Authorization` header is set, then there is nothing to do as it | ||
// will take precedence. | ||
// | ||
if (opts.auth && !options.headers.authorization) { | ||
options.headers.authorization = | ||
'Basic ' + Buffer.from(opts.auth).toString('base64'); | ||
} | ||
} | ||
let req = (websocket._req = get(opts)); | ||
@@ -771,0 +810,0 @@ |
{ | ||
"name": "ws", | ||
"version": "8.4.2", | ||
"version": "8.5.0", | ||
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
130756
3823