Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 68ceed8cf8 | |||
| 947ad6692b | |||
| 8ee77a23c0 | |||
| 5eddd922aa | |||
| 75b434c6a0 | |||
| ae94112fe9 | |||
| 5a74a0471b | |||
| 3500cddfa7 | |||
| 8d58a3363d | |||
| f104377a0e | |||
| 8ddfd06f5b | |||
| 33df77ef24 |
@@ -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
|
||||
@@ -1 +1,2 @@
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "4"
|
||||
- "5"
|
||||
- "6"
|
||||
- "7"
|
||||
- "8"
|
||||
|
||||
before_install:
|
||||
- '[ "${TRAVIS_NODE_VERSION}" = "0.8" ] && npm install -g npm@~1.4.0 || true'
|
||||
+15
-9
@@ -1,33 +1,39 @@
|
||||
### 0.1.7 / 2019-06-10
|
||||
|
||||
- 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
|
||||
|
||||
* Use `9` instead of `8` as the `windowBits` parameter to zlib, to deal with
|
||||
- Use `9` instead of `8` as the `windowBits` parameter to zlib, to deal with
|
||||
restrictions introduced in zlib v1.2.9
|
||||
|
||||
### 0.1.5 / 2016-02-24
|
||||
|
||||
* Catch errors thrown by `close()` on zlib streams
|
||||
- Catch errors thrown by `close()` on zlib streams
|
||||
|
||||
### 0.1.4 / 2015-11-06
|
||||
|
||||
* The server does not send `server_max_window_bits` if the client does not ask
|
||||
- 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
|
||||
* Make sure to emit minimal output on all Node versions
|
||||
- Fix a race condition causing some fragments of deflate output to be dropped
|
||||
- Make sure to emit minimal output on all Node versions
|
||||
|
||||
### 0.1.2 / 2014-12-18
|
||||
|
||||
* Don't allow configure() to be called with unrecognized options
|
||||
- Don't allow configure() to be called with unrecognized options
|
||||
|
||||
### 0.1.1 / 2014-12-15
|
||||
|
||||
* Fix race condition when using context takeover, where adjacent messages have
|
||||
- Fix race condition when using context takeover, where adjacent messages have
|
||||
data listeners bound at the same time and end up duplicating output
|
||||
* Use `DeflateRaw.flush()` correctly on v0.10 so that optimal compression is
|
||||
- Use `DeflateRaw.flush()` correctly on v0.10 so that optimal compression is
|
||||
achieved
|
||||
|
||||
### 0.1.0 / 2014-12-13
|
||||
|
||||
* Initial release
|
||||
- Initial release
|
||||
|
||||
+9
-17
@@ -1,20 +1,12 @@
|
||||
# The MIT License
|
||||
Copyright 2014-2019 James Coglan
|
||||
|
||||
Copyright (c) 2014-2017 James Coglan
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at
|
||||
|
||||
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:
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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.
|
||||
Unless required by applicable law or agreed to in writing, software distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations under the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# permessage-deflate [](http://travis-ci.org/faye/permessage-deflate-node)
|
||||
# permessage-deflate
|
||||
|
||||
Implements the
|
||||
[permessage-deflate](https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression)
|
||||
@@ -45,25 +45,25 @@ the peer, and those that are negotiated as part of the protocol. The settings
|
||||
only affecting the compressor are described fully in the [zlib
|
||||
documentation](http://nodejs.org/api/zlib.html#zlib_options):
|
||||
|
||||
* `level`: sets the compression level, can be an integer from `0` to `9`, or one
|
||||
- `level`: sets the compression level, can be an integer from `0` to `9`, or one
|
||||
of the constants `zlib.Z_NO_COMPRESSION`, `zlib.Z_BEST_SPEED`,
|
||||
`zlib.Z_BEST_COMPRESSION`, or `zlib.Z_DEFAULT_COMPRESSION`
|
||||
* `memLevel`: sets how much memory the compressor allocates, can be an integer
|
||||
- `memLevel`: sets how much memory the compressor allocates, can be an integer
|
||||
from `1` to `9`, or one of the constants `zlib.Z_MIN_MEMLEVEL`,
|
||||
`zlib.Z_MAX_MEMLEVEL`, or `zlib.Z_DEFAULT_MEMLEVEL`
|
||||
* `strategy`: can be one of the constants `zlib.Z_FILTERED`,
|
||||
- `strategy`: can be one of the constants `zlib.Z_FILTERED`,
|
||||
`zlib.Z_HUFFMAN_ONLY`, `zlib.Z_RLE`, `zlib.Z_FIXED`, or
|
||||
`zlib.Z_DEFAULT_STRATEGY`
|
||||
|
||||
The other options relate to settings that are negotiated via the protocol and
|
||||
can be used to set the local session's behaviour and control that of the peer:
|
||||
|
||||
* `noContextTakeover`: if `true`, stops the session reusing a deflate context
|
||||
- `noContextTakeover`: if `true`, stops the session reusing a deflate context
|
||||
between messages
|
||||
* `requestNoContextTakeover`: if `true`, makes the session tell the other peer
|
||||
- `requestNoContextTakeover`: if `true`, makes the session tell the other peer
|
||||
not to reuse a deflate context between messages
|
||||
* `maxWindowBits`: an integer from `8` to `15` inclusive that sets the maximum
|
||||
- `maxWindowBits`: an integer from `8` to `15` inclusive that sets the maximum
|
||||
size of the session's sliding window; a lower window size will be used if
|
||||
requested by the peer
|
||||
* `requestMaxWindowBits`: an integer from `8` to `15` inclusive to ask the other
|
||||
- `requestMaxWindowBits`: an integer from `8` to `15` inclusive to ask the other
|
||||
peer to use to set its maximum sliding window size, if supported
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+2
-11
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
|
||||
var common = {
|
||||
VALID_PARAMS: [
|
||||
'server_no_context_takeover',
|
||||
@@ -12,17 +14,6 @@ var common = {
|
||||
MAX_WINDOW_BITS: 15,
|
||||
VALID_WINDOW_BITS: [8, 9, 10, 11, 12, 13, 14, 15],
|
||||
|
||||
concat: function(buffers, length) {
|
||||
var buffer = new Buffer(length),
|
||||
offset = 0;
|
||||
|
||||
for (var i = 0, n = buffers.length; i < n; i++) {
|
||||
buffers[i].copy(buffer, offset);
|
||||
offset += buffers[i].length;
|
||||
}
|
||||
return buffer;
|
||||
},
|
||||
|
||||
fetch: function(options, key, _default) {
|
||||
if (options.hasOwnProperty(key))
|
||||
return options[key];
|
||||
|
||||
@@ -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() {
|
||||
|
||||
+7
-6
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var zlib = require('zlib'),
|
||||
var Buffer = require('safe-buffer').Buffer,
|
||||
zlib = require('zlib'),
|
||||
common = require('./common');
|
||||
|
||||
var Session = function(options) {
|
||||
@@ -57,10 +58,10 @@ Session.prototype.processIncomingMessage = function(message, callback) {
|
||||
inflate.on('error', onError);
|
||||
|
||||
inflate.write(message.data);
|
||||
inflate.write(new Buffer([0x00, 0x00, 0xff, 0xff]));
|
||||
inflate.write(Buffer.from([0x00, 0x00, 0xff, 0xff]));
|
||||
|
||||
inflate.flush(function() {
|
||||
message.data = common.concat(chunks, length);
|
||||
message.data = Buffer.concat(chunks, length);
|
||||
return_(null, message);
|
||||
});
|
||||
};
|
||||
@@ -103,7 +104,7 @@ Session.prototype.processOutgoingMessage = function(message, callback) {
|
||||
deflate.write(message.data);
|
||||
|
||||
var onFlush = function() {
|
||||
var data = common.concat(chunks, length);
|
||||
var data = Buffer.concat(chunks, length);
|
||||
message.data = data.slice(0, data.length - 4);
|
||||
message.rsv1 = true;
|
||||
return_(null, message);
|
||||
@@ -127,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;
|
||||
@@ -158,7 +159,7 @@ Session.prototype._getDeflate = function() {
|
||||
flush.call(this, callback);
|
||||
} else {
|
||||
this._flushFlag = zlib.Z_SYNC_FLUSH;
|
||||
this.write(new Buffer(0), '', callback);
|
||||
this.write(Buffer.alloc(0), '', callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+33
-21
@@ -1,22 +1,34 @@
|
||||
{ "name" : "permessage-deflate"
|
||||
, "description" : "Per-message DEFLATE compression extension for WebSocket connections"
|
||||
, "homepage" : "https://github.com/faye/permessage-deflate-node"
|
||||
, "author" : "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)"
|
||||
, "keywords" : ["websocket", "compression", "deflate"]
|
||||
, "license" : "MIT"
|
||||
|
||||
, "version" : "0.1.6"
|
||||
, "engines" : { "node": ">=0.8.0" }
|
||||
, "files" : ["lib"]
|
||||
, "main" : "./lib/permessage_deflate"
|
||||
|
||||
, "devDependencies" : { "jstest": "*" }
|
||||
|
||||
, "scripts" : { "test": "jstest spec/runner.js" }
|
||||
|
||||
, "repository" : { "type" : "git"
|
||||
, "url" : "git://github.com/faye/permessage-deflate-node.git"
|
||||
}
|
||||
|
||||
, "bugs" : "https://github.com/faye/permessage-deflate-node/issues"
|
||||
{
|
||||
"name": "permessage-deflate",
|
||||
"description": "Per-message DEFLATE compression extension for WebSocket connections",
|
||||
"homepage": "https://github.com/faye/permessage-deflate-node",
|
||||
"author": "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)",
|
||||
"keywords": [
|
||||
"websocket",
|
||||
"compression",
|
||||
"deflate"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"version": "0.1.7",
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"main": "./lib/permessage_deflate",
|
||||
"dependencies": {
|
||||
"safe-buffer": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jstest": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jstest spec/runner.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/faye/permessage-deflate-node.git"
|
||||
},
|
||||
"bugs": "https://github.com/faye/permessage-deflate-node/issues"
|
||||
}
|
||||
|
||||
+41
-41
@@ -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
@@ -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()
|
||||
}})
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user