Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f50de64532 | |||
| d071ec3acd | |||
| 59fd729a03 | |||
| b458959e6a | |||
| 7f18af7c90 | |||
| 680d8fc759 |
+1
-1
@@ -2,4 +2,4 @@ language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
||||
- 0.7
|
||||
- 0.8
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
=== 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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@
|
||||
, "author" : "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)"
|
||||
, "keywords" : ["websocket", "eventsource"]
|
||||
|
||||
, "version" : "0.4.2"
|
||||
, "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