Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 913b174ea1 | |||
| 0eb99773db | |||
| 758ed46420 | |||
| 9cb62ecd49 |
+6
-1
@@ -1,3 +1,4 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
@@ -5,7 +6,11 @@ node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
- "iojs-1"
|
||||
- "iojs-2"
|
||||
- "iojs-3"
|
||||
- "4"
|
||||
- "5"
|
||||
|
||||
before_install:
|
||||
- '[ "${TRAVIS_NODE_VERSION}" = "0.6" ] && npm conf set strict-ssl false || true'
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
### 0.1.4 / 2015-11-06
|
||||
|
||||
* The server does not send `server_max_window_bits` if the client does not ask
|
||||
for it; this works around an issue in Firefox.
|
||||
|
||||
### 0.1.3 / 2015-04-10
|
||||
|
||||
* Fix a race condition causing some fragments of deflate output to be dropped
|
||||
|
||||
@@ -64,12 +64,12 @@ ClientSession.prototype.activate = function(params) {
|
||||
|
||||
this._ownContextTakeover = !(this._acceptNoContextTakeover || params.client_no_context_takeover);
|
||||
this._ownWindowBits = Math.min(
|
||||
this._acceptMaxWindowBits || common.DEFAULT_MAX_WINDOW_BITS,
|
||||
params.client_max_window_bits || common.DEFAULT_MAX_WINDOW_BITS
|
||||
this._acceptMaxWindowBits || common.MAX_WINDOW_BITS,
|
||||
params.client_max_window_bits || common.MAX_WINDOW_BITS
|
||||
);
|
||||
|
||||
this._peerContextTakeover = !params.server_no_context_takeover;
|
||||
this._peerWindowBits = params.server_max_window_bits || common.DEFAULT_MAX_WINDOW_BITS;
|
||||
this._peerWindowBits = params.server_max_window_bits || common.MAX_WINDOW_BITS;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ var common = {
|
||||
'client_max_window_bits'
|
||||
],
|
||||
|
||||
DEFAULT_MAX_WINDOW_BITS: 15,
|
||||
MAX_WINDOW_BITS: 15,
|
||||
VALID_WINDOW_BITS: [8, 9, 10, 11, 12, 13, 14, 15],
|
||||
|
||||
concat: function(buffers, length) {
|
||||
|
||||
+27
-23
@@ -21,42 +21,46 @@ ServerSession.validParams = function(params) {
|
||||
};
|
||||
|
||||
ServerSession.prototype.generateResponse = function() {
|
||||
var params = {};
|
||||
var response = {};
|
||||
|
||||
// https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.1.1
|
||||
if (this._acceptNoContextTakeover || this._params.server_no_context_takeover)
|
||||
params.server_no_context_takeover = true;
|
||||
|
||||
this._ownContextTakeover = !this._acceptNoContextTakeover &&
|
||||
!this._params.server_no_context_takeover;
|
||||
|
||||
if (!this._ownContextTakeover) response.server_no_context_takeover = true;
|
||||
|
||||
// https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.1.2
|
||||
if (this._requestNoContextTakeover || this._params.client_no_context_takeover)
|
||||
params.client_no_context_takeover = true;
|
||||
|
||||
this._peerContextTakeover = !this._requestNoContextTakeover &&
|
||||
!this._params.client_no_context_takeover;
|
||||
|
||||
if (!this._peerContextTakeover) response.client_no_context_takeover = true;
|
||||
|
||||
// https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.2.1
|
||||
var acceptMax, serverMax;
|
||||
if (this._acceptMaxWindowBits || this._params.server_max_window_bits) {
|
||||
acceptMax = this._acceptMaxWindowBits || common.DEFAULT_MAX_WINDOW_BITS;
|
||||
serverMax = this._params.server_max_window_bits || common.DEFAULT_MAX_WINDOW_BITS;
|
||||
params.server_max_window_bits = Math.min(acceptMax, serverMax);
|
||||
}
|
||||
|
||||
this._ownWindowBits = Math.min(this._acceptMaxWindowBits || common.MAX_WINDOW_BITS,
|
||||
this._params.server_max_window_bits || common.MAX_WINDOW_BITS);
|
||||
|
||||
// In violation of the spec, Firefox closes the connection if it does not
|
||||
// send server_max_window_bits but the server includes this in its response
|
||||
if (this._ownWindowBits < common.MAX_WINDOW_BITS && this._params.server_max_window_bits)
|
||||
response.server_max_window_bits = this._ownWindowBits;
|
||||
|
||||
// https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.2.2
|
||||
|
||||
var clientMax = this._params.client_max_window_bits, requestMax;
|
||||
if (clientMax) {
|
||||
if (clientMax === true) {
|
||||
if (this._requestMaxWindowBits) params.client_max_window_bits = this._requestMaxWindowBits;
|
||||
} else {
|
||||
requestMax = this._requestMaxWindowBits || common.DEFAULT_MAX_WINDOW_BITS;
|
||||
params.client_max_window_bits = Math.min(requestMax, clientMax);
|
||||
}
|
||||
if (clientMax === true) clientMax = common.MAX_WINDOW_BITS;
|
||||
this._peerWindowBits = Math.min(this._requestMaxWindowBits || common.MAX_WINDOW_BITS, clientMax);
|
||||
} else {
|
||||
this._peerWindowBits = common.MAX_WINDOW_BITS;
|
||||
}
|
||||
|
||||
this._ownContextTakeover = !params.server_no_context_takeover;
|
||||
this._ownWindowBits = params.server_max_window_bits || common.DEFAULT_MAX_WINDOW_BITS;
|
||||
if (this._peerWindowBits < common.MAX_WINDOW_BITS)
|
||||
response.client_max_window_bits = this._peerWindowBits;
|
||||
|
||||
this._peerContextTakeover = !params.client_no_context_takeover;
|
||||
this._peerWindowBits = params.client_max_window_bits || common.DEFAULT_MAX_WINDOW_BITS;
|
||||
|
||||
return params;
|
||||
return response;
|
||||
};
|
||||
|
||||
module.exports = ServerSession;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
, "keywords" : ["websocket", "compression", "deflate"]
|
||||
, "license" : "MIT"
|
||||
|
||||
, "version" : "0.1.3"
|
||||
, "version" : "0.1.4"
|
||||
, "engines" : {"node": ">=0.6.0"}
|
||||
, "main" : "./lib/permessage_deflate"
|
||||
, "devDependencies" : {"jstest": ""}
|
||||
|
||||
@@ -2,7 +2,7 @@ var PermessageDeflate = require('../lib/permessage_deflate'),
|
||||
zlib = require('zlib'),
|
||||
test = require('jstest').Test
|
||||
|
||||
test.describe("ClientSession", function() { with(this) {
|
||||
test.describe("ServerSession", function() { with(this) {
|
||||
before(function() { with(this) {
|
||||
this.ext = PermessageDeflate.configure(options)
|
||||
this.session = ext.createServerSession([offer])
|
||||
@@ -183,8 +183,8 @@ test.describe("ClientSession", function() { with(this) {
|
||||
define("options", {maxWindowBits: 12})
|
||||
|
||||
describe("with an empty offer", function() { with(this) {
|
||||
it("includes server_max_window_bits in the response", function() { with(this) {
|
||||
assertEqual( {server_max_window_bits: 12}, response() )
|
||||
it("does not include server_max_window_bits in the response", function() { with(this) {
|
||||
assertEqual( {}, response() )
|
||||
}})
|
||||
|
||||
it("uses context takeover and 12 window bits for deflating outgoing messages", function() { with(this) {
|
||||
|
||||
Reference in New Issue
Block a user