mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
update sockjs
git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/nodeJSProjects@59138 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
2
CoAuthoring/node_modules/sockjs/COPYING
generated
vendored
2
CoAuthoring/node_modules/sockjs/COPYING
generated
vendored
@ -3,4 +3,4 @@ Parts of the code are derived from various open source projects.
|
|||||||
For code derived from Socket.IO by Guillermo Rauch see
|
For code derived from Socket.IO by Guillermo Rauch see
|
||||||
https://github.com/LearnBoost/socket.io/tree/0.6.17#readme.
|
https://github.com/LearnBoost/socket.io/tree/0.6.17#readme.
|
||||||
|
|
||||||
All other code is released on MIT license, see LICENSE-MIT-SockJS.
|
All other code is released on MIT license, see LICENSE.
|
||||||
|
|||||||
7
CoAuthoring/node_modules/sockjs/Changelog
generated
vendored
7
CoAuthoring/node_modules/sockjs/Changelog
generated
vendored
@ -1,3 +1,10 @@
|
|||||||
|
0.3.9
|
||||||
|
=====
|
||||||
|
|
||||||
|
* #130 - Set Vary: Origin on CORS requests
|
||||||
|
* Upgrade Faye to 0.7.2 from 0.7.0
|
||||||
|
|
||||||
|
|
||||||
0.3.8
|
0.3.8
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
|||||||
19
CoAuthoring/node_modules/sockjs/LICENSE-MIT-SockJS
generated
vendored
19
CoAuthoring/node_modules/sockjs/LICENSE-MIT-SockJS
generated
vendored
@ -1,19 +0,0 @@
|
|||||||
Copyright (C) 2011 VMware, Inc.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
2
CoAuthoring/node_modules/sockjs/README.md
generated
vendored
2
CoAuthoring/node_modules/sockjs/README.md
generated
vendored
@ -4,7 +4,7 @@ SockJS family:
|
|||||||
* [SockJS-node](https://github.com/sockjs/sockjs-node) Node.js server
|
* [SockJS-node](https://github.com/sockjs/sockjs-node) Node.js server
|
||||||
* [SockJS-erlang](https://github.com/sockjs/sockjs-erlang) Erlang server
|
* [SockJS-erlang](https://github.com/sockjs/sockjs-erlang) Erlang server
|
||||||
* [SockJS-tornado](https://github.com/MrJoes/sockjs-tornado) Python/Tornado server
|
* [SockJS-tornado](https://github.com/MrJoes/sockjs-tornado) Python/Tornado server
|
||||||
* [vert.x](https://github.com/purplefox/vert.x) Java/vert.x server
|
* [vert.x](https://github.com/eclipse/vert.x) Java/vert.x server
|
||||||
|
|
||||||
Work in progress:
|
Work in progress:
|
||||||
|
|
||||||
|
|||||||
1
CoAuthoring/node_modules/sockjs/lib/trans-xhr.js
generated
vendored
1
CoAuthoring/node_modules/sockjs/lib/trans-xhr.js
generated
vendored
@ -93,6 +93,7 @@
|
|||||||
origin = req.headers['origin'];
|
origin = req.headers['origin'];
|
||||||
}
|
}
|
||||||
res.setHeader('Access-Control-Allow-Origin', origin);
|
res.setHeader('Access-Control-Allow-Origin', origin);
|
||||||
|
res.setHeader('Vary', 'Origin');
|
||||||
headers = req.headers['access-control-request-headers'];
|
headers = req.headers['access-control-request-headers'];
|
||||||
if (headers) res.setHeader('Access-Control-Allow-Headers', headers);
|
if (headers) res.setHeader('Access-Control-Allow-Headers', headers);
|
||||||
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
||||||
|
|||||||
11
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/CHANGELOG.md
generated
vendored
11
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/CHANGELOG.md
generated
vendored
@ -1,3 +1,14 @@
|
|||||||
|
### 0.7.2 / 2013-12-29
|
||||||
|
|
||||||
|
* Make sure the `close` event is emitted by clients on Node v0.10
|
||||||
|
|
||||||
|
|
||||||
|
### 0.7.1 / 2013-12-03
|
||||||
|
|
||||||
|
* Support the `maxLength` websocket-driver option
|
||||||
|
* Make the client emit `error` events on network errors
|
||||||
|
|
||||||
|
|
||||||
### 0.7.0 / 2013-09-09
|
### 0.7.0 / 2013-09-09
|
||||||
|
|
||||||
* Allow the server to send custom headers with EventSource responses
|
* Allow the server to send custom headers with EventSource responses
|
||||||
|
|||||||
2
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/README.md
generated
vendored
2
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/README.md
generated
vendored
@ -155,6 +155,8 @@ var ws = new WebSocket.Client(url, protocols, options);
|
|||||||
|
|
||||||
* `headers` - an object containing key-value pairs representing HTTP headers to
|
* `headers` - an object containing key-value pairs representing HTTP headers to
|
||||||
be sent during the handshake process
|
be sent during the handshake process
|
||||||
|
* `maxLength` - the maximum allowed size of incoming message frames, in bytes.
|
||||||
|
The default value is `2^26 - 1`, or 1 byte short of 64 MiB.
|
||||||
* `ping` - an integer that sets how often the WebSocket should send ping
|
* `ping` - an integer that sets how often the WebSocket should send ping
|
||||||
frames, measured in seconds
|
frames, measured in seconds
|
||||||
|
|
||||||
|
|||||||
13
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket.js
generated
vendored
13
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket.js
generated
vendored
@ -9,8 +9,10 @@ var util = require('util'),
|
|||||||
API = require('./websocket/api');
|
API = require('./websocket/api');
|
||||||
|
|
||||||
var WebSocket = function(request, socket, body, protocols, options) {
|
var WebSocket = function(request, socket, body, protocols, options) {
|
||||||
this._stream = socket;
|
options = options || {};
|
||||||
this._driver = driver.http(request, {protocols: protocols});
|
|
||||||
|
this._stream = socket;
|
||||||
|
this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!this._stream || !this._stream.writable) return;
|
if (!this._stream || !this._stream.writable) return;
|
||||||
@ -18,16 +20,9 @@ var WebSocket = function(request, socket, body, protocols, options) {
|
|||||||
var catchup = function() { self._stream.removeListener('data', catchup) };
|
var catchup = function() { self._stream.removeListener('data', catchup) };
|
||||||
this._stream.on('data', catchup);
|
this._stream.on('data', catchup);
|
||||||
|
|
||||||
this._stream.setTimeout(0);
|
|
||||||
this._stream.setNoDelay(true);
|
|
||||||
|
|
||||||
this._driver.io.write(body);
|
this._driver.io.write(body);
|
||||||
API.call(this, options);
|
API.call(this, options);
|
||||||
|
|
||||||
['error', 'end'].forEach(function(event) {
|
|
||||||
this._stream.on(event, function() { self._finalize('', 1006) });
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
self._driver.start();
|
self._driver.start();
|
||||||
});
|
});
|
||||||
|
|||||||
14
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/api.js
generated
vendored
14
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/api.js
generated
vendored
@ -23,6 +23,20 @@ var API = function(options) {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
this._stream.setTimeout(0);
|
||||||
|
this._stream.setNoDelay(true);
|
||||||
|
|
||||||
|
['close', 'end'].forEach(function(event) {
|
||||||
|
this._stream.on(event, function() { self._finalize('', 1006) });
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this._stream.on('error', function(error) {
|
||||||
|
var event = new Event('error', {message: 'Network error: ' + self.url + ': ' + error.message});
|
||||||
|
event.initEvent('error', false, false);
|
||||||
|
self.dispatchEvent(event);
|
||||||
|
self._finalize('', 1006);
|
||||||
|
});
|
||||||
|
|
||||||
this._driver.on('open', function(e) { self._open() });
|
this._driver.on('open', function(e) { self._open() });
|
||||||
this._driver.on('message', function(e) { self._receiveMessage(e.data) });
|
this._driver.on('message', function(e) { self._receiveMessage(e.data) });
|
||||||
this._driver.on('close', function(e) { self._finalize(e.reason, e.code) });
|
this._driver.on('close', function(e) { self._finalize(e.reason, e.code) });
|
||||||
|
|||||||
16
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/client.js
generated
vendored
16
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/client.js
generated
vendored
@ -2,12 +2,15 @@ var util = require('util'),
|
|||||||
net = require('net'),
|
net = require('net'),
|
||||||
tls = require('tls'),
|
tls = require('tls'),
|
||||||
driver = require('websocket-driver'),
|
driver = require('websocket-driver'),
|
||||||
API = require('./api');
|
API = require('./api'),
|
||||||
|
Event = require('./api/event');
|
||||||
|
|
||||||
var Client = function(url, protocols, options) {
|
var Client = function(url, protocols, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this._uri = require('url').parse(url);
|
this._uri = require('url').parse(url);
|
||||||
this._driver = driver.client(url, {protocols: protocols});
|
this._driver = driver.client(url, {maxLength: options.maxLength, protocols: protocols});
|
||||||
|
|
||||||
['open', 'error'].forEach(function(event) {
|
['open', 'error'].forEach(function(event) {
|
||||||
this._driver.on(event, function() {
|
this._driver.on(event, function() {
|
||||||
@ -21,23 +24,16 @@ var Client = function(url, protocols, options) {
|
|||||||
tlsOptions = {},
|
tlsOptions = {},
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
if (options && options.ca) tlsOptions.ca = options.ca;
|
if (options.ca) tlsOptions.ca = options.ca;
|
||||||
|
|
||||||
var connection = secure
|
var connection = secure
|
||||||
? tls.connect(this._uri.port || 443, this._uri.hostname, tlsOptions, onConnect)
|
? tls.connect(this._uri.port || 443, this._uri.hostname, tlsOptions, onConnect)
|
||||||
: net.createConnection(this._uri.port || 80, this._uri.hostname);
|
: net.createConnection(this._uri.port || 80, this._uri.hostname);
|
||||||
|
|
||||||
this._stream = connection;
|
this._stream = connection;
|
||||||
this._stream.setTimeout(0);
|
|
||||||
this._stream.setNoDelay(true);
|
|
||||||
|
|
||||||
if (!secure) this._stream.on('connect', onConnect);
|
if (!secure) this._stream.on('connect', onConnect);
|
||||||
|
|
||||||
API.call(this, options);
|
API.call(this, options);
|
||||||
|
|
||||||
['error', 'end'].forEach(function(event) {
|
|
||||||
this._stream.on(event, function() { self._finalize('', 1006) });
|
|
||||||
}, this);
|
|
||||||
};
|
};
|
||||||
util.inherits(Client, API);
|
util.inherits(Client, API);
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
### 0.3.6 / 2014-10-04
|
||||||
|
|
||||||
|
* It is now possible to call `close()` before `start()` and close the driver
|
||||||
|
|
||||||
|
### 0.3.5 / 2014-07-06
|
||||||
|
|
||||||
|
* Don't hold references to frame buffers after a message has been emitted
|
||||||
|
* Make sure that `protocol` and `version` are exposed properly by the TCP driver
|
||||||
|
|
||||||
|
### 0.3.4 / 2014-05-08
|
||||||
|
|
||||||
|
* Don't hold memory-leaking references to I/O buffers after they have been parsed
|
||||||
|
|
||||||
|
### 0.3.3 / 2014-04-24
|
||||||
|
|
||||||
|
* Correct the draft-76 status line reason phrase
|
||||||
|
|
||||||
### 0.3.2 / 2013-12-29
|
### 0.3.2 / 2013-12-29
|
||||||
|
|
||||||
* Expand `maxLength` to cover sequences of continuation frames and `draft-{75,76}`
|
* Expand `maxLength` to cover sequences of continuation frames and `draft-{75,76}`
|
||||||
@ -31,4 +48,3 @@
|
|||||||
### 0.1.0 / 2013-05-04
|
### 0.1.0 / 2013-05-04
|
||||||
|
|
||||||
* First stable release
|
* First stable release
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# websocket-driver [](https://travis-ci.org/faye/websocket-driver-node)
|
# websocket-driver [](https://travis-ci.org/faye/websocket-driver-node)
|
||||||
|
|
||||||
This module provides a complete implementation of the WebSocket protocols that
|
This module provides a complete implementation of the WebSocket protocols that
|
||||||
can be hooked up to any I/O stream. It aims to simplify things by decoupling
|
can be hooked up to any I/O stream. It aims to simplify things by decoupling
|
||||||
@ -285,7 +285,7 @@ after `emit('open')` has fired.
|
|||||||
|
|
||||||
(The MIT License)
|
(The MIT License)
|
||||||
|
|
||||||
Copyright (c) 2010-2013 James Coglan
|
Copyright (c) 2010-2014 James Coglan
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the 'Software'), to deal in
|
this software and associated documentation files (the 'Software'), to deal in
|
||||||
@ -304,4 +304,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
|
|||||||
@ -18,4 +18,3 @@ var server = net.createServer(function(connection) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.listen(process.argv[2]);
|
server.listen(process.argv[2]);
|
||||||
|
|
||||||
|
|||||||
@ -41,4 +41,3 @@ var Driver = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Driver;
|
module.exports = Driver;
|
||||||
|
|
||||||
|
|||||||
@ -123,4 +123,3 @@ Base.MessageEvent = function(data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Base;
|
module.exports = Base;
|
||||||
|
|
||||||
|
|||||||
@ -109,4 +109,3 @@ for (var key in instance)
|
|||||||
Client.prototype[key] = instance[key];
|
Client.prototype[key] = instance[key];
|
||||||
|
|
||||||
module.exports = Client;
|
module.exports = Client;
|
||||||
|
|
||||||
|
|||||||
@ -115,4 +115,3 @@ for (var key in instance)
|
|||||||
Draft75.prototype[key] = instance[key];
|
Draft75.prototype[key] = instance[key];
|
||||||
|
|
||||||
module.exports = Draft75;
|
module.exports = Draft75;
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ var instance = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_handshakeResponse: function() {
|
_handshakeResponse: function() {
|
||||||
return new Buffer('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
|
return new Buffer('HTTP/1.1 101 WebSocket Protocol Handshake\r\n' +
|
||||||
'Upgrade: WebSocket\r\n' +
|
'Upgrade: WebSocket\r\n' +
|
||||||
'Connection: Upgrade\r\n' +
|
'Connection: Upgrade\r\n' +
|
||||||
'Sec-WebSocket-Origin: ' + this._request.headers.origin + '\r\n' +
|
'Sec-WebSocket-Origin: ' + this._request.headers.origin + '\r\n' +
|
||||||
@ -106,4 +106,3 @@ for (var key in instance)
|
|||||||
Draft76.prototype[key] = instance[key];
|
Draft76.prototype[key] = instance[key];
|
||||||
|
|
||||||
module.exports = Draft76;
|
module.exports = Draft76;
|
||||||
|
|
||||||
|
|||||||
@ -27,4 +27,3 @@ Headers.prototype._strip = function(string) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Headers;
|
module.exports = Headers;
|
||||||
|
|
||||||
|
|||||||
@ -78,4 +78,3 @@ HttpParser.prototype.parse = function(data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = HttpParser;
|
module.exports = HttpParser;
|
||||||
|
|
||||||
|
|||||||
@ -7,26 +7,33 @@ var Hybi = function(request, url, options) {
|
|||||||
Base.apply(this, arguments);
|
Base.apply(this, arguments);
|
||||||
this._reset();
|
this._reset();
|
||||||
|
|
||||||
this._reader = new Reader();
|
this._reader = new Reader();
|
||||||
this._stage = 0;
|
this._stage = 0;
|
||||||
this._masking = this._options.masking;
|
this._masking = this._options.masking;
|
||||||
this._protocols = this._options.protocols || [];
|
this._protocols = this._options.protocols || [];
|
||||||
|
this._requireMasking = this._options.requireMasking;
|
||||||
|
this._pingCallbacks = {};
|
||||||
|
|
||||||
if (typeof this._protocols === 'string')
|
if (typeof this._protocols === 'string')
|
||||||
this._protocols = this._protocols.split(/\s*,\s*/);
|
this._protocols = this._protocols.split(/\s*,\s*/);
|
||||||
|
|
||||||
this._requireMasking = this._options.requireMasking;
|
if (!this._request) return;
|
||||||
this._pingCallbacks = {};
|
|
||||||
|
|
||||||
if (!this.version) {
|
var protos = this._request.headers['sec-websocket-protocol'],
|
||||||
var version = this._request.headers['sec-websocket-version'];
|
supported = this._protocols;
|
||||||
this.version = 'hybi-' + version;
|
|
||||||
|
if (protos !== undefined) {
|
||||||
|
if (typeof protos === 'string') protos = protos.split(/\s*,\s*/);
|
||||||
|
this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var version = this._request.headers['sec-websocket-version'];
|
||||||
|
this.version = 'hybi-' + version;
|
||||||
};
|
};
|
||||||
util.inherits(Hybi, Base);
|
util.inherits(Hybi, Base);
|
||||||
|
|
||||||
Hybi.mask = function(payload, mask, offset) {
|
Hybi.mask = function(payload, mask, offset) {
|
||||||
if (mask.length === 0) return payload;
|
if (!mask || mask.length === 0) return payload;
|
||||||
offset = offset || 0;
|
offset = offset || 0;
|
||||||
|
|
||||||
for (var i = 0, n = payload.length - offset; i < n; i++) {
|
for (var i = 0, n = payload.length - offset; i < n; i++) {
|
||||||
@ -118,8 +125,7 @@ var instance = {
|
|||||||
case 4:
|
case 4:
|
||||||
buffer = this._reader.read(this._length);
|
buffer = this._reader.read(this._length);
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
this._payload = buffer;
|
this._emitFrame(buffer);
|
||||||
this._emitFrame();
|
|
||||||
this._stage = 0;
|
this._stage = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -203,7 +209,7 @@ var instance = {
|
|||||||
reason = reason || '';
|
reason = reason || '';
|
||||||
code = code || this.ERRORS.normal_closure;
|
code = code || this.ERRORS.normal_closure;
|
||||||
|
|
||||||
if (this.readyState === 0) {
|
if (this.readyState <= 0) {
|
||||||
this.readyState = 3;
|
this.readyState = 3;
|
||||||
this.emit('close', new Base.CloseEvent(code, reason));
|
this.emit('close', new Base.CloseEvent(code, reason));
|
||||||
return true;
|
return true;
|
||||||
@ -220,26 +226,15 @@ var instance = {
|
|||||||
var secKey = this._request.headers['sec-websocket-key'];
|
var secKey = this._request.headers['sec-websocket-key'];
|
||||||
if (!secKey) return '';
|
if (!secKey) return '';
|
||||||
|
|
||||||
var accept = Hybi.generateAccept(secKey),
|
var headers = [
|
||||||
protos = this._request.headers['sec-websocket-protocol'],
|
'HTTP/1.1 101 Switching Protocols',
|
||||||
supported = this._protocols,
|
'Upgrade: websocket',
|
||||||
proto,
|
'Connection: Upgrade',
|
||||||
|
'Sec-WebSocket-Accept: ' + Hybi.generateAccept(secKey)
|
||||||
|
];
|
||||||
|
|
||||||
headers = [
|
if (this.protocol)
|
||||||
'HTTP/1.1 101 Switching Protocols',
|
headers.push('Sec-WebSocket-Protocol: ' + this.protocol);
|
||||||
'Upgrade: websocket',
|
|
||||||
'Connection: Upgrade',
|
|
||||||
'Sec-WebSocket-Accept: ' + accept
|
|
||||||
];
|
|
||||||
|
|
||||||
if (protos !== undefined) {
|
|
||||||
if (typeof protos === 'string') protos = protos.split(/\s*,\s*/);
|
|
||||||
proto = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];
|
|
||||||
if (proto) {
|
|
||||||
this.protocol = proto;
|
|
||||||
headers.push('Sec-WebSocket-Protocol: ' + proto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Buffer(headers.concat(this.__headers.toString(), '').join('\r\n'), 'utf8');
|
return new Buffer(headers.concat(this.__headers.toString(), '').join('\r\n'), 'utf8');
|
||||||
},
|
},
|
||||||
@ -269,8 +264,6 @@ var instance = {
|
|||||||
|
|
||||||
this._final = (data & this.FIN) === this.FIN;
|
this._final = (data & this.FIN) === this.FIN;
|
||||||
this._opcode = (data & this.OPCODE);
|
this._opcode = (data & this.OPCODE);
|
||||||
this._mask = [];
|
|
||||||
this._payload = [];
|
|
||||||
|
|
||||||
if (this.OPCODE_CODES.indexOf(this._opcode) < 0)
|
if (this.OPCODE_CODES.indexOf(this._opcode) < 0)
|
||||||
return this._fail('protocol_error', 'Unrecognized frame opcode: ' + this._opcode);
|
return this._fail('protocol_error', 'Unrecognized frame opcode: ' + this._opcode);
|
||||||
@ -320,14 +313,17 @@ var instance = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_emitFrame: function() {
|
_emitFrame: function(buffer) {
|
||||||
var payload = Hybi.mask(this._payload, this._mask),
|
var payload = Hybi.mask(buffer, this._mask),
|
||||||
|
isFinal = this._final,
|
||||||
opcode = this._opcode;
|
opcode = this._opcode;
|
||||||
|
|
||||||
|
this._final = this._opcode = this._length = this._lengthSize = this._masked = this._mask = null;
|
||||||
|
|
||||||
if (opcode === this.OPCODES.continuation) {
|
if (opcode === this.OPCODES.continuation) {
|
||||||
if (!this._mode) return this._fail('protocol_error', 'Received unexpected continuation frame');
|
if (!this._mode) return this._fail('protocol_error', 'Received unexpected continuation frame');
|
||||||
this._buffer(payload);
|
this._buffer(payload);
|
||||||
if (this._final) {
|
if (isFinal) {
|
||||||
var message = this._concatBuffer();
|
var message = this._concatBuffer();
|
||||||
if (this._mode === 'text') message = this._encode(message);
|
if (this._mode === 'text') message = this._encode(message);
|
||||||
this._reset();
|
this._reset();
|
||||||
@ -338,7 +334,7 @@ var instance = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (opcode === this.OPCODES.text) {
|
else if (opcode === this.OPCODES.text) {
|
||||||
if (this._final) {
|
if (isFinal) {
|
||||||
var message = this._encode(payload);
|
var message = this._encode(payload);
|
||||||
if (message === null)
|
if (message === null)
|
||||||
this._fail('encoding_error', 'Could not decode a text frame as UTF-8');
|
this._fail('encoding_error', 'Could not decode a text frame as UTF-8');
|
||||||
@ -350,7 +346,7 @@ var instance = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (opcode === this.OPCODES.binary) {
|
else if (opcode === this.OPCODES.binary) {
|
||||||
if (this._final) {
|
if (isFinal) {
|
||||||
this.emit('message', new Base.MessageEvent(payload));
|
this.emit('message', new Base.MessageEvent(payload));
|
||||||
} else {
|
} else {
|
||||||
this._mode = 'binary';
|
this._mode = 'binary';
|
||||||
@ -426,4 +422,3 @@ for (var key in instance)
|
|||||||
Hybi.prototype[key] = instance[key];
|
Hybi.prototype[key] = instance[key];
|
||||||
|
|
||||||
module.exports = Hybi;
|
module.exports = Hybi;
|
||||||
|
|
||||||
|
|||||||
@ -4,10 +4,6 @@ var StreamReader = function() {
|
|||||||
this._cursor = 0;
|
this._cursor = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
StreamReader.prototype.read = function(bytes) {
|
|
||||||
return this._readBuffer(bytes);
|
|
||||||
};
|
|
||||||
|
|
||||||
StreamReader.prototype.put = function(buffer) {
|
StreamReader.prototype.put = function(buffer) {
|
||||||
if (!buffer || buffer.length === 0) return;
|
if (!buffer || buffer.length === 0) return;
|
||||||
if (!buffer.copy) buffer = new Buffer(buffer);
|
if (!buffer.copy) buffer = new Buffer(buffer);
|
||||||
@ -15,7 +11,7 @@ StreamReader.prototype.put = function(buffer) {
|
|||||||
this._queueSize += buffer.length;
|
this._queueSize += buffer.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
StreamReader.prototype._readBuffer = function(length) {
|
StreamReader.prototype.read = function(length) {
|
||||||
if (length > this._queueSize) return null;
|
if (length > this._queueSize) return null;
|
||||||
|
|
||||||
var buffer = new Buffer(length),
|
var buffer = new Buffer(length),
|
||||||
@ -23,22 +19,22 @@ StreamReader.prototype._readBuffer = function(length) {
|
|||||||
remain = length,
|
remain = length,
|
||||||
n = queue.length,
|
n = queue.length,
|
||||||
i = 0,
|
i = 0,
|
||||||
chunk, offset, size;
|
chunk, size;
|
||||||
|
|
||||||
if (remain === 0) return buffer;
|
|
||||||
|
|
||||||
while (remain > 0 && i < n) {
|
while (remain > 0 && i < n) {
|
||||||
chunk = queue[i];
|
chunk = queue[i];
|
||||||
offset = (i === 0) ? this._cursor : 0;
|
size = Math.min(remain, chunk.length - this._cursor);
|
||||||
size = Math.min(remain, chunk.length - offset);
|
|
||||||
chunk.copy(buffer, length - remain, offset, offset + size);
|
chunk.copy(buffer, length - remain, this._cursor, this._cursor + size);
|
||||||
remain -= size;
|
|
||||||
|
remain -= size;
|
||||||
this._queueSize -= size;
|
this._queueSize -= size;
|
||||||
|
this._cursor = (this._cursor + size) % chunk.length;
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.splice(0, i-1);
|
queue.splice(0, this._cursor === 0 ? i : i - 1);
|
||||||
this._cursor = (i === 1 ? this._cursor : 0) + size;
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -40,6 +40,9 @@ var instance = {
|
|||||||
this._delegate.on(event, function(e) { self.emit(event, e) });
|
this._delegate.on(event, function(e) { self.emit(event, e) });
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
this.protocol = this._delegate.protocol;
|
||||||
|
this.version = this._delegate.version;
|
||||||
|
|
||||||
this.parse(this._http.body);
|
this.parse(this._http.body);
|
||||||
this.emit('connect', new Base.ConnectEvent());
|
this.emit('connect', new Base.ConnectEvent());
|
||||||
},
|
},
|
||||||
@ -101,4 +104,3 @@ Server.http = function(request, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Server;
|
module.exports = Server;
|
||||||
|
|
||||||
|
|||||||
@ -141,4 +141,3 @@ Messages.prototype.destroy = function() {};
|
|||||||
|
|
||||||
exports.IO = IO;
|
exports.IO = IO;
|
||||||
exports.Messages = Messages;
|
exports.Messages = Messages;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
14
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/package.json
generated
vendored
14
CoAuthoring/node_modules/sockjs/node_modules/faye-websocket/package.json
generated
vendored
File diff suppressed because one or more lines are too long
6
CoAuthoring/node_modules/sockjs/node_modules/node-uuid/package.json
generated
vendored
6
CoAuthoring/node_modules/sockjs/node_modules/node-uuid/package.json
generated
vendored
@ -31,5 +31,9 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/broofa/node-uuid",
|
"homepage": "https://github.com/broofa/node-uuid",
|
||||||
"_id": "node-uuid@1.3.3",
|
"_id": "node-uuid@1.3.3",
|
||||||
"_from": "node-uuid@1.3.3"
|
"dist": {
|
||||||
|
"shasum": "4f758576edd9e2726cf9182d6755039e277ad581"
|
||||||
|
},
|
||||||
|
"_from": "node-uuid@1.3.3",
|
||||||
|
"_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.3.3.tgz"
|
||||||
}
|
}
|
||||||
|
|||||||
9
CoAuthoring/node_modules/sockjs/package.json
generated
vendored
9
CoAuthoring/node_modules/sockjs/package.json
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user