committed by
GitHub
parent
20d2b4f98d
commit
e4f3964f67
51
node_modules/ws/lib/websocket.js
generated
vendored
51
node_modules/ws/lib/websocket.js
generated
vendored
@ -682,6 +682,52 @@ function initAsClient(websocket, address, protocols, options) {
|
||||
opts.path = parts[1];
|
||||
}
|
||||
|
||||
if (opts.followRedirects) {
|
||||
if (websocket._redirects === 0) {
|
||||
websocket._originalSecure = isSecure;
|
||||
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 {
|
||||
const isSameHost = parsedUrl.host === websocket._originalHost;
|
||||
|
||||
if (!isSameHost || (websocket._originalSecure && !isSecure)) {
|
||||
//
|
||||
// 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;
|
||||
|
||||
if (!isSameHost) 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));
|
||||
|
||||
if (opts.timeout) {
|
||||
@ -744,6 +790,11 @@ function initAsClient(websocket, address, protocols, options) {
|
||||
|
||||
req = websocket._req = null;
|
||||
|
||||
if (res.headers.upgrade.toLowerCase() !== 'websocket') {
|
||||
abortHandshake(websocket, socket, 'Invalid Upgrade header');
|
||||
return;
|
||||
}
|
||||
|
||||
const digest = createHash('sha1')
|
||||
.update(key + GUID)
|
||||
.digest('base64');
|
||||
|
2
node_modules/ws/package.json
generated
vendored
2
node_modules/ws/package.json
generated
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ws",
|
||||
"version": "7.5.6",
|
||||
"version": "7.5.8",
|
||||
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
|
||||
"keywords": [
|
||||
"HyBi",
|
||||
|
Reference in New Issue
Block a user