Socket
Socket
Sign inDemoInstall

ws

Package Overview
Dependencies
3
Maintainers
4
Versions
164
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.5.0 to 8.6.0

49

lib/websocket.js

@@ -33,6 +33,7 @@ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */

const closeTimeout = 30 * 1000;
const kAborted = Symbol('kAborted');
const protocolVersions = [8, 13];
const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
const subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
const protocolVersions = [8, 13];
const closeTimeout = 30 * 1000;

@@ -651,3 +652,3 @@ /**

timeout: undefined,
method: undefined,
method: 'GET',
host: undefined,

@@ -706,3 +707,3 @@ path: undefined,

const key = randomBytes(16).toString('base64');
const get = isSecure ? https.get : http.get;
const request = isSecure ? https.request : http.request;
const protocolSet = new Set();

@@ -772,2 +773,4 @@ let perMessageDeflate;

let req;
if (opts.followRedirects) {

@@ -790,3 +793,6 @@ if (websocket._redirects === 0) {

}
} else if (parsedUrl.host !== websocket._originalHost) {
} else if (
websocket.listenerCount('redirect') === 0 &&
parsedUrl.host !== websocket._originalHost
) {
//

@@ -811,6 +817,21 @@ // Match curl 7.77.0 behavior and drop the following headers. These

}
req = websocket._req = request(opts);
if (websocket._redirects) {
//
// Unlike what is done for the `'upgrade'` event, no early exit is
// triggered here if the user calls `websocket.close()` or
// `websocket.terminate()` from a listener of the `'redirect'` event. This
// is because the user can also call `request.destroy()` with an error
// before calling `websocket.close()` or `websocket.terminate()` and this
// would result in an error being emitted on the `request` object with no
// `'error'` event listeners attached.
//
websocket.emit('redirect', websocket.url, req);
}
} else {
req = websocket._req = request(opts);
}
let req = (websocket._req = get(opts));
if (opts.timeout) {

@@ -823,3 +844,3 @@ req.on('timeout', () => {

req.on('error', (err) => {
if (req === null || req.aborted) return;
if (req === null || req[kAborted]) return;

@@ -871,4 +892,4 @@ req = websocket._req = null;

//
// The user may have closed the connection from a listener of the `upgrade`
// event.
// The user may have closed the connection from a listener of the
// `'upgrade'` event.
//

@@ -958,6 +979,8 @@ if (websocket.readyState !== WebSocket.CONNECTING) return;

});
req.end();
}
/**
* Emit the `'error'` and `'close'` event.
* Emit the `'error'` and `'close'` events.
*

@@ -1019,2 +1042,3 @@ * @param {WebSocket} websocket The WebSocket instance

if (stream.setHeader) {
stream[kAborted] = true;
stream.abort();

@@ -1031,4 +1055,3 @@

stream.once('abort', websocket.emitClose.bind(websocket));
websocket.emit('error', err);
process.nextTick(emitErrorAndClose, websocket, err);
} else {

@@ -1035,0 +1058,0 @@ stream.destroy(err);

{
"name": "ws",
"version": "8.5.0",
"version": "8.6.0",
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -255,4 +255,4 @@ # ws: a Node.js WebSocket library

```js
import WebSocket from 'ws';
import { createServer } from 'http';
import { WebSocketServer } from 'ws';

@@ -259,0 +259,0 @@ const server = createServer();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc