6 Commits

Author SHA1 Message Date
James Coglan 68ceed8cf8 Test on recent versions of Node 2023-09-07 19:24:32 +01:00
James Coglan 947ad6692b Switch from Travis CI to GitHub Actions 2021-05-18 22:11:31 +01:00
James Coglan 8ee77a23c0 Travis update: cache npm modules, remove sudo, run on Node 15 2021-03-12 21:37:13 +00:00
James Coglan 5eddd922aa Add Node versions 13 and 14 on Travis 2020-05-14 23:52:45 +01:00
James Coglan 75b434c6a0 Mention license change in the changelog 2019-06-13 11:38:41 +01:00
James Coglan ae94112fe9 Formatting change: {...} should have spaces inside the braces 2019-06-11 15:50:38 +01:00
9 changed files with 138 additions and 115 deletions
+41
View File
@@ -0,0 +1,41 @@
on:
- push
- pull_request
jobs:
test:
strategy:
fail-fast: false
matrix:
node:
- '0.8'
- '0.10'
- '0.12'
- '4'
- '6'
- '8'
- '10'
- '12'
- '14'
- '16'
- '18'
- '20'
name: node.js v${{ matrix.node }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- if: matrix.node == '0.8'
run: npm conf set strict-ssl false
- run: node --version
- run: npm install
- run: npm install 'nopt@5'
- run: rm -rf node_modules/jstest/node_modules/nopt
- run: npm test
-19
View File
@@ -1,19 +0,0 @@
sudo: false
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"
- "11"
- "12"
before_install:
- '[ "${TRAVIS_NODE_VERSION}" = "0.8" ] && npm install -g npm@~1.4.0 || true'
+1
View File
@@ -2,6 +2,7 @@
- Use the `Buffer.alloc()` and `Buffer.from()` functions instead of the unsafe
`Buffer()` constructor
- Change license from MIT to Apache 2.0
### 0.1.6 / 2017-09-10
+1 -1
View File
@@ -1,4 +1,4 @@
# permessage-deflate [![Build status](https://secure.travis-ci.org/faye/permessage-deflate-node.svg)](http://travis-ci.org/faye/permessage-deflate-node)
# permessage-deflate
Implements the
[permessage-deflate](https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression)
+1 -1
View File
@@ -22,7 +22,7 @@ function compress(index) {
return decompress(0);
}
var message = {data: new Buffer(record[3], 'base64')};
var message = { data: new Buffer(record[3], 'base64') };
size[0] += message.data.length;
server.processOutgoingMessage(message, function(error, message) {
+1 -1
View File
@@ -20,7 +20,7 @@ var PermessageDeflate = {
common.validateOptions(options, VALID_OPTIONS);
var opts = this._options || {};
for (var key in opts) options[key] = opts[key];
return Object.create(this, {_options: {value: options}});
return Object.create(this, { _options: { value: options }});
},
createClientSession: function() {
+1 -1
View File
@@ -128,7 +128,7 @@ Session.prototype._getInflate = function() {
if (this._inflate) return this._inflate;
var windowBits = Math.max(this._peerWindowBits, common.MIN_WINDOW_BITS),
inflate = this._zlib.createInflateRaw({windowBits: windowBits});
inflate = this._zlib.createInflateRaw({ windowBits: windowBits });
if (this._peerContextTakeover) this._inflate = inflate;
return inflate;
+41 -41
View File
@@ -12,9 +12,9 @@ test.describe("ClientSession", function() { with(this) {
this.ext = PermessageDeflate.configure(options)
this.zlib = {}
this.session = ext.configure({zlib: zlib}).createClientSession()
this.session = ext.configure({ zlib: zlib }).createClientSession()
this.message = {data: "hello", rsv1: true}
this.message = { data: "hello", rsv1: true }
}})
define("zlibMock", function() {
@@ -54,7 +54,7 @@ test.describe("ClientSession", function() { with(this) {
describe("with default options", function() { with(this) {
it("indicates support for client_max_window_bits", function() { with(this) {
assertEqual( {client_max_window_bits: true}, offer() )
assertEqual( { client_max_window_bits: true }, offer() )
}})
describe("with an empty response", function() { with(this) {
@@ -64,21 +64,21 @@ test.describe("ClientSession", function() { with(this) {
it("uses context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
activate()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
it("uses context takeover and 15 window bits for deflating outgoing messages", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
}})
describe("when the response includes server_no_context_takeover", function() { with(this) {
define("response", {server_no_context_takeover: true})
define("response", { server_no_context_takeover: true })
it("accepts the response", function() { with(this) {
assertEqual( true, activate() )
@@ -86,7 +86,7 @@ test.describe("ClientSession", function() { with(this) {
it("ues no context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
activate()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(2).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(2).returning(inflate)
expect(inflate, "close").exactly(2)
processIncomingMessage()
processIncomingMessage()
@@ -100,7 +100,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("when the response includes client_no_context_takeover", function() { with(this) {
define("response", {client_no_context_takeover: true})
define("response", { client_no_context_takeover: true })
it("accepts the response", function() { with(this) {
assertEqual( true, activate() )
@@ -108,7 +108,7 @@ test.describe("ClientSession", function() { with(this) {
it("uses no context takeover and 15 window bits to deflate outgoing messages", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: level, memLevel: memLevel, strategy: strategy}).exactly(2).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: level, memLevel: memLevel, strategy: strategy }).exactly(2).returning(deflate)
expect(deflate, "close").exactly(2)
processOutgoingMessage()
processOutgoingMessage()
@@ -122,7 +122,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("when the response includes server_max_window_bits", function() { with(this) {
define("response", {server_max_window_bits: 8})
define("response", { server_max_window_bits: 8 })
it("accepts the response", function() { with(this) {
assertEqual( true, activate() )
@@ -130,14 +130,14 @@ test.describe("ClientSession", function() { with(this) {
it("uses context takeover and 9 window bits for inflating incoming messages", function() { with(this) {
activate()
expect(zlib, "createInflateRaw").given({windowBits: 9}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 9 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
}})
describe("when the response includes invalid server_max_window_bits", function() { with(this) {
define("response", {server_max_window_bits: 20})
define("response", { server_max_window_bits: 20 })
it("rejects the response", function() { with(this) {
assertEqual( false, activate() )
@@ -145,7 +145,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("when the response includes client_max_window_bits", function() { with(this) {
define("response", {client_max_window_bits: 8})
define("response", { client_max_window_bits: 8 })
it("accepts the response", function() { with(this) {
assertEqual( true, activate() )
@@ -153,14 +153,14 @@ test.describe("ClientSession", function() { with(this) {
it("uses context takeover and 9 window bits for deflating outgoing messages", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 9, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 9, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
}})
describe("when the response includes invalid client_max_window_bits", function() { with(this) {
define("response", {client_max_window_bits: 20})
define("response", { client_max_window_bits: 20 })
it("rejects the response", function() { with(this) {
assertEqual( false, activate() )
@@ -169,10 +169,10 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("with noContextTakeover", function() { with(this) {
define("options", {noContextTakeover: true})
define("options", { noContextTakeover: true })
it("sends client_no_context_takeover", function() { with(this) {
assertEqual( {client_no_context_takeover: true, client_max_window_bits: true}, offer() )
assertEqual( { client_no_context_takeover: true, client_max_window_bits: true }, offer() )
}})
describe("with an empty response", function() { with(this) {
@@ -182,7 +182,7 @@ test.describe("ClientSession", function() { with(this) {
it("uses no context takeover and 15 window bits for deflating outgoing messages", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: level, memLevel: memLevel, strategy: strategy}).exactly(2).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: level, memLevel: memLevel, strategy: strategy }).exactly(2).returning(deflate)
expect(deflate, "close").exactly(2)
processOutgoingMessage()
processOutgoingMessage()
@@ -191,10 +191,10 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("with maxWindowBits", function() { with(this) {
define("options", {maxWindowBits: 9})
define("options", { maxWindowBits: 9 })
it("sends client_max_window_bits", function() { with(this) {
assertEqual( {client_max_window_bits: 9}, offer() )
assertEqual( { client_max_window_bits: 9 }, offer() )
}})
describe("with an empty response", function() { with(this) {
@@ -204,14 +204,14 @@ test.describe("ClientSession", function() { with(this) {
it("uses context takeover and 9 window bits for deflating outgoing messages", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 9, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 9, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
}})
describe("when the response has higher client_max_window_bits", function() { with(this) {
define("response", {client_max_window_bits: 10})
define("response", { client_max_window_bits: 10 })
it("rejects the response", function() { with(this) {
assertEqual( false, activate() )
@@ -219,7 +219,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("when the response has lower client_max_window_bits", function() { with(this) {
define("response", {client_max_window_bits: 8});
define("response", { client_max_window_bits: 8 });
it("accepts the response", function() { with(this) {
assertEqual( true, activate() )
@@ -227,7 +227,7 @@ test.describe("ClientSession", function() { with(this) {
it("uses context takeover and 9 window bits for deflating outgoing messages", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 9, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 9, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
@@ -235,7 +235,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("with invalid maxWindowBits", function() { with(this) {
define("options", {maxWindowBits: 20})
define("options", { maxWindowBits: 20 })
it("throws when generating the offer", function() { with(this) {
assertThrows(Error, function() { offer() })
@@ -243,10 +243,10 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("with requestNoContextTakeover", function() { with(this) {
define("options", {requestNoContextTakeover: true})
define("options", { requestNoContextTakeover: true })
it("sends server_no_context_takeover", function() { with(this) {
assertEqual( {client_max_window_bits: true, server_no_context_takeover: true}, offer() )
assertEqual( { client_max_window_bits: true, server_no_context_takeover: true }, offer() )
}})
describe("with an empty response", function() { with(this) {
@@ -256,7 +256,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("when the response includes server_no_context_takeover", function() { with(this) {
define("response", {server_no_context_takeover: true})
define("response", { server_no_context_takeover: true })
it("accepts the response", function() { with(this) {
assertEqual( true, activate() )
@@ -264,7 +264,7 @@ test.describe("ClientSession", function() { with(this) {
it("uses no context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
activate()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(2).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(2).returning(inflate)
expect(inflate, "close").exactly(2)
processIncomingMessage()
processIncomingMessage()
@@ -273,10 +273,10 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("with requestMaxWindowBits", function() { with(this) {
define("options", {requestMaxWindowBits: 12})
define("options", { requestMaxWindowBits: 12 })
it("sends server_max_window_bits", function() { with(this) {
assertEqual( { client_max_window_bits: true, server_max_window_bits: 12}, offer() )
assertEqual( { client_max_window_bits: true, server_max_window_bits: 12 }, offer() )
}})
describe("with an empty response", function() { with(this) {
@@ -286,7 +286,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("when the response has higher server_max_window_bits", function() { with(this) {
define("response", {server_max_window_bits: 13})
define("response", { server_max_window_bits: 13 })
it("rejects the response", function() { with(this) {
assertEqual( false, activate() )
@@ -294,7 +294,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("when the response has lower server_max_window_bits", function() { with(this) {
define("response", {server_max_window_bits: 11})
define("response", { server_max_window_bits: 11 })
it("accepts the response", function() { with(this) {
assertEqual( true, activate() )
@@ -302,7 +302,7 @@ test.describe("ClientSession", function() { with(this) {
it("uses context takeover and 11 window bits for inflating incoming messages", function() { with(this) {
activate()
expect(zlib, "createInflateRaw").given({windowBits: 11}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 11 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
@@ -310,7 +310,7 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("with invalid requestMaxWindowBits", function() { with(this) {
define("options", {requestMaxWindowBits: 20})
define("options", { requestMaxWindowBits: 20 })
it("throws when generating the offer", function() { with(this) {
assertThrows(Error, function() { offer() })
@@ -318,31 +318,31 @@ test.describe("ClientSession", function() { with(this) {
}})
describe("with level", function() { with(this) {
define("options", {level: _zlib.Z_BEST_SPEED})
define("options", { level: _zlib.Z_BEST_SPEED })
it("sets the level of the deflate stream", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: _zlib.Z_BEST_SPEED, memLevel: memLevel, strategy: strategy}).returns(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: _zlib.Z_BEST_SPEED, memLevel: memLevel, strategy: strategy }).returns(deflate)
processOutgoingMessage()
}})
}})
describe("with memLevel", function() { with(this) {
define("options", {memLevel: 5})
define("options", { memLevel: 5 })
it("sets the memLevel of the deflate stream", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: 5, strategy: strategy}).returns(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: 5, strategy: strategy }).returns(deflate)
processOutgoingMessage()
}})
}})
describe("with strategy", function() { with(this) {
define("options", {strategy: _zlib.Z_FILTERED})
define("options", { strategy: _zlib.Z_FILTERED })
it("sets the strategy of the deflate stream", function() { with(this) {
activate()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: memLevel, strategy: _zlib.Z_FILTERED}).returns(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: memLevel, strategy: _zlib.Z_FILTERED }).returns(deflate)
processOutgoingMessage()
}})
}})
+51 -51
View File
@@ -12,9 +12,9 @@ test.describe("ServerSession", function() { with(this) {
this.ext = PermessageDeflate.configure(options)
this.zlib = {}
this.session = ext.configure({zlib: zlib}).createServerSession([offer])
this.session = ext.configure({ zlib: zlib }).createServerSession([offer])
this.message = {data: "hello", rsv1: true}
this.message = { data: "hello", rsv1: true }
}})
define("zlibMock", function() {
@@ -55,29 +55,29 @@ test.describe("ServerSession", function() { with(this) {
it("uses context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
it("uses context takeover and 15 window bits for deflating outgoing messages", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
}})
describe("when the offer includes server_no_context_takeover", function() { with(this) {
define("offer", {server_no_context_takeover: true})
define("offer", { server_no_context_takeover: true })
it("includes server_no_context_takeover in the response", function() { with(this) {
assertEqual( {server_no_context_takeover: true}, response() )
assertEqual( { server_no_context_takeover: true }, response() )
}})
it("uses no context takeover and 15 window bits for deflating outgoing messages", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: level, memLevel: memLevel, strategy: strategy}).exactly(2).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: level, memLevel: memLevel, strategy: strategy }).exactly(2).returning(deflate)
expect(deflate, "close").exactly(2)
processOutgoingMessage()
processOutgoingMessage()
@@ -91,15 +91,15 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("when the offer includes client_no_context_takeover", function() { with(this) {
define("offer", {client_no_context_takeover: true})
define("offer", { client_no_context_takeover: true })
it("includes client_no_context_takeover in the response", function() { with(this) {
assertEqual( {client_no_context_takeover: true}, response() )
assertEqual( { client_no_context_takeover: true }, response() )
}})
it("uses no context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(2).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(2).returning(inflate)
expect(inflate, "close").exactly(2)
processIncomingMessage()
processIncomingMessage()
@@ -113,22 +113,22 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("when the offer includes server_max_window_bits", function() { with(this) {
define("offer", {server_max_window_bits: 13})
define("offer", { server_max_window_bits: 13 })
it("includes server_max_window_bits in the response", function() { with(this) {
assertEqual( {server_max_window_bits: 13}, response() )
assertEqual( { server_max_window_bits: 13 }, response() )
}})
it("uses context takeover and 13 window bits for deflating outgoing messages", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 13, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 13, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
}})
describe("when the offer includes invalid server_max_window_bits", function() { with(this) {
define("offer", {server_max_window_bits: 20})
define("offer", { server_max_window_bits: 20 })
it("does not create a session", function() { with(this) {
assertEqual( null, session )
@@ -136,7 +136,7 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("when the offer includes client_max_window_bits", function() { with(this) {
define("offer", {client_max_window_bits: true})
define("offer", { client_max_window_bits: true })
it("does not include a client_max_window_bits hint in the response", function() { with(this) {
assertEqual( {}, response() )
@@ -144,29 +144,29 @@ test.describe("ServerSession", function() { with(this) {
it("uses context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
}})
describe("when the offer includes a client_max_window_bits hint", function() { with(this) {
define("offer", {client_max_window_bits: 13})
define("offer", { client_max_window_bits: 13 })
it("includes a client_max_window_bits hint in the response", function() { with(this) {
assertEqual( {client_max_window_bits: 13}, response() )
assertEqual( { client_max_window_bits: 13 }, response() )
}})
it("uses context takeover and 13 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 13}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 13 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
}})
describe("when the offer includes invalid client_max_window_bits", function() { with(this) {
define("offer", {client_max_window_bits: 20})
define("offer", { client_max_window_bits: 20 })
it("does not create a session", function() { with(this) {
assertEqual( null, session )
@@ -175,16 +175,16 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("with noContextTakeover", function() { with(this) {
define("options", {noContextTakeover: true})
define("options", { noContextTakeover: true })
describe("with an empty offer", function() { with(this) {
it("includes server_no_context_takeover in the response", function() { with(this) {
assertEqual( {server_no_context_takeover: true}, response() )
assertEqual( { server_no_context_takeover: true }, response() )
}})
it("uses no context takeover and 15 window bits for deflating outgoing messages", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: level, memLevel: memLevel, strategy: strategy}).exactly(2).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: level, memLevel: memLevel, strategy: strategy }).exactly(2).returning(deflate)
expect(deflate, "close").exactly(2)
processOutgoingMessage()
processOutgoingMessage()
@@ -193,7 +193,7 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("with maxWindowBits", function() { with(this) {
define("options", {maxWindowBits: 12})
define("options", { maxWindowBits: 12 })
describe("with an empty offer", function() { with(this) {
it("does not include server_max_window_bits in the response", function() { with(this) {
@@ -202,37 +202,37 @@ test.describe("ServerSession", function() { with(this) {
it("uses context takeover and 12 window bits for deflating outgoing messages", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 12, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 12, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
}})
describe("when the offer has higher server_max_window_bits", function() { with(this) {
define("offer", {server_max_window_bits: 13})
define("offer", { server_max_window_bits: 13 })
it("includes server_max_window_bits in the response", function() { with(this) {
assertEqual( {server_max_window_bits: 12}, response() )
assertEqual( { server_max_window_bits: 12 }, response() )
}})
it("uses context takeover and 12 window bits for deflating outgoing messages", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 12, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 12, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
}})
describe("when the offer has lower server_max_window_bits", function() { with(this) {
define("offer", {server_max_window_bits: 11})
define("offer", { server_max_window_bits: 11 })
it("includes server_max_window_bits in the response", function() { with(this) {
assertEqual( {server_max_window_bits: 11}, response() )
assertEqual( { server_max_window_bits: 11 }, response() )
}})
it("uses context takeover and 11 window bits for deflating outgoing messages", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 11, level: level, memLevel: memLevel, strategy: strategy}).exactly(1).returning(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 11, level: level, memLevel: memLevel, strategy: strategy }).exactly(1).returning(deflate)
processOutgoingMessage()
processOutgoingMessage()
}})
@@ -240,16 +240,16 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("with requestNoContextTakeover", function() { with(this) {
define("options", {requestNoContextTakeover: true})
define("options", { requestNoContextTakeover: true })
describe("with an empty offer", function() { with(this) {
it("includes client_no_context_takeover in the response", function() { with(this) {
assertEqual( {client_no_context_takeover: true}, response() )
assertEqual( { client_no_context_takeover: true }, response() )
}})
it("uses no context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(2).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(2).returning(inflate)
expect(inflate, "close").exactly(2)
processIncomingMessage()
processIncomingMessage()
@@ -258,7 +258,7 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("with requestMaxWindowBits", function() { with(this) {
define("options", {requestMaxWindowBits: 11})
define("options", { requestMaxWindowBits: 11 })
describe("with an empty offer", function() { with(this) {
it("does not include client_max_window_bits in the response", function() { with(this) {
@@ -267,52 +267,52 @@ test.describe("ServerSession", function() { with(this) {
it("uses context takeover and 15 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 15}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 15 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
}})
describe("when the offer includes client_max_window_bits", function() { with(this) {
define("offer", {client_max_window_bits: true})
define("offer", { client_max_window_bits: true })
it("includes client_max_window_bits in the response", function() { with(this) {
assertEqual( {client_max_window_bits: 11}, response() )
assertEqual( { client_max_window_bits: 11 }, response() )
}})
it("uses context takeover and 11 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 11}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 11 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
}})
describe("when the offer has higher client_max_window_bits", function() { with(this) {
define("offer", {client_max_window_bits: 12})
define("offer", { client_max_window_bits: 12 })
it("includes client_max_window_bits in the response", function() { with(this) {
assertEqual( {client_max_window_bits: 11}, response() )
assertEqual( { client_max_window_bits: 11 }, response() )
}})
it("uses context takeover and 11 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 11}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 11 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
}})
describe("when the offer has lower client_max_window_bits", function() { with(this) {
define("offer", {client_max_window_bits: 10})
define("offer", { client_max_window_bits: 10 })
it("includes client_max_window_bits in the response", function() { with(this) {
assertEqual( {client_max_window_bits: 10}, response() )
assertEqual( { client_max_window_bits: 10 }, response() )
}})
it("uses context takeover and 10 window bits for inflating incoming messages", function() { with(this) {
response()
expect(zlib, "createInflateRaw").given({windowBits: 10}).exactly(1).returning(inflate)
expect(zlib, "createInflateRaw").given({ windowBits: 10 }).exactly(1).returning(inflate)
processIncomingMessage()
processIncomingMessage()
}})
@@ -320,31 +320,31 @@ test.describe("ServerSession", function() { with(this) {
}})
describe("with level", function() { with(this) {
define("options", {level: _zlib.Z_BEST_SPEED})
define("options", { level: _zlib.Z_BEST_SPEED })
it("sets the level of the deflate stream", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: _zlib.Z_BEST_SPEED, memLevel: memLevel, strategy: strategy}).returns(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: _zlib.Z_BEST_SPEED, memLevel: memLevel, strategy: strategy }).returns(deflate)
processOutgoingMessage()
}})
}})
describe("with memLevel", function() { with(this) {
define("options", {memLevel: 5})
define("options", { memLevel: 5 })
it("sets the memLevel of the deflate stream", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: 5, strategy: strategy}).returns(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: 5, strategy: strategy }).returns(deflate)
processOutgoingMessage()
}})
}})
describe("with strategy", function() { with(this) {
define("options", {strategy: _zlib.Z_FILTERED})
define("options", { strategy: _zlib.Z_FILTERED })
it("sets the strategy of the deflate stream", function() { with(this) {
response()
expect(zlib, "createDeflateRaw").given({windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: memLevel, strategy: _zlib.Z_FILTERED}).returns(deflate)
expect(zlib, "createDeflateRaw").given({ windowBits: 15, level: _zlib.Z_DEFAULT_LEVEL, memLevel: memLevel, strategy: _zlib.Z_FILTERED }).returns(deflate)
processOutgoingMessage()
}})
}})