first commit
This commit is contained in:
136
app_vue/node_modules/hpack.js/test/compressor-test.js
generated
vendored
Normal file
136
app_vue/node_modules/hpack.js/test/compressor-test.js
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
var assert = require('assert');
|
||||
var hpack = require('../');
|
||||
var fixtures = require('./fixtures');
|
||||
|
||||
describe('hpack/compressor', function() {
|
||||
var comp;
|
||||
|
||||
beforeEach(function() {
|
||||
comp = hpack.compressor.create({
|
||||
table: {
|
||||
maxSize: 1024
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function expect(arr, enc) {
|
||||
function isNumber(num) {
|
||||
return typeof num === 'number';
|
||||
}
|
||||
|
||||
var out = comp.read().toString('hex');
|
||||
if (Array.isArray(arr) && !arr.every(isNumber)) {
|
||||
arr = arr.map(function(item) {
|
||||
return new Buffer(item, enc);
|
||||
});
|
||||
arr = Buffer.concat(arr);
|
||||
} else {
|
||||
arr = new Buffer(arr, enc);
|
||||
}
|
||||
var actual = arr.toString('hex');
|
||||
assert.equal(out, actual);
|
||||
}
|
||||
|
||||
describe('indexed field', function() {
|
||||
it('should lookup entry from static table', function() {
|
||||
comp.write([{ name: ':method', value: 'GET' }]);
|
||||
expect([ 0b10000000 | 2 ]);
|
||||
});
|
||||
|
||||
it('should fetch entry from the end of the static table', function() {
|
||||
comp.write([{ name: 'www-authenticate', value: '' }]);
|
||||
expect([ 0b10000000 | 61 ]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('literal field', function() {
|
||||
it('should lookup name in the table (incremental)', function() {
|
||||
comp.write([{ name: 'host', value: 'localhost' }]);
|
||||
expect('6686a0e41d139d09', 'hex');
|
||||
|
||||
comp.write([{ name: 'host', value: 'localhost' }]);
|
||||
expect([ 0b10000000 | 62 ]);
|
||||
});
|
||||
|
||||
it('should lookup name in the table (not-incremental)', function() {
|
||||
comp.write([{ name: 'host', value: 'localhost', incremental: false }]);
|
||||
expect('0f1786a0e41d139d09', 'hex');
|
||||
|
||||
// Should not use the table
|
||||
comp.write([{ name: 'host', value: 'localhost' }]);
|
||||
expect('6686a0e41d139d09', 'hex');
|
||||
});
|
||||
|
||||
it('should evict header field from the table', function() {
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
comp.write([{ name: 'host', value: 'localhost' + i }]);
|
||||
comp.read();
|
||||
}
|
||||
|
||||
assert(comp._table.size < comp._table.maxSize);
|
||||
assert.equal(comp._table.dynamic.length, 21);
|
||||
});
|
||||
});
|
||||
|
||||
describe('update size', function() {
|
||||
it('should evict header field from the table', function() {
|
||||
comp.write([{ name: 'host', value: 'localhost' }]);
|
||||
expect('6686a0e41d139d09', 'hex');
|
||||
|
||||
comp.reset();
|
||||
|
||||
// update=0, update=maxSize
|
||||
expect('203fe107', 'hex');
|
||||
|
||||
comp.write([{ name: 'host', value: 'localhost' }]);
|
||||
expect('6686a0e41d139d09', 'hex');
|
||||
});
|
||||
|
||||
it('should send dynamic update if size >= protocolMaxSize', function() {
|
||||
comp.updateTableSize(Infinity);
|
||||
|
||||
// update=maxSize
|
||||
expect('3fe107', 'hex');
|
||||
});
|
||||
});
|
||||
|
||||
describe('spec examples', function() {
|
||||
beforeEach(function() {
|
||||
comp = hpack.compressor.create({
|
||||
table: {
|
||||
maxSize: 256
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var tests = fixtures.specExamples;
|
||||
|
||||
tests.forEach(function(test, i) {
|
||||
var prev = tests[i - 1];
|
||||
it('should give expected output on ' + test.id, function() {
|
||||
var startFrom = test.continuation ? prev.comp : comp;
|
||||
if (!startFrom)
|
||||
throw new Error('Previous test failed');
|
||||
comp = startFrom;
|
||||
|
||||
comp.write(test.output.map(function(pair) {
|
||||
return { name: pair[0], value: pair[1], huffman: test.huffman };
|
||||
}));
|
||||
expect(test.input.replace(/ /g, ''), 'hex');
|
||||
|
||||
// Verify table contents
|
||||
assert.deepEqual(comp._table.dynamic.map(function(header) {
|
||||
return [ header.name, header.value, header.totalSize ];
|
||||
}).reverse(), test.table);
|
||||
|
||||
// Verify table size
|
||||
var expectedSize = test.table.reduce(function(acc, item) {
|
||||
return acc + item[2];
|
||||
}, 0);
|
||||
assert.equal(comp._table.size, expectedSize);
|
||||
|
||||
test.comp = comp;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
181
app_vue/node_modules/hpack.js/test/decoder-test.js
generated
vendored
Normal file
181
app_vue/node_modules/hpack.js/test/decoder-test.js
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
var assert = require('assert');
|
||||
var hpack = require('../');
|
||||
|
||||
describe('hpack/decoder', function() {
|
||||
var decoder;
|
||||
|
||||
beforeEach(function() {
|
||||
decoder = hpack.decoder.create();
|
||||
});
|
||||
|
||||
describe('bit', function() {
|
||||
it('should decode number bit-by-bit', function() {
|
||||
decoder.push([ 0b11101010, 0b10101111 ]);
|
||||
var out = '';
|
||||
for (var i = 0; i < 16; i++)
|
||||
out += decoder.decodeBit();
|
||||
assert.equal(out, '11101010' + '10101111');
|
||||
});
|
||||
});
|
||||
|
||||
describe('integer', function() {
|
||||
it('should decode 10 in prefix-5 (C.1.1)', function() {
|
||||
decoder.push([ 0b11101010 ]);
|
||||
decoder.skipBits(3);
|
||||
assert.equal(decoder.decodeInt(), 10);
|
||||
});
|
||||
|
||||
it('should decode 1337 in prefix-5 (C.1.2)', function() {
|
||||
decoder.push([ 0b11111111, 0b10011010, 0b00001010 ]);
|
||||
decoder.skipBits(3);
|
||||
assert.equal(decoder.decodeInt(), 1337);
|
||||
});
|
||||
|
||||
it('should decode 42 at octect boundary (C.1.3)', function() {
|
||||
decoder.push([ 0b00101010 ]);
|
||||
assert.equal(decoder.decodeInt(8), 42);
|
||||
});
|
||||
|
||||
it('should throw on empty input', function() {
|
||||
assert.throws(function() {
|
||||
decoder.decodeInt();
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw on incomplete int', function() {
|
||||
decoder.push([ 0b11111111, 0b10011010 ]);
|
||||
decoder.skipBits(3);
|
||||
assert.throws(function() {
|
||||
decoder.decodeInt();
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw on overflowing int', function() {
|
||||
decoder.push([
|
||||
0b11111111,
|
||||
0b10011010,
|
||||
0b10011010,
|
||||
0b10011010,
|
||||
0b10011010,
|
||||
0b10011010
|
||||
]);
|
||||
decoder.skipBits(3);
|
||||
assert.throws(function() {
|
||||
decoder.decodeInt();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('string', function() {
|
||||
it('should decode literal from (C.2.1)', function() {
|
||||
decoder.push([ 0x0a ]);
|
||||
decoder.push(new Buffer('custom-key'));
|
||||
|
||||
assert.equal(decoder.decodeStr().toString(), 'custom-key');
|
||||
});
|
||||
|
||||
it('should decode literal from (C.4.1)', function() {
|
||||
decoder.push(new Buffer(
|
||||
'8c' +
|
||||
'f1e3 c2e5 f23a 6ba0 ab90 f4ff'.replace(/ /g, ''),
|
||||
'hex'));
|
||||
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(),
|
||||
'www.example.com');
|
||||
});
|
||||
|
||||
it('should decode literal from (C.4.2)', function() {
|
||||
decoder.push(new Buffer(
|
||||
'86' +
|
||||
'a8eb 1064 9cbf'.replace(/ /g, ''),
|
||||
'hex'));
|
||||
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(), 'no-cache');
|
||||
});
|
||||
|
||||
it('should decode literal from (C.4.3) #1', function() {
|
||||
decoder.push(new Buffer(
|
||||
'88' +
|
||||
'25a8 49e9 5ba9 7d7f'.replace(/ /g, ''),
|
||||
'hex'));
|
||||
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(), 'custom-key');
|
||||
});
|
||||
|
||||
it('should decode literal from (C.4.3) #2', function() {
|
||||
decoder.push(new Buffer(
|
||||
'89' +
|
||||
'25a8 49e9 5bb8 e8b4 bf'.replace(/ /g, ''),
|
||||
'hex'));
|
||||
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(), 'custom-value');
|
||||
});
|
||||
|
||||
it('should decode literal from (C.6.1) #1', function() {
|
||||
decoder.push(new Buffer(
|
||||
('96' +
|
||||
'd07a be94 1054 d444 a820 0595 040b 8166' +
|
||||
'e082 a62d 1bff').replace(/ /g, ''),
|
||||
'hex'));
|
||||
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(),
|
||||
'Mon, 21 Oct 2013 20:13:21 GMT');
|
||||
});
|
||||
|
||||
it('should decode literal from (C.6.1) #2', function() {
|
||||
decoder.push(new Buffer(
|
||||
('91' +
|
||||
'9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43' +
|
||||
'd3').replace(/ /g, ''),
|
||||
'hex'));
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(),
|
||||
'https://www.example.com');
|
||||
});
|
||||
|
||||
it('should decode many 5 bit chars', function() {
|
||||
// e = 00101, 0x294A5294A5 = 00101 x 8
|
||||
decoder.push(new Buffer('85294A5294A5', 'hex'));
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(), 'eeeeeeee');
|
||||
});
|
||||
|
||||
it('should decode many 5 bit chars with 3-bit EOS', function() {
|
||||
// e = 00101, EOS=111,
|
||||
// 0x294A5294A52F = 00101 x 9 + 111
|
||||
decoder.push(new Buffer('86294A5294A52F', 'hex'));
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(), 'eeeeeeeee');
|
||||
});
|
||||
|
||||
it('should decode many 5 bit chars with 2-bit EOS', function() {
|
||||
// e = 00101, EOS=11,
|
||||
// 0x294A5297 = 00101 x 6 + 11
|
||||
decoder.push(new Buffer('84294A5297', 'hex'));
|
||||
assert.equal(new Buffer(decoder.decodeStr()).toString(), 'eeeeee');
|
||||
});
|
||||
|
||||
it('should decode many multi-octet chars', function() {
|
||||
decoder.push(new Buffer(
|
||||
'97ffffb1ffff63fffec7fffd8ffffb1ffff63fffec7fffd8',
|
||||
'hex'));
|
||||
assert.deepEqual(decoder.decodeStr(), [
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on 8 bit EOS', function() {
|
||||
// e = 00101, 0x294A5294A5 = 00101 x 8
|
||||
decoder.push(new Buffer('86294A5294A5ff', 'hex'));
|
||||
assert.throws(function() {
|
||||
decoder.decodeStr();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail on invalid 2-bit EOS', function() {
|
||||
// e = 00101, EOS=10,
|
||||
// 0x294A5297 = 00101 x 6 + 11
|
||||
decoder.push(new Buffer('84294A5296', 'hex'));
|
||||
assert.throws(function() {
|
||||
decoder.decodeStr();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
184
app_vue/node_modules/hpack.js/test/decompressor-test.js
generated
vendored
Normal file
184
app_vue/node_modules/hpack.js/test/decompressor-test.js
generated
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
var assert = require('assert');
|
||||
var hpack = require('../');
|
||||
var fixtures = require('./fixtures');
|
||||
|
||||
describe('hpack/decompressor', function() {
|
||||
var decomp;
|
||||
|
||||
beforeEach(function() {
|
||||
decomp = hpack.decompressor.create({
|
||||
table: {
|
||||
maxSize: 1024
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('indexed field', function() {
|
||||
it('should fail on 0-index', function(cb) {
|
||||
decomp.write(new Buffer([ 0b10000000 ]));
|
||||
decomp.execute(function(err) {
|
||||
assert(/zero index/i.test(err.message), err.message);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch entry from static table', function() {
|
||||
decomp.write(new Buffer([ 0b10000000 | 2 ]));
|
||||
decomp.execute();
|
||||
var field = decomp.read();
|
||||
assert.equal(field.name, ':method');
|
||||
assert.equal(field.value, 'GET');
|
||||
});
|
||||
|
||||
it('should fetch entry from the end of the static table', function() {
|
||||
decomp.write(new Buffer([ 0b10000000 | 61 ]));
|
||||
decomp.execute();
|
||||
var field = decomp.read();
|
||||
assert.equal(field.name, 'www-authenticate');
|
||||
assert.equal(field.value, '');
|
||||
});
|
||||
|
||||
it('should fail on OOB-index', function(cb) {
|
||||
decomp.write(new Buffer([ 0b11000000 ]));
|
||||
decomp.execute(function(err) {
|
||||
assert(/field oob/i.test(err.message), err.message);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('literal field', function() {
|
||||
it('should lookup name in the table (incremental)', function() {
|
||||
var value = new Buffer('localhost');
|
||||
var header = new Buffer([
|
||||
0b01000000 | 38, // 38th element from static table
|
||||
value.length
|
||||
]);
|
||||
decomp.write(Buffer.concat([ header, value ]));
|
||||
decomp.execute();
|
||||
|
||||
var field = decomp.read();
|
||||
assert.equal(field.name, 'host');
|
||||
assert.equal(field.value, 'localhost');
|
||||
|
||||
decomp.write(new Buffer([ 0b10000000 | 62 ]));
|
||||
decomp.execute();
|
||||
var field = decomp.read();
|
||||
assert.equal(field.name, 'host');
|
||||
assert.equal(field.value, 'localhost');
|
||||
});
|
||||
|
||||
it('should lookup name in the table (not-incremental)', function(cb) {
|
||||
var value = new Buffer('localhost');
|
||||
var header = new Buffer([
|
||||
0b00001111,
|
||||
0b00000000 | 23,
|
||||
value.length
|
||||
]);
|
||||
decomp.write(Buffer.concat([ header, value ]));
|
||||
decomp.execute();
|
||||
|
||||
var field = decomp.read();
|
||||
assert.equal(field.name, 'host');
|
||||
assert.equal(field.value, 'localhost');
|
||||
|
||||
decomp.write(new Buffer([ 0b10000000 | 62 ]));
|
||||
decomp.execute(function(err) {
|
||||
assert(/field oob/i.test(err.message), err.message);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
it('should evict header field from the table', function() {
|
||||
var value = new Buffer('localhost');
|
||||
var header = new Buffer([
|
||||
0b01000000 | 38, // 38th element from static table
|
||||
value.length
|
||||
]);
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
decomp.write(Buffer.concat([ header, value ]));
|
||||
decomp.execute();
|
||||
var field = decomp.read();
|
||||
assert.equal(field.name, 'host');
|
||||
assert.equal(field.value, 'localhost');
|
||||
}
|
||||
|
||||
assert(decomp._table.size < decomp._table.maxSize);
|
||||
assert.equal(decomp._table.dynamic.length, 22);
|
||||
});
|
||||
});
|
||||
|
||||
describe('update size', function() {
|
||||
it('should evict header field from the table', function() {
|
||||
var value = new Buffer('localhost');
|
||||
var header = new Buffer([
|
||||
0b01000000 | 38, // 38th element from static table
|
||||
value.length
|
||||
]);
|
||||
|
||||
decomp.write(Buffer.concat([ header, value ]));
|
||||
decomp.execute();
|
||||
var field = decomp.read();
|
||||
assert.equal(field.name, 'host');
|
||||
assert.equal(field.value, 'localhost');
|
||||
assert.equal(decomp._table.dynamic.length, 1);
|
||||
|
||||
decomp.write(new Buffer([
|
||||
0b00100000
|
||||
]));
|
||||
decomp.execute();
|
||||
|
||||
assert.equal(decomp._table.dynamic.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('spec examples', function() {
|
||||
var decomp;
|
||||
beforeEach(function() {
|
||||
decomp = hpack.decompressor.create({
|
||||
table: {
|
||||
maxSize: 256
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var tests = fixtures.specExamples;
|
||||
|
||||
tests.forEach(function(test, i) {
|
||||
var prev = tests[i - 1];
|
||||
it('should give expected output on ' + test.id, function() {
|
||||
var startFrom = test.continuation ? prev.decomp : decomp;
|
||||
if (!startFrom)
|
||||
throw new Error('Previous test failed');
|
||||
decomp = startFrom;
|
||||
|
||||
decomp.write(new Buffer(test.input.replace(/ /g, ''), 'hex'));
|
||||
decomp.execute();
|
||||
|
||||
var output = [];
|
||||
for (;;) {
|
||||
var chunk = decomp.read();
|
||||
if (!chunk)
|
||||
break;
|
||||
|
||||
output.push([ chunk.name, chunk.value ]);
|
||||
}
|
||||
|
||||
assert.deepEqual(output, test.output);
|
||||
|
||||
// Verify table contents
|
||||
assert.deepEqual(decomp._table.dynamic.map(function(header) {
|
||||
return [ header.name, header.value, header.totalSize ];
|
||||
}).reverse(), test.table);
|
||||
|
||||
// Verify table size
|
||||
var expectedSize = test.table.reduce(function(acc, item) {
|
||||
return acc + item[2];
|
||||
}, 0);
|
||||
assert.equal(decomp._table.size, expectedSize);
|
||||
|
||||
test.decomp = decomp;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
166
app_vue/node_modules/hpack.js/test/encoder-test.js
generated
vendored
Normal file
166
app_vue/node_modules/hpack.js/test/encoder-test.js
generated
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
var assert = require('assert');
|
||||
var hpack = require('../');
|
||||
|
||||
describe('hpack/encoder', function() {
|
||||
var encoder;
|
||||
|
||||
beforeEach(function() {
|
||||
encoder = hpack.encoder.create();
|
||||
});
|
||||
|
||||
function expect(arr, enc) {
|
||||
function isNumber(num) {
|
||||
return typeof num === 'number';
|
||||
}
|
||||
|
||||
var out = Buffer.concat(encoder.render()).toString('hex');
|
||||
if (Array.isArray(arr) && !arr.every(isNumber)) {
|
||||
arr = arr.map(function(item) {
|
||||
return new Buffer(item, enc);
|
||||
});
|
||||
arr = Buffer.concat(arr);
|
||||
} else {
|
||||
arr = new Buffer(arr, enc);
|
||||
}
|
||||
var actual = arr.toString('hex');
|
||||
assert.equal(out, actual);
|
||||
}
|
||||
|
||||
describe('bit', function() {
|
||||
it('should encode number bit-by-bit', function() {
|
||||
[ 1, 1, 1, 0, 1, 0, 1, 0,
|
||||
1, 0, 1, 0, 1, 1, 1, 1 ].forEach(function(bit) {
|
||||
encoder.encodeBit(bit);
|
||||
});
|
||||
expect([
|
||||
0b11101010,
|
||||
0b10101111
|
||||
]);
|
||||
});
|
||||
|
||||
it('should encode number using multiple bits', function() {
|
||||
for (var i = 0; i < 8; i++)
|
||||
encoder.encodeBits(0b1011010, 7);
|
||||
expect([
|
||||
0b10110101,
|
||||
0b01101010,
|
||||
0b11010101,
|
||||
0b10101011,
|
||||
0b01010110,
|
||||
0b10101101,
|
||||
0b01011010
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('integer', function() {
|
||||
it('should encode 10 in prefix-5 (C.1.1)', function() {
|
||||
encoder.skipBits(3);
|
||||
encoder.encodeInt(10);
|
||||
expect([ 0x0a ]);
|
||||
});
|
||||
|
||||
it('should decode 1337 in prefix-5 (C.1.2)', function() {
|
||||
encoder.skipBits(3);
|
||||
encoder.encodeInt(1337);
|
||||
expect([
|
||||
0b00011111,
|
||||
0b10011010,
|
||||
0b00001010
|
||||
]);
|
||||
});
|
||||
|
||||
it('should decode 42 at octect boundary (C.1.3)', function() {
|
||||
encoder.encodeInt(42);
|
||||
expect([ 0b00101010 ]);
|
||||
});
|
||||
|
||||
it('should regression 6-bit test', function() {
|
||||
encoder.skipBits(2);
|
||||
encoder.encodeInt(63);
|
||||
expect([ 0b00111111, 0b00000000 ]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('string', function() {
|
||||
it('should encode literal from (C.2.1)', function() {
|
||||
encoder.encodeStr(new Buffer('custom-key'), false);
|
||||
expect([ [ 0x0a ], 'custom-key' ]);
|
||||
});
|
||||
|
||||
it('should encode literal from (C.4.1)', function() {
|
||||
encoder.encodeStr(new Buffer('www.example.com'), true);
|
||||
expect('8c' +
|
||||
'f1e3 c2e5 f23a 6ba0 ab90 f4ff'.replace(/ /g, ''),
|
||||
'hex');
|
||||
});
|
||||
|
||||
it('should decode literal from (C.4.2)', function() {
|
||||
encoder.encodeStr(new Buffer('no-cache'), true);
|
||||
expect(
|
||||
'86' +
|
||||
'a8eb 1064 9cbf'.replace(/ /g, ''),
|
||||
'hex');
|
||||
});
|
||||
|
||||
it('should encode literal from (C.4.3) #1', function() {
|
||||
encoder.encodeStr(new Buffer('custom-key'), true);
|
||||
expect(
|
||||
'88' +
|
||||
'25a8 49e9 5ba9 7d7f'.replace(/ /g, ''),
|
||||
'hex');
|
||||
});
|
||||
|
||||
it('should encode literal from (C.4.3) #2', function() {
|
||||
encoder.encodeStr(new Buffer('custom-value'), true);
|
||||
expect(
|
||||
'89' +
|
||||
'25a8 49e9 5bb8 e8b4 bf'.replace(/ /g, ''),
|
||||
'hex');
|
||||
});
|
||||
|
||||
it('should encode literal from (C.6.1) #1', function() {
|
||||
encoder.encodeStr(new Buffer('Mon, 21 Oct 2013 20:13:21 GMT'), true);
|
||||
expect(
|
||||
('96' +
|
||||
'd07a be94 1054 d444 a820 0595 040b 8166' +
|
||||
'e082 a62d 1bff').replace(/ /g, ''),
|
||||
'hex');
|
||||
});
|
||||
|
||||
it('should encode literal from (C.6.1) #2', function() {
|
||||
encoder.encodeStr(new Buffer('https://www.example.com'), true);
|
||||
expect(
|
||||
('91' +
|
||||
'9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43' +
|
||||
'd3').replace(/ /g, ''),
|
||||
'hex');
|
||||
});
|
||||
|
||||
it('should encode many 5 bit chars', function() {
|
||||
encoder.encodeStr(new Buffer('eeeeeeee'), true);
|
||||
// e = 00101, 0x294A5294A5 = 00101 x 8
|
||||
expect('85294A5294A5', 'hex');
|
||||
});
|
||||
|
||||
it('should encode many 5 bit chars with 3-bit EOS', function() {
|
||||
// e = 00101, EOS=111,
|
||||
// 0x294A5294A52F = 00101 x 9 + 111
|
||||
encoder.encodeStr(new Buffer('eeeeeeeee'), true);
|
||||
expect('86294A5294A52F', 'hex');
|
||||
});
|
||||
|
||||
it('should decode many 5 bit chars with 2-bit EOS', function() {
|
||||
// e = 00101, EOS=11,
|
||||
// 0x294A5297 = 00101 x 6 + 11
|
||||
encoder.encodeStr(new Buffer('eeeeee'), true);
|
||||
expect('84294A5297', 'hex');
|
||||
});
|
||||
|
||||
it('should decode many multi-octet chars', function() {
|
||||
encoder.encodeStr([ 1, 1, 1, 1, 1, 1, 1, 1 ], true);
|
||||
expect('97ffffb1ffff63fffec7fffd8ffffb1ffff63fffec7fffd8',
|
||||
'hex');
|
||||
});
|
||||
});
|
||||
});
|
232
app_vue/node_modules/hpack.js/test/fixtures.js
generated
vendored
Normal file
232
app_vue/node_modules/hpack.js/test/fixtures.js
generated
vendored
Normal file
@ -0,0 +1,232 @@
|
||||
exports.specExamples = [
|
||||
{
|
||||
id: 'C.3.1',
|
||||
huffman: false,
|
||||
input: '8286 8441 0f77 7777 2e65 7861 6d70 6c65' +
|
||||
'2e63 6f6d',
|
||||
output: [
|
||||
[ ':method', 'GET' ],
|
||||
[ ':scheme', 'http' ],
|
||||
[ ':path', '/' ],
|
||||
[ ':authority', 'www.example.com' ]
|
||||
],
|
||||
table: [
|
||||
[ ':authority', 'www.example.com', 57 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.3.2',
|
||||
continuation: true,
|
||||
huffman: false,
|
||||
input: '8286 84be 5808 6e6f 2d63 6163 6865',
|
||||
output: [
|
||||
[ ':method', 'GET' ],
|
||||
[ ':scheme', 'http' ],
|
||||
[ ':path', '/' ],
|
||||
[ ':authority', 'www.example.com' ],
|
||||
[ 'cache-control', 'no-cache' ]
|
||||
],
|
||||
table: [
|
||||
[ 'cache-control', 'no-cache', 53 ],
|
||||
[ ':authority', 'www.example.com', 57 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.3.3',
|
||||
continuation: true,
|
||||
huffman: false,
|
||||
input: '8287 85bf 400a 6375 7374 6f6d 2d6b 6579' +
|
||||
'0c63 7573 746f 6d2d 7661 6c75 65',
|
||||
output: [
|
||||
[ ':method', 'GET' ],
|
||||
[ ':scheme', 'https' ],
|
||||
[ ':path', '/index.html' ],
|
||||
[ ':authority', 'www.example.com' ],
|
||||
[ 'custom-key', 'custom-value' ]
|
||||
],
|
||||
table: [
|
||||
[ 'custom-key', 'custom-value', 54 ],
|
||||
[ 'cache-control', 'no-cache', 53 ],
|
||||
[ ':authority', 'www.example.com', 57 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
id: 'C.4.1',
|
||||
input: '8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4' +
|
||||
'ff',
|
||||
output: [
|
||||
[ ':method', 'GET' ],
|
||||
[ ':scheme', 'http' ],
|
||||
[ ':path', '/' ],
|
||||
[ ':authority', 'www.example.com' ]
|
||||
],
|
||||
table: [
|
||||
[ ':authority', 'www.example.com', 57 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.4.2',
|
||||
continuation: true,
|
||||
input: '8286 84be 5886 a8eb 1064 9cbf',
|
||||
output: [
|
||||
[ ':method', 'GET' ],
|
||||
[ ':scheme', 'http' ],
|
||||
[ ':path', '/' ],
|
||||
[ ':authority', 'www.example.com' ],
|
||||
[ 'cache-control', 'no-cache' ]
|
||||
],
|
||||
table: [
|
||||
[ 'cache-control', 'no-cache', 53 ],
|
||||
[ ':authority', 'www.example.com', 57 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.4.3',
|
||||
continuation: true,
|
||||
input: '8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925' +
|
||||
'a849 e95b b8e8 b4bf',
|
||||
output: [
|
||||
[ ':method', 'GET' ],
|
||||
[ ':scheme', 'https' ],
|
||||
[ ':path', '/index.html' ],
|
||||
[ ':authority', 'www.example.com' ],
|
||||
[ 'custom-key', 'custom-value' ]
|
||||
],
|
||||
table: [
|
||||
[ 'custom-key', 'custom-value', 54 ],
|
||||
[ 'cache-control', 'no-cache', 53 ],
|
||||
[ ':authority', 'www.example.com', 57 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
id: 'C.5.1',
|
||||
huffman: false,
|
||||
input: '4803 3330 3258 0770 7269 7661 7465 611d' +
|
||||
'4d6f 6e2c 2032 3120 4f63 7420 3230 3133' +
|
||||
'2032 303a 3133 3a32 3120 474d 546e 1768' +
|
||||
'7474 7073 3a2f 2f77 7777 2e65 7861 6d70' +
|
||||
'6c65 2e63 6f6d',
|
||||
output: [
|
||||
[ ':status', '302' ],
|
||||
[ 'cache-control', 'private' ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT' ],
|
||||
[ 'location', 'https://www.example.com' ]
|
||||
],
|
||||
table: [
|
||||
[ 'location', 'https://www.example.com', 63 ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT', 65 ],
|
||||
[ 'cache-control', 'private', 52 ],
|
||||
[ ':status', '302', 42 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.5.2',
|
||||
huffman: false,
|
||||
continuation: true,
|
||||
input: '4803 3330 37c1 c0bf',
|
||||
output: [
|
||||
[ ':status', '307' ],
|
||||
[ 'cache-control', 'private' ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT' ],
|
||||
[ 'location', 'https://www.example.com' ]
|
||||
],
|
||||
table: [
|
||||
[ ':status', '307', 42 ],
|
||||
[ 'location', 'https://www.example.com', 63 ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT', 65 ],
|
||||
[ 'cache-control', 'private', 52 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.5.3',
|
||||
huffman: false,
|
||||
continuation: true,
|
||||
input: '88c1 611d 4d6f 6e2c 2032 3120 4f63 7420' +
|
||||
'3230 3133 2032 303a 3133 3a32 3220 474d' +
|
||||
'54c0 5a04 677a 6970 7738 666f 6f3d 4153' +
|
||||
'444a 4b48 514b 425a 584f 5157 454f 5049' +
|
||||
'5541 5851 5745 4f49 553b 206d 6178 2d61' +
|
||||
'6765 3d33 3630 303b 2076 6572 7369 6f6e' +
|
||||
'3d31',
|
||||
output: [
|
||||
[ ':status', '200' ],
|
||||
[ 'cache-control', 'private' ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:22 GMT' ],
|
||||
[ 'location', 'https://www.example.com' ],
|
||||
[ 'content-encoding', 'gzip' ],
|
||||
[ 'set-cookie',
|
||||
'foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1' ]
|
||||
],
|
||||
table: [
|
||||
[ 'set-cookie',
|
||||
'foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1',
|
||||
98 ],
|
||||
[ 'content-encoding', 'gzip', 52 ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:22 GMT', 65 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
id: 'C.6.1',
|
||||
input: '4882 6402 5885 aec3 771a 4b61 96d0 7abe' +
|
||||
'9410 54d4 44a8 2005 9504 0b81 66e0 82a6' +
|
||||
'2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8' +
|
||||
'e9ae 82ae 43d3',
|
||||
output: [
|
||||
[ ':status', '302' ],
|
||||
[ 'cache-control', 'private' ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT' ],
|
||||
[ 'location', 'https://www.example.com' ]
|
||||
],
|
||||
table: [
|
||||
[ 'location', 'https://www.example.com', 63 ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT', 65 ],
|
||||
[ 'cache-control', 'private', 52 ],
|
||||
[ ':status', '302', 42 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.6.2',
|
||||
continuation: true,
|
||||
input: '4883 640e ffc1 c0bf',
|
||||
output: [
|
||||
[ ':status', '307' ],
|
||||
[ 'cache-control', 'private' ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT' ],
|
||||
[ 'location', 'https://www.example.com' ]
|
||||
],
|
||||
table: [
|
||||
[ ':status', '307', 42 ],
|
||||
[ 'location', 'https://www.example.com', 63 ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:21 GMT', 65 ],
|
||||
[ 'cache-control', 'private', 52 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'C.6.3',
|
||||
continuation: true,
|
||||
input: '88c1 6196 d07a be94 1054 d444 a820 0595' +
|
||||
'040b 8166 e084 a62d 1bff c05a 839b d9ab' +
|
||||
'77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b' +
|
||||
'3960 d5af 2708 7f36 72c1 ab27 0fb5 291f' +
|
||||
'9587 3160 65c0 03ed 4ee5 b106 3d50 07',
|
||||
output: [
|
||||
[ ':status', '200' ],
|
||||
[ 'cache-control', 'private' ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:22 GMT' ],
|
||||
[ 'location', 'https://www.example.com' ],
|
||||
[ 'content-encoding', 'gzip' ],
|
||||
[ 'set-cookie',
|
||||
'foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1' ]
|
||||
],
|
||||
table: [
|
||||
[ 'set-cookie',
|
||||
'foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1',
|
||||
98 ],
|
||||
[ 'content-encoding', 'gzip', 52 ],
|
||||
[ 'date', 'Mon, 21 Oct 2013 20:13:22 GMT', 65 ]
|
||||
]
|
||||
}
|
||||
];
|
Reference in New Issue
Block a user