Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f50de64532 | |||
| d071ec3acd | |||
| 59fd729a03 | |||
| b458959e6a | |||
| 7f18af7c90 | |||
| 680d8fc759 | |||
| 90d039e371 | |||
| b42cdf741d | |||
| bd7c52dfa2 |
+1
-1
@@ -2,4 +2,4 @@ language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
||||
- 0.7
|
||||
- 0.8
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
=== 0.4.3 / 2012-07-09
|
||||
|
||||
* Add 'Connection: close' to EventSource response
|
||||
* Handle situations where request.socket is undefined
|
||||
|
||||
|
||||
=== 0.4.2 / 2012-04-06
|
||||
|
||||
* Add WebSocket error code 1011.
|
||||
* Handle URLs with no path correctly by sending 'GET /'
|
||||
|
||||
|
||||
=== 0.4.1 / 2012-02-26
|
||||
|
||||
* Treat anything other than a Buffer as a string when calling send()
|
||||
|
||||
@@ -19,9 +19,6 @@ var EventSource = function(request, response, options) {
|
||||
this._ping = options.ping || this.DEFAULT_PING;
|
||||
this._retry = options.retry || this.DEFAULT_RETRY;
|
||||
|
||||
this._stream.setTimeout(0);
|
||||
this._stream.setNoDelay(true);
|
||||
|
||||
var scheme = isSecureConnection(request) ? 'https:' : 'http:';
|
||||
this.url = scheme + '//' + request.headers.host + request.url;
|
||||
|
||||
@@ -35,18 +32,22 @@ var EventSource = function(request, response, options) {
|
||||
var handshake = 'HTTP/1.1 200 OK\r\n' +
|
||||
'Content-Type: text/event-stream\r\n' +
|
||||
'Cache-Control: no-cache, no-store\r\n' +
|
||||
'Connection: close\r\n' +
|
||||
'\r\n\r\n' +
|
||||
'retry: ' + Math.floor(this._retry * 1000) + '\r\n\r\n';
|
||||
|
||||
try {
|
||||
this._stream.write(handshake, 'utf8');
|
||||
} catch (e) {}
|
||||
|
||||
this.readyState = API.OPEN;
|
||||
|
||||
if (this._ping)
|
||||
this._pingLoop = setInterval(function() { self.ping() }, this._ping * 1000);
|
||||
|
||||
if (!this._stream || !this._stream.writable) return;
|
||||
|
||||
this._stream.setTimeout(0);
|
||||
this._stream.setNoDelay(true);
|
||||
|
||||
try { this._stream.write(handshake, 'utf8') } catch (e) {}
|
||||
|
||||
['close', 'end', 'error'].forEach(function(event) {
|
||||
self._stream.addListener(event, function() { self.close() });
|
||||
});
|
||||
|
||||
@@ -37,9 +37,6 @@ var WebSocket = function(request, socket, head, supportedProtos, options) {
|
||||
this._ping = options && options.ping;
|
||||
this._pingId = 0;
|
||||
|
||||
this._stream.setTimeout(0);
|
||||
this._stream.setNoDelay(true);
|
||||
|
||||
var scheme = isSecureConnection(request) ? 'wss:' : 'ws:';
|
||||
this.url = scheme + '//' + request.headers.host + request.url;
|
||||
this.readyState = API.CONNECTING;
|
||||
@@ -53,8 +50,6 @@ var WebSocket = function(request, socket, head, supportedProtos, options) {
|
||||
process.nextTick(function() { self._open() });
|
||||
|
||||
var handshake = this._parser.handshakeResponse(head);
|
||||
try { this._stream.write(handshake, 'binary') } catch (e) {}
|
||||
|
||||
if (this._parser.isOpen()) this.readyState = API.OPEN;
|
||||
|
||||
if (this._ping)
|
||||
@@ -66,6 +61,13 @@ var WebSocket = function(request, socket, head, supportedProtos, options) {
|
||||
this.protocol = this._parser.protocol || '';
|
||||
this.version = this._parser.getVersion();
|
||||
|
||||
if (!this._stream || !this._stream.writable) return;
|
||||
|
||||
this._stream.setTimeout(0);
|
||||
this._stream.setNoDelay(true);
|
||||
|
||||
try { this._stream.write(handshake, 'binary') } catch (e) {}
|
||||
|
||||
this._stream.addListener('data', function(data) {
|
||||
var response = self._parser.parse(data);
|
||||
if (!response) return;
|
||||
|
||||
@@ -63,7 +63,7 @@ var API = {
|
||||
var close = function() {
|
||||
this.readyState = API.CLOSED;
|
||||
if (this._pingLoop) clearInterval(this._pingLoop);
|
||||
this._stream.end();
|
||||
if (this._stream) this._stream.end();
|
||||
var event = new Event('close', {code: code || 1000, reason: reason || ''});
|
||||
event.initEvent('close', false, false);
|
||||
this.dispatchEvent(event);
|
||||
|
||||
@@ -46,20 +46,21 @@ var instance = {
|
||||
},
|
||||
|
||||
ERRORS: {
|
||||
normal_closure: 1000,
|
||||
going_away: 1001,
|
||||
protocol_error: 1002,
|
||||
unacceptable: 1003,
|
||||
encoding_error: 1007,
|
||||
policy_violation: 1008,
|
||||
too_large: 1009,
|
||||
extension_error: 1010
|
||||
normal_closure: 1000,
|
||||
going_away: 1001,
|
||||
protocol_error: 1002,
|
||||
unacceptable: 1003,
|
||||
encoding_error: 1007,
|
||||
policy_violation: 1008,
|
||||
too_large: 1009,
|
||||
extension_error: 1010,
|
||||
unexpected_condition: 1011
|
||||
},
|
||||
|
||||
FRAGMENTED_OPCODES: [0,1,2],
|
||||
OPENING_OPCODES: [1,2],
|
||||
|
||||
ERROR_CODES: [1000,1001,1002,1003,1007,1008,1009,1010],
|
||||
ERROR_CODES: [1000,1001,1002,1003,1007,1008,1009,1010,1011],
|
||||
|
||||
UTF8_MATCH: /^([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/,
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ Handshake.prototype.requestData = function() {
|
||||
var u = this._uri;
|
||||
|
||||
var headers = [
|
||||
'GET ' + u.pathname + (u.search || '') + ' HTTP/1.1',
|
||||
'GET ' + (u.pathname || '/') + (u.search || '') + ' HTTP/1.1',
|
||||
'Host: ' + u.hostname + (u.port ? ':' + u.port : ''),
|
||||
'Upgrade: websocket',
|
||||
'Connection: Upgrade',
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@
|
||||
, "author" : "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)"
|
||||
, "keywords" : ["websocket", "eventsource"]
|
||||
|
||||
, "version" : "0.4.1"
|
||||
, "version" : "0.4.3"
|
||||
, "engines" : {"node": ">=0.4.0"}
|
||||
, "main" : "./lib/faye/websocket"
|
||||
, "devDependencies" : {"jsclass": ""}
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
, "bugs" : "http://github.com/faye/faye-websocket-node/issues"
|
||||
|
||||
, "licenses" : [ { "type" : "MIT"
|
||||
, "url" : "http://www.opensource.org/licenses/mit-license.php"
|
||||
, "licenses" : [ { "type" : "MIT"
|
||||
, "url" : "http://www.opensource.org/licenses/mit-license.php"
|
||||
}
|
||||
]
|
||||
|
||||
, "repositories" : [ { "type" : "git"
|
||||
, "url" : "git://github.com/faye/faye-websocket-node.git"
|
||||
, "repositories" : [ { "type" : "git"
|
||||
, "url" : "git://github.com/faye/faye-websocket-node.git"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -137,15 +137,6 @@ JS.ENV.HybiParserSpec = JS.Test.describe("HybiParser", function() { with(this) {
|
||||
assertBufferEqual( [129, 126, 0, 200, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111], parser.frame("HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello") )
|
||||
}})
|
||||
|
||||
it("encodes long strings using extra length bytes", function() { with(this) {
|
||||
var reps = 13108, message = '', output = [0x81, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04]
|
||||
while (reps--) {
|
||||
message += "Hello"
|
||||
output = output.concat([0x48, 0x65, 0x6c, 0x6c, 0x6f])
|
||||
}
|
||||
assertBufferEqual( output, parser.frame(message) )
|
||||
}})
|
||||
|
||||
it("encodes close frames with an error code", function() { with(this) {
|
||||
assertBufferEqual( [0x88, 0x07, 0x03, 0xea, 0x48, 0x65, 0x6c, 0x6c, 0x6f], parser.frame("Hello", "close", 1002) )
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user