Skip to content
Permalink
Browse files

[major] Drop support for Node.js 6

  • Loading branch information...
lpinca committed Apr 25, 2019
1 parent 5d751fb commit 1e6999bb67e86d486da0b61f5bc71ed9f8417e65
Showing with 7 additions and 23 deletions.
  1. +0 −1 .travis.yml
  2. +0 −1 appveyor.yml
  3. +7 −19 lib/websocket.js
  4. +0 −2 test/websocket.test.js
@@ -3,7 +3,6 @@ node_js:
- '11'
- '10'
- '8'
- '6'
os:
- linux
- osx
@@ -3,7 +3,6 @@ environment:
- nodejs_version: '11'
- nodejs_version: '10'
- nodejs_version: '8'
- nodejs_version: '6'
platform:
- x86
matrix:
@@ -1,12 +1,12 @@
'use strict';

const EventEmitter = require('events');
const crypto = require('crypto');
const https = require('https');
const http = require('http');
const net = require('net');
const tls = require('tls');
const url = require('url');
const { randomBytes, createHash } = require('crypto');
const { URL } = require('url');

const PerMessageDeflate = require('./permessage-deflate');
const EventTarget = require('./event-target');
@@ -480,10 +480,7 @@ function initAsClient(websocket, address, protocols, options) {
parsedUrl = address;
websocket.url = address.href;
} else {
//
// The WHATWG URL constructor is not available on Node.js < 6.13.0
//
parsedUrl = url.URL ? new url.URL(address) : url.parse(address);
parsedUrl = new URL(address);
websocket.url = address;
}

@@ -496,7 +493,7 @@ function initAsClient(websocket, address, protocols, options) {
const isSecure =
parsedUrl.protocol === 'wss:' || parsedUrl.protocol === 'https:';
const defaultPort = isSecure ? 443 : 80;
const key = crypto.randomBytes(16).toString('base64');
const key = randomBytes(16).toString('base64');
const get = isSecure ? https.get : http.get;
const path = parsedUrl.search
? `${parsedUrl.pathname || '/'}${parsedUrl.search}`
@@ -588,9 +585,7 @@ function initAsClient(websocket, address, protocols, options) {

req.abort();

const addr = url.URL
? new url.URL(location, address)
: url.resolve(address, location);
const addr = new URL(location, address);

initAsClient(websocket, addr, protocols, options);
} else if (!websocket.emit('unexpected-response', req, res)) {
@@ -613,8 +608,7 @@ function initAsClient(websocket, address, protocols, options) {

req = websocket._req = null;

const digest = crypto
.createHash('sha1')
const digest = createHash('sha1')
.update(key + GUID)
.digest('base64');

@@ -676,13 +670,7 @@ function initAsClient(websocket, address, protocols, options) {
* @private
*/
function netConnect(options) {
//
// Override `options.path` only if `options` is a copy of the original options
// object. This is always true on Node.js >= 8 but not on Node.js 6 where
// `options.socketPath` might be `undefined` even if the `socketPath` option
// was originally set.
//
if (options.protocolVersion) options.path = options.socketPath;
options.path = options.socketPath;
return net.connect(options);
}

@@ -37,8 +37,6 @@ describe('WebSocket', () => {
});

it('accepts `url.URL` objects as url', function(done) {
if (!url.URL) return this.skip();

const agent = new CustomAgent();

agent.addRequest = (req, opts) => {

1 comment on commit 1e6999b

@julien-f

This comment has been minimized.

Copy link
Contributor

commented on 1e6999b Jun 3, 2019

It would be nice to add a engines field in the package.json to better document this 🙂

Please sign in to comment.
You can’t perform that action at this time.