Skip to content

Commit

Permalink
[major] Drop support for Hixie-76 (#871)
Browse files Browse the repository at this point in the history

* !fixup: remove leftover
  • Loading branch information
lpinca committed Oct 25, 2016
1 parent f026859 commit d73ed13
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 1,178 deletions.
3 changes: 0 additions & 3 deletions README.md
Expand Up @@ -10,9 +10,6 @@ for the full reports.

## Protocol support

* **Hixie draft 76** (Old and deprecated, but still in use by Safari and Opera.
Added to ws version 0.4.2, but server only. Can be disabled by setting the
`disableHixie` option to true.)
* **HyBi drafts 07-12** (Use the option `protocolVersion: 8`)
* **HyBi drafts 13-17** (Current default, alternatively option `protocolVersion: 13`)

Expand Down
5 changes: 2 additions & 3 deletions doc/ws.md
Expand Up @@ -14,7 +14,6 @@ This class is a WebSocket server. It is an `EventEmitter`.
* `handleProtocols` Function
* `path` String
* `noServer` Boolean
* `disableHixie` Boolean
* `clientTracking` Boolean
* `perMessageDeflate` Boolean|Object
* `callback` Function
Expand Down Expand Up @@ -108,7 +107,7 @@ This class represents a WebSocket connection. It is an `EventEmitter`.
* `protocol` String
* `agent` Agent
* `headers` Object
* `protocolVersion` Number|String
* `protocolVersion` Number
-- the following only apply if `address` is a String
* `host` String
* `origin` String
Expand Down Expand Up @@ -138,7 +137,7 @@ Possible states are `WebSocket.CONNECTING`, `WebSocket.OPEN`, `WebSocket.CLOSING

### websocket.protocolVersion

The WebSocket protocol version used for this connection, `8`, `13` or `hixie-76` (the latter only for server clients).
The WebSocket protocol version used for this connection, `8`, `13`.

### websocket.url

Expand Down
170 changes: 0 additions & 170 deletions lib/Receiver.hixie.js

This file was deleted.

112 changes: 0 additions & 112 deletions lib/Sender.hixie.js

This file was deleted.

20 changes: 6 additions & 14 deletions lib/WebSocket.js
Expand Up @@ -15,8 +15,6 @@ const stream = require('stream');
const Ultron = require('ultron');
const Sender = require('./Sender');
const Receiver = require('./Receiver');
const SenderHixie = require('./Sender.hixie');
const ReceiverHixie = require('./Receiver.hixie');
const Extensions = require('./Extensions');
const PerMessageDeflate = require('./PerMessageDeflate');
const EventEmitter = require('events');
Expand Down Expand Up @@ -72,7 +70,7 @@ function WebSocket (address, protocols, options) {
this._closeReceived = false;
this.bytesReceived = 0;
this.readyState = null;
this.supports = {};
this.supports = { binary: true };
this.extensions = {};
this._binaryType = 'nodebuffer';

Expand Down Expand Up @@ -539,16 +537,11 @@ function buildHostHeader (isSecure, hostname, port) {
function initAsServerClient (req, socket, upgradeHead, options) {
// expose state properties
Object.assign(this, options);
this.supports.binary = this.protocolVersion !== 'hixie-76';
this.readyState = WebSocket.CONNECTING;
this.upgradeReq = req;
this._isServer = true;
// establish connection
if (options.protocolVersion === 'hixie-76') {
establishConnection.call(this, ReceiverHixie, SenderHixie, socket, upgradeHead);
} else {
establishConnection.call(this, Receiver, Sender, socket, upgradeHead);
}
establishConnection.call(this, socket, upgradeHead);
}

function initAsClient (address, protocols, options) {
Expand Down Expand Up @@ -599,7 +592,6 @@ function initAsClient (address, protocols, options) {
this._isServer = false;
this.url = address;
this.protocolVersion = options.protocolVersion;
this.supports.binary = true;

// begin handshake
var key = new Buffer(options.protocolVersion + '-' + Date.now()).toString('base64');
Expand Down Expand Up @@ -772,7 +764,7 @@ function initAsClient (address, protocols, options) {
this.extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
}

establishConnection.call(this, Receiver, Sender, socket, upgradeHead);
establishConnection.call(this, socket, upgradeHead);

// perform cleanup on http resources
req.removeAllListeners();
Expand All @@ -784,13 +776,13 @@ function initAsClient (address, protocols, options) {
this.readyState = WebSocket.CONNECTING;
}

function establishConnection (ReceiverClass, SenderClass, socket, upgradeHead) {
function establishConnection (socket, upgradeHead) {
var ultron = this._ultron = new Ultron(socket);

socket.setTimeout(0);
socket.setNoDelay(true);

this._receiver = new ReceiverClass(this.extensions, this.maxPayload);
this._receiver = new Receiver(this.extensions, this.maxPayload);
this._socket = socket;

// socket cleanup handlers
Expand Down Expand Up @@ -847,7 +839,7 @@ function establishConnection (ReceiverClass, SenderClass, socket, upgradeHead) {
};

// finalize the client
this._sender = new SenderClass(socket, this.extensions);
this._sender = new Sender(socket, this.extensions);
this._sender.onerror = (error) => {
this.close(1002, '');
this.emit('error', error);
Expand Down

0 comments on commit d73ed13

Please sign in to comment.