first commit

This commit is contained in:
monjack
2025-06-20 18:01:48 +08:00
commit 6daa6d65c1
24611 changed files with 2512443 additions and 0 deletions

2
app_vue/node_modules/hpack.js/.npmignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
npm-debug.log

6
app_vue/node_modules/hpack.js/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,6 @@
language: node_js
node_js:
- "iojs"
branches:
only:
- master

52
app_vue/node_modules/hpack.js/README.md generated vendored Normal file
View File

@ -0,0 +1,52 @@
# HPACK.js
[![Build Status](https://secure.travis-ci.org/indutny/hpack.js.png)](http://travis-ci.org/indutny/hpack.js)
[![NPM version](https://badge.fury.io/js/hpack.js.svg)](http://badge.fury.io/js/hpack.js)
Plain-JS implementation of [HPACK][0].
## Usage
```javascript
var hpack = require('hpack.js');
var comp = hpack.compressor.create({ table: { size: 256 } });
var decomp = hpack.decompressor.create({ table: { size: 256 } });
comp.write([ { name: 'host', value: 'localhost' } ]);
var raw = comp.read();
console.log(raw);
// <Buffer 66 86 a0 e4 1d 13 9d 09>
decomp.write(raw);
decomp.execute();
console.log(decomp.read());
// { name: 'host', value: 'localhost', neverIndex: false }
```
#### LICENSE
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2015.
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:
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.
[0]: https://tools.ietf.org/html/rfc7541

34
app_vue/node_modules/hpack.js/bin/benchmark generated vendored Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env node
var hpack = require('../');
var options = {
table: { size: 1024 }
};
var compressor = hpack.compressor.create(options);
var vector = [];
for (var i = 0; i < 1024; i++) {
vector.push({
name: 'kind-of-big-header-name__',
value: 'not-so-small value yes!',
huffman: true,
neverIndex: true
});
}
compressor.write(vector);
var input = compressor.read();
console.time('decompressor');
for (var i = 0; i < 2000; i++) {
var decompressor = hpack.decompressor.create(options);
decompressor.write(input);
decompressor.execute();
while (true) {
var chunk = decompressor.read();
if (!chunk)
break;
}
}
console.timeEnd('decompressor');

12
app_vue/node_modules/hpack.js/lib/hpack.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
var hpack = exports;
hpack.utils = require('./hpack/utils');
hpack.huffman = require('./hpack/huffman');
hpack['static-table'] = require('./hpack/static-table');
hpack.table = require('./hpack/table');
hpack.decoder = require('./hpack/decoder');
hpack.decompressor = require('./hpack/decompressor');
hpack.encoder = require('./hpack/encoder');
hpack.compressor = require('./hpack/compressor');

127
app_vue/node_modules/hpack.js/lib/hpack/compressor.js generated vendored Normal file
View File

@ -0,0 +1,127 @@
var hpack = require('../hpack');
var utils = hpack.utils;
var encoder = hpack.encoder;
var table = hpack.table;
var assert = utils.assert;
var inherits = require('inherits');
var Duplex = require('readable-stream').Duplex;
function Compressor(options) {
Duplex.call(this, {
writableObjectMode: true
});
this._encoder = null;
this._table = table.create(options.table);
}
inherits(Compressor, Duplex);
module.exports = Compressor;
Compressor.create = function create(options) {
return new Compressor(options);
};
Compressor.prototype._read = function _read() {
// We only push!
};
Compressor.prototype._write = function _write(data, enc, cb) {
assert(Array.isArray(data), 'Compressor.write() expects list of headers');
this._encoder = encoder.create();
for (var i = 0; i < data.length; i++)
this._encodeHeader(data[i]);
var data = this._encoder.render();
this._encoder = null;
cb(null);
for (var i = 0; i < data.length; i++)
this.push(data[i]);
};
Compressor.prototype.updateTableSize = function updateTableSize(size) {
if (size >= this._table.protocolMaxSize) {
size = this._table.protocolMaxSize;
var enc = encoder.create();
// indexed = 0
// incremental = 0
// update = 1
enc.encodeBits(1, 3);
enc.encodeInt(size);
var data = enc.render();
for (var i = 0; i < data.length; i++)
this.push(data[i]);
}
this._table.updateSize(size);
};
Compressor.prototype.reset = function reset() {
var enc = encoder.create();
var size = this._table.maxSize;
// indexed = 0
// incremental = 0
// update = 1
enc.encodeBits(1, 3);
enc.encodeInt(0);
// Evict everything
this._table.updateSize(0);
// indexed = 0
// incremental = 0
// update = 1
enc.encodeBits(1, 3);
enc.encodeInt(size);
// Revert size
this._table.updateSize(size);
var data = enc.render();
for (var i = 0; i < data.length; i++)
this.push(data[i]);
};
Compressor.prototype._encodeHeader = function _encodeHeader(header) {
if (header.neverIndex) {
var index = 0;
var neverIndex = 1;
var isIndexed = 0;
var isIncremental = 0;
} else {
var index = this._table.reverseLookup(header.name, header.value);
var isIndexed = index > 0;
var isIncremental = header.incremental !== false;
var neverIndex = 0;
}
this._encoder.encodeBit(isIndexed);
if (isIndexed) {
this._encoder.encodeInt(index);
return;
}
var name = utils.toArray(header.name);
var value = utils.toArray(header.value);
this._encoder.encodeBit(isIncremental);
if (isIncremental) {
this._table.add(header.name, header.value, name.length, value.length);
} else {
// Update = false
this._encoder.encodeBit(0);
this._encoder.encodeBit(neverIndex);
}
// index is negative for `name`-only headers
this._encoder.encodeInt(-index);
if (index === 0)
this._encoder.encodeStr(name, header.huffman !== false);
this._encoder.encodeStr(value, header.huffman !== false);
};

169
app_vue/node_modules/hpack.js/lib/hpack/decoder.js generated vendored Normal file
View File

@ -0,0 +1,169 @@
var hpack = require('../hpack');
var utils = hpack.utils;
var huffman = hpack.huffman.decode;
var assert = utils.assert;
var OffsetBuffer = require('obuf');
function Decoder() {
this.buffer = new OffsetBuffer();
this.bitOffset = 0;
// Used internally in decodeStr
this._huffmanNode = null;
}
module.exports = Decoder;
Decoder.create = function create() {
return new Decoder();
};
Decoder.prototype.isEmpty = function isEmpty() {
return this.buffer.isEmpty();
};
Decoder.prototype.push = function push(chunk) {
this.buffer.push(chunk);
};
Decoder.prototype.decodeBit = function decodeBit() {
// Need at least one octet
assert(this.buffer.has(1), 'Buffer too small for an int');
var octet;
var offset = this.bitOffset;
if (++this.bitOffset === 8) {
octet = this.buffer.readUInt8();
this.bitOffset = 0;
} else {
octet = this.buffer.peekUInt8();
}
return (octet >>> (7 - offset)) & 1;
};
// Just for testing
Decoder.prototype.skipBits = function skipBits(n) {
this.bitOffset += n;
this.buffer.skip(this.bitOffset >> 3);
this.bitOffset &= 0x7;
};
Decoder.prototype.decodeInt = function decodeInt() {
// Need at least one octet
assert(this.buffer.has(1), 'Buffer too small for an int');
var prefix = 8 - this.bitOffset;
// We are going to end up octet-aligned
this.bitOffset = 0;
var max = (1 << prefix) - 1;
var octet = this.buffer.readUInt8() & max;
// Fast case - int fits into the prefix
if (octet !== max)
return octet;
// TODO(indutny): what about > 32bit numbers?
var res = 0;
var isLast = false;
var len = 0;
do {
octet = this.buffer.readUInt8();
isLast = (octet & 0x80) === 0;
res <<= 7;
res |= octet & 0x7f;
len++;
} while (!isLast);
assert(isLast, 'Incomplete data for multi-octet integer');
assert(len <= 4, 'Integer does not fit into 32 bits');
// Reverse bits
res = (res >>> 21) |
(((res >> 14) & 0x7f) << 7) |
(((res >> 7) & 0x7f) << 14) |
((res & 0x7f) << 21);
res >>= (4 - len) * 7;
// Append prefix max
res += max;
return res;
};
Decoder.prototype.decodeHuffmanWord = function decodeHuffmanWord(input,
inputBits,
out) {
var root = huffman;
var node = this._huffmanNode;
var word = input;
var bits = inputBits;
for (; bits > 0; word &= (1 << bits) - 1) {
// Nudge the word bit length to match it
for (var i = Math.max(0, bits - 8); i < bits; i++) {
var subnode = node[word >>> i];
if (typeof subnode !== 'number') {
node = subnode;
bits = i;
break;
}
if (subnode === 0)
continue;
// Word bit length should match
if ((subnode >>> 9) !== bits - i) {
subnode = 0;
continue;
}
var octet = subnode & 0x1ff;
assert(octet !== 256, 'EOS in encoding');
out.push(octet);
node = root;
bits = i;
break;
}
if (subnode === 0)
break;
}
this._huffmanNode = node;
return bits;
};
Decoder.prototype.decodeStr = function decodeStr() {
var isHuffman = this.decodeBit();
var len = this.decodeInt();
assert(this.buffer.has(len), 'Not enough octets for string');
if (!isHuffman)
return this.buffer.take(len);
this._huffmanNode = huffman;
var out = [];
var word = 0;
var bits = 0;
var lastKey = 0;
for (var i = 0; i < len; i++) {
word <<= 8;
word |= this.buffer.readUInt8();
bits += 8;
bits = this.decodeHuffmanWord(word, bits, out);
lastKey = word >> bits;
word &= (1 << bits) - 1;
}
assert(this._huffmanNode === huffman, '8-bit EOS');
assert(word + 1 === (1 << bits), 'Final sequence is not EOS');
this._huffmanNode = null;
return out;
};

116
app_vue/node_modules/hpack.js/lib/hpack/decompressor.js generated vendored Normal file
View File

@ -0,0 +1,116 @@
var hpack = require('../hpack');
var utils = hpack.utils;
var decoder = hpack.decoder;
var table = hpack.table;
var assert = utils.assert;
var inherits = require('inherits');
var Duplex = require('readable-stream').Duplex;
function Decompressor(options) {
Duplex.call(this, {
readableObjectMode: true
});
this._decoder = decoder.create();
this._table = table.create(options.table);
}
inherits(Decompressor, Duplex);
module.exports = Decompressor;
Decompressor.create = function create(options) {
return new Decompressor(options);
};
Decompressor.prototype._read = function _read() {
// We only push!
};
Decompressor.prototype._write = function _write(data, enc, cb) {
this._decoder.push(data);
cb(null);
};
Decompressor.prototype.execute = function execute(cb) {
while (!this._decoder.isEmpty()) {
try {
this._execute();
} catch (err) {
if (cb)
return done(err);
else
return this.emit('error', err);
}
}
if (cb)
done(null);
function done(err) {
process.nextTick(function() {
cb(err);
});
}
};
Decompressor.prototype.updateTableSize = function updateTableSize(size) {
this._table.updateSize(size);
};
Decompressor.prototype._execute = function _execute() {
var isIndexed = this._decoder.decodeBit();
if (isIndexed)
return this._processIndexed();
var isIncremental = this._decoder.decodeBit();
var neverIndex = 0;
if (!isIncremental) {
var isUpdate = this._decoder.decodeBit();
if (isUpdate)
return this._processUpdate();
neverIndex = this._decoder.decodeBit();
}
this._processLiteral(isIncremental, neverIndex);
};
Decompressor.prototype._processIndexed = function _processIndexed() {
var index = this._decoder.decodeInt();
var lookup = this._table.lookup(index);
this.push({ name: lookup.name, value: lookup.value, neverIndex: false });
};
Decompressor.prototype._processLiteral = function _processLiteral(inc, never) {
var index = this._decoder.decodeInt();
var name;
var nameSize;
// Literal header-name too
if (index === 0) {
name = this._decoder.decodeStr();
nameSize = name.length;
name = utils.stringify(name);
} else {
var lookup = this._table.lookup(index);
nameSize = lookup.nameSize;
name = lookup.name;
}
var value = this._decoder.decodeStr();
var valueSize = value.length;
value = utils.stringify(value);
if (inc)
this._table.add(name, value, nameSize, valueSize);
this.push({ name: name, value: value, neverIndex: never !== 0});
};
Decompressor.prototype._processUpdate = function _processUpdate() {
var size = this._decoder.decodeInt();
this.updateTableSize(size);
};

129
app_vue/node_modules/hpack.js/lib/hpack/encoder.js generated vendored Normal file
View File

@ -0,0 +1,129 @@
var hpack = require('../hpack');
var utils = hpack.utils;
var huffman = hpack.huffman.encode;
var assert = utils.assert;
var WBuf = require('wbuf');
function Encoder() {
this.buffer = new WBuf();
this.word = 0;
this.bitOffset = 0;
}
module.exports = Encoder;
Encoder.create = function create() {
return new Encoder();
};
Encoder.prototype.render = function render() {
return this.buffer.render();
};
Encoder.prototype.encodeBit = function encodeBit(bit) {
var octet;
this.word <<= 1;
this.word |= bit;
this.bitOffset++;
if (this.bitOffset === 8) {
this.buffer.writeUInt8(this.word);
this.word = 0;
this.bitOffset = 0;
}
};
Encoder.prototype.encodeBits = function encodeBits(bits, len) {
var left = bits;
var leftLen = len;
while (leftLen > 0) {
var avail = Math.min(leftLen, 8 - this.bitOffset);
var toWrite = left >>> (leftLen - avail);
if (avail === 8) {
this.buffer.writeUInt8(toWrite);
} else {
this.word <<= avail;
this.word |= toWrite;
this.bitOffset += avail;
if (this.bitOffset === 8) {
this.buffer.writeUInt8(this.word);
this.word = 0;
this.bitOffset = 0;
}
}
leftLen -= avail;
left &= (1 << leftLen) - 1;
}
};
// Just for testing
Encoder.prototype.skipBits = function skipBits(num) {
this.bitOffset += num;
this.buffer.skip(this.bitOffset >> 3);
this.bitOffset &= 0x7;
};
Encoder.prototype.encodeInt = function encodeInt(num) {
var prefix = 8 - this.bitOffset;
// We are going to end up octet-aligned
this.bitOffset = 0;
var max = (1 << prefix) - 1;
// Fast case - int fits into the prefix
if (num < max) {
this.buffer.writeUInt8((this.word << prefix) | num);
return octet;
}
var left = num - max;
this.buffer.writeUInt8((this.word << prefix) | max);
do {
var octet = left & 0x7f;
left >>= 7;
if (left !== 0)
octet |= 0x80;
this.buffer.writeUInt8(octet);
} while (left !== 0);
};
Encoder.prototype.encodeStr = function encodeStr(value, isHuffman) {
this.encodeBit(isHuffman ? 1 : 0);
if (!isHuffman) {
this.buffer.reserve(value.length + 1);
this.encodeInt(value.length);
for (var i = 0; i < value.length; i++)
this.buffer.writeUInt8(value[i]);
return;
}
var codes = [];
var len = 0;
var pad = 0;
for (var i = 0; i < value.length; i++) {
var code = huffman[value[i]];
codes.push(code);
len += code[0];
}
if (len % 8 !== 0)
pad = 8 - (len % 8);
len += pad;
this.buffer.reserve((len / 8) + 1);
this.encodeInt(len / 8);
for (var i = 0; i < codes.length; i++) {
var code = codes[i];
this.encodeBits(code[1], code[0]);
}
// Append padding
this.encodeBits(0xff >>> (8 - pad), pad);
};

159
app_vue/node_modules/hpack.js/lib/hpack/huffman.js generated vendored Normal file
View File

@ -0,0 +1,159 @@
exports.decode =
[2608,2609,2610,2657,2659,2661,2665,2671,2675,2676,0,0,0,0,0,0,0,0,0,0,
3104,3109,3117,3118,3119,3123,3124,3125,3126,3127,3128,3129,3133,3137,3167,
3170,3172,3174,3175,3176,3180,3181,3182,3184,3186,3189,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3642,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,
3664,3665,3666,3667,3668,3669,3670,3671,3673,3690,3691,3697,3702,3703,3704,
3705,3706,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4134,4138,4140,4155,4184,4186,[1057,
1058,1064,1065,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1087,0,1575,1579,1660,0,0,0,0,0,2083,2110,0,0,0,0,0,0,0,0,0,0,0,0,2560,
2596,2624,2651,2653,2686,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,3166,3197,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3644,
3680,3707,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,[1628,1731,1744,0,0,0,2176,2178,
2179,2210,2232,2242,2272,2274,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2713,2721,2727,
2732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0],[2736,2737,2739,2769,2776,2777,2787,2789,2790,0,0,0,0,0,0,0,0,0,
3201,3204,3205,3206,3208,3218,3226,3228,3232,3235,3236,3241,3242,3245,3250,
3253,3257,3258,3259,3261,3262,3268,3270,3300,3304,3305,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3585,
3719,3721,3722,3723,3724,3725,3727,3731,3733,3734,3735,3736,3739,3741,3742,
3749,3750,3752,3758,3759,3764,3766,3767,3772,3775,3781,3815,3823,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,4105,4238,4240,4241,4244,4255,4267,4302,4311,4321,4332,4333,[711,719,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[746,747,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1216,1217,
1224,1225,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1226,1229,1234,1237,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0],[1242,1243,1262,1264,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0],[1266,1267,1279,0,0,0,1739,1740,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0],[1747,1748,1750,1757,1758,1759,1777,1780,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1781,1782,1783,1784,1786,
1787,1788,1789,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1790,0,
2050,2051,2052,2053,2054,2055,2056,2059,2060,2062,2063,2064,2065,2066,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2067,2068,2069,2071,2072,2073,2074,2075,
2076,2077,2078,2079,2175,2268,2297,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3082,3085,3094,3328,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0]]]];
exports.encode =
[[13,8184],[23,8388568],[28,268435426],[28,268435427],[28,268435428],[28,
268435429],[28,268435430],[28,268435431],[28,268435432],[24,16777194],[30,
1073741820],[28,268435433],[28,268435434],[30,1073741821],[28,268435435],
[28,268435436],[28,268435437],[28,268435438],[28,268435439],[28,268435440],
[28,268435441],[28,268435442],[30,1073741822],[28,268435443],[28,
268435444],[28,268435445],[28,268435446],[28,268435447],[28,268435448],[28,
268435449],[28,268435450],[28,268435451],[6,20],[10,1016],[10,1017],[12,
4090],[13,8185],[6,21],[8,248],[11,2042],[10,1018],[10,1019],[8,249],[11,
2043],[8,250],[6,22],[6,23],[6,24],[5,0],[5,1],[5,2],[6,25],[6,26],[6,27],
[6,28],[6,29],[6,30],[6,31],[7,92],[8,251],[15,32764],[6,32],[12,4091],[10,
1020],[13,8186],[6,33],[7,93],[7,94],[7,95],[7,96],[7,97],[7,98],[7,99],[7,
100],[7,101],[7,102],[7,103],[7,104],[7,105],[7,106],[7,107],[7,108],[7,
109],[7,110],[7,111],[7,112],[7,113],[7,114],[8,252],[7,115],[8,253],[13,
8187],[19,524272],[13,8188],[14,16380],[6,34],[15,32765],[5,3],[6,35],[5,
4],[6,36],[5,5],[6,37],[6,38],[6,39],[5,6],[7,116],[7,117],[6,40],[6,41],
[6,42],[5,7],[6,43],[7,118],[6,44],[5,8],[5,9],[6,45],[7,119],[7,120],[7,
121],[7,122],[7,123],[15,32766],[11,2044],[14,16381],[13,8189],[28,
268435452],[20,1048550],[22,4194258],[20,1048551],[20,1048552],[22,
4194259],[22,4194260],[22,4194261],[23,8388569],[22,4194262],[23,8388570],
[23,8388571],[23,8388572],[23,8388573],[23,8388574],[24,16777195],[23,
8388575],[24,16777196],[24,16777197],[22,4194263],[23,8388576],[24,
16777198],[23,8388577],[23,8388578],[23,8388579],[23,8388580],[21,2097116],
[22,4194264],[23,8388581],[22,4194265],[23,8388582],[23,8388583],[24,
16777199],[22,4194266],[21,2097117],[20,1048553],[22,4194267],[22,4194268],
[23,8388584],[23,8388585],[21,2097118],[23,8388586],[22,4194269],[22,
4194270],[24,16777200],[21,2097119],[22,4194271],[23,8388587],[23,8388588],
[21,2097120],[21,2097121],[22,4194272],[21,2097122],[23,8388589],[22,
4194273],[23,8388590],[23,8388591],[20,1048554],[22,4194274],[22,4194275],
[22,4194276],[23,8388592],[22,4194277],[22,4194278],[23,8388593],[26,
67108832],[26,67108833],[20,1048555],[19,524273],[22,4194279],[23,8388594],
[22,4194280],[25,33554412],[26,67108834],[26,67108835],[26,67108836],[27,
134217694],[27,134217695],[26,67108837],[24,16777201],[25,33554413],[19,
524274],[21,2097123],[26,67108838],[27,134217696],[27,134217697],[26,
67108839],[27,134217698],[24,16777202],[21,2097124],[21,2097125],[26,
67108840],[26,67108841],[28,268435453],[27,134217699],[27,134217700],[27,
134217701],[20,1048556],[24,16777203],[20,1048557],[21,2097126],[22,
4194281],[21,2097127],[21,2097128],[23,8388595],[22,4194282],[22,4194283],
[25,33554414],[25,33554415],[24,16777204],[24,16777205],[26,67108842],[23,
8388596],[26,67108843],[27,134217702],[26,67108844],[26,67108845],[27,
134217703],[27,134217704],[27,134217705],[27,134217706],[27,134217707],[28,
268435454],[27,134217708],[27,134217709],[27,134217710],[27,134217711],[27,
134217712],[26,67108846],[30,1073741823]];

691
app_vue/node_modules/hpack.js/lib/hpack/static-table.js generated vendored Normal file
View File

@ -0,0 +1,691 @@
exports.table = [
{
"name": ":authority",
"value": "",
"nameSize": 10,
"totalSize": 42
},
{
"name": ":method",
"value": "GET",
"nameSize": 7,
"totalSize": 42
},
{
"name": ":method",
"value": "POST",
"nameSize": 7,
"totalSize": 43
},
{
"name": ":path",
"value": "/",
"nameSize": 5,
"totalSize": 38
},
{
"name": ":path",
"value": "/index.html",
"nameSize": 5,
"totalSize": 48
},
{
"name": ":scheme",
"value": "http",
"nameSize": 7,
"totalSize": 43
},
{
"name": ":scheme",
"value": "https",
"nameSize": 7,
"totalSize": 44
},
{
"name": ":status",
"value": "200",
"nameSize": 7,
"totalSize": 42
},
{
"name": ":status",
"value": "204",
"nameSize": 7,
"totalSize": 42
},
{
"name": ":status",
"value": "206",
"nameSize": 7,
"totalSize": 42
},
{
"name": ":status",
"value": "304",
"nameSize": 7,
"totalSize": 42
},
{
"name": ":status",
"value": "400",
"nameSize": 7,
"totalSize": 42
},
{
"name": ":status",
"value": "404",
"nameSize": 7,
"totalSize": 42
},
{
"name": ":status",
"value": "500",
"nameSize": 7,
"totalSize": 42
},
{
"name": "accept-charset",
"value": "",
"nameSize": 14,
"totalSize": 46
},
{
"name": "accept-encoding",
"value": "gzip, deflate",
"nameSize": 15,
"totalSize": 60
},
{
"name": "accept-language",
"value": "",
"nameSize": 15,
"totalSize": 47
},
{
"name": "accept-ranges",
"value": "",
"nameSize": 13,
"totalSize": 45
},
{
"name": "accept",
"value": "",
"nameSize": 6,
"totalSize": 38
},
{
"name": "access-control-allow-origin",
"value": "",
"nameSize": 27,
"totalSize": 59
},
{
"name": "age",
"value": "",
"nameSize": 3,
"totalSize": 35
},
{
"name": "allow",
"value": "",
"nameSize": 5,
"totalSize": 37
},
{
"name": "authorization",
"value": "",
"nameSize": 13,
"totalSize": 45
},
{
"name": "cache-control",
"value": "",
"nameSize": 13,
"totalSize": 45
},
{
"name": "content-disposition",
"value": "",
"nameSize": 19,
"totalSize": 51
},
{
"name": "content-encoding",
"value": "",
"nameSize": 16,
"totalSize": 48
},
{
"name": "content-language",
"value": "",
"nameSize": 16,
"totalSize": 48
},
{
"name": "content-length",
"value": "",
"nameSize": 14,
"totalSize": 46
},
{
"name": "content-location",
"value": "",
"nameSize": 16,
"totalSize": 48
},
{
"name": "content-range",
"value": "",
"nameSize": 13,
"totalSize": 45
},
{
"name": "content-type",
"value": "",
"nameSize": 12,
"totalSize": 44
},
{
"name": "cookie",
"value": "",
"nameSize": 6,
"totalSize": 38
},
{
"name": "date",
"value": "",
"nameSize": 4,
"totalSize": 36
},
{
"name": "etag",
"value": "",
"nameSize": 4,
"totalSize": 36
},
{
"name": "expect",
"value": "",
"nameSize": 6,
"totalSize": 38
},
{
"name": "expires",
"value": "",
"nameSize": 7,
"totalSize": 39
},
{
"name": "from",
"value": "",
"nameSize": 4,
"totalSize": 36
},
{
"name": "host",
"value": "",
"nameSize": 4,
"totalSize": 36
},
{
"name": "if-match",
"value": "",
"nameSize": 8,
"totalSize": 40
},
{
"name": "if-modified-since",
"value": "",
"nameSize": 17,
"totalSize": 49
},
{
"name": "if-none-match",
"value": "",
"nameSize": 13,
"totalSize": 45
},
{
"name": "if-range",
"value": "",
"nameSize": 8,
"totalSize": 40
},
{
"name": "if-unmodified-since",
"value": "",
"nameSize": 19,
"totalSize": 51
},
{
"name": "last-modified",
"value": "",
"nameSize": 13,
"totalSize": 45
},
{
"name": "link",
"value": "",
"nameSize": 4,
"totalSize": 36
},
{
"name": "location",
"value": "",
"nameSize": 8,
"totalSize": 40
},
{
"name": "max-forwards",
"value": "",
"nameSize": 12,
"totalSize": 44
},
{
"name": "proxy-authenticate",
"value": "",
"nameSize": 18,
"totalSize": 50
},
{
"name": "proxy-authorization",
"value": "",
"nameSize": 19,
"totalSize": 51
},
{
"name": "range",
"value": "",
"nameSize": 5,
"totalSize": 37
},
{
"name": "referer",
"value": "",
"nameSize": 7,
"totalSize": 39
},
{
"name": "refresh",
"value": "",
"nameSize": 7,
"totalSize": 39
},
{
"name": "retry-after",
"value": "",
"nameSize": 11,
"totalSize": 43
},
{
"name": "server",
"value": "",
"nameSize": 6,
"totalSize": 38
},
{
"name": "set-cookie",
"value": "",
"nameSize": 10,
"totalSize": 42
},
{
"name": "strict-transport-security",
"value": "",
"nameSize": 25,
"totalSize": 57
},
{
"name": "transfer-encoding",
"value": "",
"nameSize": 17,
"totalSize": 49
},
{
"name": "user-agent",
"value": "",
"nameSize": 10,
"totalSize": 42
},
{
"name": "vary",
"value": "",
"nameSize": 4,
"totalSize": 36
},
{
"name": "via",
"value": "",
"nameSize": 3,
"totalSize": 35
},
{
"name": "www-authenticate",
"value": "",
"nameSize": 16,
"totalSize": 48
}
];
exports.map = {
":authority": {
"index": 1,
"values": {
"": 1
}
},
":method": {
"index": 2,
"values": {
"GET": 2,
"POST": 3
}
},
":path": {
"index": 4,
"values": {
"/": 4,
"/index.html": 5
}
},
":scheme": {
"index": 6,
"values": {
"http": 6,
"https": 7
}
},
":status": {
"index": 8,
"values": {
"200": 8,
"204": 9,
"206": 10,
"304": 11,
"400": 12,
"404": 13,
"500": 14
}
},
"accept-charset": {
"index": 15,
"values": {
"": 15
}
},
"accept-encoding": {
"index": 16,
"values": {
"gzip, deflate": 16
}
},
"accept-language": {
"index": 17,
"values": {
"": 17
}
},
"accept-ranges": {
"index": 18,
"values": {
"": 18
}
},
"accept": {
"index": 19,
"values": {
"": 19
}
},
"access-control-allow-origin": {
"index": 20,
"values": {
"": 20
}
},
"age": {
"index": 21,
"values": {
"": 21
}
},
"allow": {
"index": 22,
"values": {
"": 22
}
},
"authorization": {
"index": 23,
"values": {
"": 23
}
},
"cache-control": {
"index": 24,
"values": {
"": 24
}
},
"content-disposition": {
"index": 25,
"values": {
"": 25
}
},
"content-encoding": {
"index": 26,
"values": {
"": 26
}
},
"content-language": {
"index": 27,
"values": {
"": 27
}
},
"content-length": {
"index": 28,
"values": {
"": 28
}
},
"content-location": {
"index": 29,
"values": {
"": 29
}
},
"content-range": {
"index": 30,
"values": {
"": 30
}
},
"content-type": {
"index": 31,
"values": {
"": 31
}
},
"cookie": {
"index": 32,
"values": {
"": 32
}
},
"date": {
"index": 33,
"values": {
"": 33
}
},
"etag": {
"index": 34,
"values": {
"": 34
}
},
"expect": {
"index": 35,
"values": {
"": 35
}
},
"expires": {
"index": 36,
"values": {
"": 36
}
},
"from": {
"index": 37,
"values": {
"": 37
}
},
"host": {
"index": 38,
"values": {
"": 38
}
},
"if-match": {
"index": 39,
"values": {
"": 39
}
},
"if-modified-since": {
"index": 40,
"values": {
"": 40
}
},
"if-none-match": {
"index": 41,
"values": {
"": 41
}
},
"if-range": {
"index": 42,
"values": {
"": 42
}
},
"if-unmodified-since": {
"index": 43,
"values": {
"": 43
}
},
"last-modified": {
"index": 44,
"values": {
"": 44
}
},
"link": {
"index": 45,
"values": {
"": 45
}
},
"location": {
"index": 46,
"values": {
"": 46
}
},
"max-forwards": {
"index": 47,
"values": {
"": 47
}
},
"proxy-authenticate": {
"index": 48,
"values": {
"": 48
}
},
"proxy-authorization": {
"index": 49,
"values": {
"": 49
}
},
"range": {
"index": 50,
"values": {
"": 50
}
},
"referer": {
"index": 51,
"values": {
"": 51
}
},
"refresh": {
"index": 52,
"values": {
"": 52
}
},
"retry-after": {
"index": 53,
"values": {
"": 53
}
},
"server": {
"index": 54,
"values": {
"": 54
}
},
"set-cookie": {
"index": 55,
"values": {
"": 55
}
},
"strict-transport-security": {
"index": 56,
"values": {
"": 56
}
},
"transfer-encoding": {
"index": 57,
"values": {
"": 57
}
},
"user-agent": {
"index": 58,
"values": {
"": 58
}
},
"vary": {
"index": 59,
"values": {
"": 59
}
},
"via": {
"index": 60,
"values": {
"": 60
}
},
"www-authenticate": {
"index": 61,
"values": {
"": 61
}
}
};

85
app_vue/node_modules/hpack.js/lib/hpack/table.js generated vendored Normal file
View File

@ -0,0 +1,85 @@
var hpack = require('../hpack');
var utils = hpack.utils;
var assert = utils.assert;
function Table(options) {
this['static'] = hpack['static-table'];
this.dynamic = [];
this.size = 0;
this.maxSize = 0;
this.length = this['static'].table.length;
this.protocolMaxSize = options.maxSize;
this.maxSize = this.protocolMaxSize;
this.lookupDepth = options.lookupDepth || 32;
}
module.exports = Table;
Table.create = function create(options) {
return new Table(options);
};
Table.prototype.lookup = function lookup(index) {
assert(index !== 0, 'Zero indexed field');
assert(index <= this.length, 'Indexed field OOB')
if (index <= this['static'].table.length)
return this['static'].table[index - 1];
else
return this.dynamic[this.length - index];
};
Table.prototype.reverseLookup = function reverseLookup(name, value) {
var staticEntry = this['static'].map[name];
if (staticEntry && staticEntry.values[value])
return staticEntry.values[value];
// Reverse search dynamic table (new items are at the end of it)
var limit = Math.max(0, this.dynamic.length - this.lookupDepth);
for (var i = this.dynamic.length - 1; i >= limit; i--) {
var entry = this.dynamic[i];
if (entry.name === name && entry.value === value)
return this.length - i;
if (entry.name === name) {
// Prefer smaller index
if (staticEntry)
break;
return -(this.length - i);
}
}
if (staticEntry)
return -staticEntry.index;
return 0;
};
Table.prototype.add = function add(name, value, nameSize, valueSize) {
var totalSize = nameSize + valueSize + 32;
this.dynamic.push({
name: name,
value: value,
nameSize: nameSize,
totalSize: totalSize
});
this.size += totalSize;
this.length++;
this.evict();
};
Table.prototype.evict = function evict() {
while (this.size > this.maxSize) {
var entry = this.dynamic.shift();
this.size -= entry.totalSize;
this.length--;
}
assert(this.size >= 0, 'Table size sanity check failed');
};
Table.prototype.updateSize = function updateSize(size) {
assert(size <= this.protocolMaxSize, 'Table size bigger than maximum');
this.maxSize = size;
this.evict();
};

25
app_vue/node_modules/hpack.js/lib/hpack/utils.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
exports.assert = function assert(cond, text) {
if (!cond)
throw new Error(text);
};
exports.stringify = function stringify(arr) {
var res = '';
for (var i = 0; i < arr.length; i++)
res += String.fromCharCode(arr[i]);
return res;
};
exports.toArray = function toArray(str) {
var res = [];
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);
var hi = c >>> 8;
var lo = c & 0xff;
if (hi)
res.push(hi, lo);
else
res.push(lo);
}
return res;
};

View File

@ -0,0 +1,34 @@
sudo: false
language: node_js
before_install:
- (test $NPM_LEGACY && npm install -g npm@2 && npm install -g npm@3) || true
notifications:
email: false
matrix:
fast_finish: true
include:
- node_js: '0.8'
env: NPM_LEGACY=true
- node_js: '0.10'
env: NPM_LEGACY=true
- node_js: '0.11'
env: NPM_LEGACY=true
- node_js: '0.12'
env: NPM_LEGACY=true
- node_js: 1
env: NPM_LEGACY=true
- node_js: 2
env: NPM_LEGACY=true
- node_js: 3
env: NPM_LEGACY=true
- node_js: 4
- node_js: 5
- node_js: 6
- node_js: 7
- node_js: 8
- node_js: 9
script: "npm run test"
env:
global:
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=

View File

@ -0,0 +1,38 @@
# Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
* (a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
* (b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
* (c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
* (d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
## Moderation Policy
The [Node.js Moderation Policy] applies to this WG.
## Code of Conduct
The [Node.js Code of Conduct][] applies to this WG.
[Node.js Code of Conduct]:
https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
[Node.js Moderation Policy]:
https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md

View File

@ -0,0 +1,136 @@
### Streams Working Group
The Node.js Streams is jointly governed by a Working Group
(WG)
that is responsible for high-level guidance of the project.
The WG has final authority over this project including:
* Technical direction
* Project governance and process (including this policy)
* Contribution policy
* GitHub repository hosting
* Conduct guidelines
* Maintaining the list of additional Collaborators
For the current list of WG members, see the project
[README.md](./README.md#current-project-team-members).
### Collaborators
The readable-stream GitHub repository is
maintained by the WG and additional Collaborators who are added by the
WG on an ongoing basis.
Individuals making significant and valuable contributions are made
Collaborators and given commit-access to the project. These
individuals are identified by the WG and their addition as
Collaborators is discussed during the WG meeting.
_Note:_ If you make a significant contribution and are not considered
for commit-access log an issue or contact a WG member directly and it
will be brought up in the next WG meeting.
Modifications of the contents of the readable-stream repository are
made on
a collaborative basis. Anybody with a GitHub account may propose a
modification via pull request and it will be considered by the project
Collaborators. All pull requests must be reviewed and accepted by a
Collaborator with sufficient expertise who is able to take full
responsibility for the change. In the case of pull requests proposed
by an existing Collaborator, an additional Collaborator is required
for sign-off. Consensus should be sought if additional Collaborators
participate and there is disagreement around a particular
modification. See _Consensus Seeking Process_ below for further detail
on the consensus model used for governance.
Collaborators may opt to elevate significant or controversial
modifications, or modifications that have not found consensus to the
WG for discussion by assigning the ***WG-agenda*** tag to a pull
request or issue. The WG should serve as the final arbiter where
required.
For the current list of Collaborators, see the project
[README.md](./README.md#members).
### WG Membership
WG seats are not time-limited. There is no fixed size of the WG.
However, the expected target is between 6 and 12, to ensure adequate
coverage of important areas of expertise, balanced with the ability to
make decisions efficiently.
There is no specific set of requirements or qualifications for WG
membership beyond these rules.
The WG may add additional members to the WG by unanimous consensus.
A WG member may be removed from the WG by voluntary resignation, or by
unanimous consensus of all other WG members.
Changes to WG membership should be posted in the agenda, and may be
suggested as any other agenda item (see "WG Meetings" below).
If an addition or removal is proposed during a meeting, and the full
WG is not in attendance to participate, then the addition or removal
is added to the agenda for the subsequent meeting. This is to ensure
that all members are given the opportunity to participate in all
membership decisions. If a WG member is unable to attend a meeting
where a planned membership decision is being made, then their consent
is assumed.
No more than 1/3 of the WG members may be affiliated with the same
employer. If removal or resignation of a WG member, or a change of
employment by a WG member, creates a situation where more than 1/3 of
the WG membership shares an employer, then the situation must be
immediately remedied by the resignation or removal of one or more WG
members affiliated with the over-represented employer(s).
### WG Meetings
The WG meets occasionally on a Google Hangout On Air. A designated moderator
approved by the WG runs the meeting. Each meeting should be
published to YouTube.
Items are added to the WG agenda that are considered contentious or
are modifications of governance, contribution policy, WG membership,
or release process.
The intention of the agenda is not to approve or review all patches;
that should happen continuously on GitHub and be handled by the larger
group of Collaborators.
Any community member or contributor can ask that something be added to
the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
WG member or the moderator can add the item to the agenda by adding
the ***WG-agenda*** tag to the issue.
Prior to each WG meeting the moderator will share the Agenda with
members of the WG. WG members can add any items they like to the
agenda at the beginning of each meeting. The moderator and the WG
cannot veto or remove items.
The WG may invite persons or representatives from certain projects to
participate in a non-voting capacity.
The moderator is responsible for summarizing the discussion of each
agenda item and sends it as a pull request after the meeting.
### Consensus Seeking Process
The WG follows a
[Consensus
Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
decision-making model.
When an agenda item has appeared to reach a consensus the moderator
will ask "Does anyone object?" as a final call for dissent from the
consensus.
If an agenda item cannot reach a consensus a WG member can call for
either a closing vote or a vote to table the issue to the next
meeting. The call for a vote must be seconded by a majority of the WG
or else the discussion will continue. Simple majority wins.
Note that changes to WG membership require a majority consensus. See
"WG Membership" above.

View File

@ -0,0 +1,47 @@
Node.js is licensed for use as follows:
"""
Copyright Node.js contributors. All rights reserved.
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:
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.
"""
This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:
"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
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:
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.
"""

View File

@ -0,0 +1,58 @@
# readable-stream
***Node-core v8.17.0 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream)
[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)
[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/readable-stream.svg)](https://saucelabs.com/u/readable-stream)
```bash
npm install --save readable-stream
```
***Node-core streams for userland***
This package is a mirror of the Streams2 and Streams3 implementations in
Node-core.
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.17.0/docs/api/stream.html).
If you want to guarantee a stable streams base, regardless of what version of
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
As of version 2.0.0 **readable-stream** uses semantic versioning.
# Streams Working Group
`readable-stream` is maintained by the Streams Working Group, which
oversees the development and maintenance of the Streams API within
Node.js. The responsibilities of the Streams Working Group include:
* Addressing stream issues on the Node.js issue tracker.
* Authoring and editing stream documentation within the Node.js project.
* Reviewing changes to stream subclasses within the Node.js project.
* Redirecting changes to streams from the Node.js project to this
project.
* Assisting in the implementation of stream providers within Node.js.
* Recommending versions of `readable-stream` to be included in Node.js.
* Messaging about the future of streams to give the community advance
notice of changes.
<a name="members"></a>
## Team Members
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) &lt;christopher.s.dickinson@gmail.com&gt;
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) &lt;calvin.metcalf@gmail.com&gt;
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) &lt;rod@vagg.org&gt;
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) &lt;newmansam@outlook.com&gt;
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) &lt;mathiasbuus@gmail.com&gt;
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) &lt;d@domenic.me&gt;
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) &lt;matteo.collina@gmail.com&gt;
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) &lt;shestak.irina@gmail.com&gt;

View File

@ -0,0 +1,60 @@
# streams WG Meeting 2015-01-30
## Links
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
## Agenda
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
## Minutes
### adopt a charter
* group: +1's all around
### What versioning scheme should be adopted?
* group: +1s 3.0.0
* domenic+group: pulling in patches from other sources where appropriate
* mikeal: version independently, suggesting versions for io.js
* mikeal+domenic: work with TC to notify in advance of changes
simpler stream creation
### streamline creation of streams
* sam: streamline creation of streams
* domenic: nice simple solution posted
but, we lose the opportunity to change the model
may not be backwards incompatible (double check keys)
**action item:** domenic will check
### remove implicit flowing of streams on(data)
* add isFlowing / isPaused
* mikeal: worrying that were documenting polyfill methods confuses users
* domenic: more reflective API is probably good, with warning labels for users
* new section for mad scientists (reflective stream access)
* calvin: name the “third state”
* mikeal: maybe borrow the name from whatwg?
* domenic: were missing the “third state”
* consensus: kind of difficult to name the third state
* mikeal: figure out differences in states / compat
* mathias: always flow on data eliminates third state
* explore what it breaks
**action items:**
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
* ask rod/build for infrastructure
* **chris**: explore the “flow on data” approach
* add isPaused/isFlowing
* add new docs section
* move isPaused to that section

View File

@ -0,0 +1 @@
module.exports = require('./lib/_stream_duplex.js');

View File

@ -0,0 +1 @@
module.exports = require('./readable').Duplex

View File

@ -0,0 +1,131 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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:
//
// 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.
// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
// Writable.
'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
/*<replacement>*/
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
keys.push(key);
}return keys;
};
/*</replacement>*/
module.exports = Duplex;
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
var Readable = require('./_stream_readable');
var Writable = require('./_stream_writable');
util.inherits(Duplex, Readable);
{
// avoid scope creep, the keys array can then be collected
var keys = objectKeys(Writable.prototype);
for (var v = 0; v < keys.length; v++) {
var method = keys[v];
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
}
}
function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
Readable.call(this, options);
Writable.call(this, options);
if (options && options.readable === false) this.readable = false;
if (options && options.writable === false) this.writable = false;
this.allowHalfOpen = true;
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
this.once('end', onend);
}
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._writableState.highWaterMark;
}
});
// the no-half-open enforcer
function onend() {
// if we allow half-open state, or if the writable side ended,
// then we're ok.
if (this.allowHalfOpen || this._writableState.ended) return;
// no more data can be written.
// But allow more writes to happen in this tick.
pna.nextTick(onEndNT, this);
}
function onEndNT(self) {
self.end();
}
Object.defineProperty(Duplex.prototype, 'destroyed', {
get: function () {
if (this._readableState === undefined || this._writableState === undefined) {
return false;
}
return this._readableState.destroyed && this._writableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (this._readableState === undefined || this._writableState === undefined) {
return;
}
// backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
});
Duplex.prototype._destroy = function (err, cb) {
this.push(null);
this.end();
pna.nextTick(cb, err);
};

View File

@ -0,0 +1,47 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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:
//
// 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.
// a passthrough stream.
// basically just the most minimal sort of Transform stream.
// Every written chunk gets output as-is.
'use strict';
module.exports = PassThrough;
var Transform = require('./_stream_transform');
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
util.inherits(PassThrough, Transform);
function PassThrough(options) {
if (!(this instanceof PassThrough)) return new PassThrough(options);
Transform.call(this, options);
}
PassThrough.prototype._transform = function (chunk, encoding, cb) {
cb(null, chunk);
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,214 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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:
//
// 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.
// a transform stream is a readable/writable stream where you do
// something with the data. Sometimes it's called a "filter",
// but that's not a great name for it, since that implies a thing where
// some bits pass through, and others are simply ignored. (That would
// be a valid example of a transform, of course.)
//
// While the output is causally related to the input, it's not a
// necessarily symmetric or synchronous transformation. For example,
// a zlib stream might take multiple plain-text writes(), and then
// emit a single compressed chunk some time in the future.
//
// Here's how this works:
//
// The Transform stream has all the aspects of the readable and writable
// stream classes. When you write(chunk), that calls _write(chunk,cb)
// internally, and returns false if there's a lot of pending writes
// buffered up. When you call read(), that calls _read(n) until
// there's enough pending readable data buffered up.
//
// In a transform stream, the written data is placed in a buffer. When
// _read(n) is called, it transforms the queued up data, calling the
// buffered _write cb's as it consumes chunks. If consuming a single
// written chunk would result in multiple output chunks, then the first
// outputted bit calls the readcb, and subsequent chunks just go into
// the read buffer, and will cause it to emit 'readable' if necessary.
//
// This way, back-pressure is actually determined by the reading side,
// since _read has to be called to start processing a new chunk. However,
// a pathological inflate type of transform can cause excessive buffering
// here. For example, imagine a stream where every byte of input is
// interpreted as an integer from 0-255, and then results in that many
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
// 1kb of data being output. In this case, you could write a very small
// amount of input, and end up with a very large amount of output. In
// such a pathological inflating mechanism, there'd be no way to tell
// the system to stop doing the transform. A single 4MB write could
// cause the system to run out of memory.
//
// However, even in such a pathological case, only a single written chunk
// would be consumed, and then the rest would wait (un-transformed) until
// the results of the previous transformed chunk were consumed.
'use strict';
module.exports = Transform;
var Duplex = require('./_stream_duplex');
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
util.inherits(Transform, Duplex);
function afterTransform(er, data) {
var ts = this._transformState;
ts.transforming = false;
var cb = ts.writecb;
if (!cb) {
return this.emit('error', new Error('write callback called multiple times'));
}
ts.writechunk = null;
ts.writecb = null;
if (data != null) // single equals check for both `null` and `undefined`
this.push(data);
cb(er);
var rs = this._readableState;
rs.reading = false;
if (rs.needReadable || rs.length < rs.highWaterMark) {
this._read(rs.highWaterMark);
}
}
function Transform(options) {
if (!(this instanceof Transform)) return new Transform(options);
Duplex.call(this, options);
this._transformState = {
afterTransform: afterTransform.bind(this),
needTransform: false,
transforming: false,
writecb: null,
writechunk: null,
writeencoding: null
};
// start out asking for a readable event once data is transformed.
this._readableState.needReadable = true;
// we have implemented the _read method, and done the other things
// that Readable wants before the first _read call, so unset the
// sync guard flag.
this._readableState.sync = false;
if (options) {
if (typeof options.transform === 'function') this._transform = options.transform;
if (typeof options.flush === 'function') this._flush = options.flush;
}
// When the writable side finishes, then flush out anything remaining.
this.on('prefinish', prefinish);
}
function prefinish() {
var _this = this;
if (typeof this._flush === 'function') {
this._flush(function (er, data) {
done(_this, er, data);
});
} else {
done(this, null, null);
}
}
Transform.prototype.push = function (chunk, encoding) {
this._transformState.needTransform = false;
return Duplex.prototype.push.call(this, chunk, encoding);
};
// This is the part where you do stuff!
// override this function in implementation classes.
// 'chunk' is an input chunk.
//
// Call `push(newChunk)` to pass along transformed output
// to the readable side. You may call 'push' zero or more times.
//
// Call `cb(err)` when you are done with this chunk. If you pass
// an error, then that'll put the hurt on the whole operation. If you
// never call cb(), then you'll never get another chunk.
Transform.prototype._transform = function (chunk, encoding, cb) {
throw new Error('_transform() is not implemented');
};
Transform.prototype._write = function (chunk, encoding, cb) {
var ts = this._transformState;
ts.writecb = cb;
ts.writechunk = chunk;
ts.writeencoding = encoding;
if (!ts.transforming) {
var rs = this._readableState;
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
}
};
// Doesn't matter what the args are here.
// _transform does all the work.
// That we got here means that the readable side wants more data.
Transform.prototype._read = function (n) {
var ts = this._transformState;
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
ts.transforming = true;
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
} else {
// mark that we need a transform, so that any data that comes in
// will get processed, now that we've asked for it.
ts.needTransform = true;
}
};
Transform.prototype._destroy = function (err, cb) {
var _this2 = this;
Duplex.prototype._destroy.call(this, err, function (err2) {
cb(err2);
_this2.emit('close');
});
};
function done(stream, er, data) {
if (er) return stream.emit('error', er);
if (data != null) // single equals check for both `null` and `undefined`
stream.push(data);
// if there's nothing in the write buffer, then that means
// that nothing more will ever be provided
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
return stream.push(null);
}

View File

@ -0,0 +1,685 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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:
//
// 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.
// A bit simpler than readable streams.
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
// the drain event emission and buffering.
'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
module.exports = Writable;
/* <replacement> */
function WriteReq(chunk, encoding, cb) {
this.chunk = chunk;
this.encoding = encoding;
this.callback = cb;
this.next = null;
}
// It seems a linked list but it is not
// there will be only 2 of these for each stream
function CorkedRequest(state) {
var _this = this;
this.next = null;
this.entry = null;
this.finish = function () {
onCorkedFinish(_this, state);
};
}
/* </replacement> */
/*<replacement>*/
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
/*</replacement>*/
/*<replacement>*/
var Duplex;
/*</replacement>*/
Writable.WritableState = WritableState;
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
/*<replacement>*/
var internalUtil = {
deprecate: require('util-deprecate')
};
/*</replacement>*/
/*<replacement>*/
var Stream = require('./internal/streams/stream');
/*</replacement>*/
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
function _uint8ArrayToBuffer(chunk) {
return Buffer.from(chunk);
}
function _isUint8Array(obj) {
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}
/*</replacement>*/
var destroyImpl = require('./internal/streams/destroy');
util.inherits(Writable, Stream);
function nop() {}
function WritableState(options, stream) {
Duplex = Duplex || require('./_stream_duplex');
options = options || {};
// Duplex streams are both readable and writable, but share
// the same options object.
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream.
// These options can be provided separately as readableXXX and writableXXX.
var isDuplex = stream instanceof Duplex;
// object stream flag to indicate whether or not this stream
// contains buffers or objects.
this.objectMode = !!options.objectMode;
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
// the point at which write() starts returning false
// Note: 0 is a valid value, means that we always return false if
// the entire buffer is not flushed immediately on write()
var hwm = options.highWaterMark;
var writableHwm = options.writableHighWaterMark;
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
// cast to ints.
this.highWaterMark = Math.floor(this.highWaterMark);
// if _final has been called
this.finalCalled = false;
// drain event flag.
this.needDrain = false;
// at the start of calling end()
this.ending = false;
// when end() has been called, and returned
this.ended = false;
// when 'finish' is emitted
this.finished = false;
// has it been destroyed
this.destroyed = false;
// should we decode strings into buffers before passing to _write?
// this is here so that some node-core streams can optimize string
// handling at a lower level.
var noDecode = options.decodeStrings === false;
this.decodeStrings = !noDecode;
// Crypto is kind of old and crusty. Historically, its default string
// encoding is 'binary' so we have to make this configurable.
// Everything else in the universe uses 'utf8', though.
this.defaultEncoding = options.defaultEncoding || 'utf8';
// not an actual buffer we keep track of, but a measurement
// of how much we're waiting to get pushed to some underlying
// socket or file.
this.length = 0;
// a flag to see when we're in the middle of a write.
this.writing = false;
// when true all writes will be buffered until .uncork() call
this.corked = 0;
// a flag to be able to tell if the onwrite cb is called immediately,
// or on a later tick. We set this to true at first, because any
// actions that shouldn't happen until "later" should generally also
// not happen before the first write call.
this.sync = true;
// a flag to know if we're processing previously buffered items, which
// may call the _write() callback in the same tick, so that we don't
// end up in an overlapped onwrite situation.
this.bufferProcessing = false;
// the callback that's passed to _write(chunk,cb)
this.onwrite = function (er) {
onwrite(stream, er);
};
// the callback that the user supplies to write(chunk,encoding,cb)
this.writecb = null;
// the amount that is being written when _write is called.
this.writelen = 0;
this.bufferedRequest = null;
this.lastBufferedRequest = null;
// number of pending user-supplied write callbacks
// this must be 0 before 'finish' can be emitted
this.pendingcb = 0;
// emit prefinish if the only thing we're waiting for is _write cbs
// This is relevant for synchronous Transform streams
this.prefinished = false;
// True if the error was already emitted and should not be thrown again
this.errorEmitted = false;
// count buffered requests
this.bufferedRequestCount = 0;
// allocate the first CorkedRequest, there is always
// one allocated and free to use, and we maintain at most two
this.corkedRequestsFree = new CorkedRequest(this);
}
WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest;
var out = [];
while (current) {
out.push(current);
current = current.next;
}
return out;
};
(function () {
try {
Object.defineProperty(WritableState.prototype, 'buffer', {
get: internalUtil.deprecate(function () {
return this.getBuffer();
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
});
} catch (_) {}
})();
// Test _writableState for inheritance to account for Duplex streams,
// whose prototype chain only points to Readable.
var realHasInstance;
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
realHasInstance = Function.prototype[Symbol.hasInstance];
Object.defineProperty(Writable, Symbol.hasInstance, {
value: function (object) {
if (realHasInstance.call(this, object)) return true;
if (this !== Writable) return false;
return object && object._writableState instanceof WritableState;
}
});
} else {
realHasInstance = function (object) {
return object instanceof this;
};
}
function Writable(options) {
Duplex = Duplex || require('./_stream_duplex');
// Writable ctor is applied to Duplexes, too.
// `realHasInstance` is necessary because using plain `instanceof`
// would return false, as no `_writableState` property is attached.
// Trying to use the custom `instanceof` for Writable here will also break the
// Node.js LazyTransform implementation, which has a non-trivial getter for
// `_writableState` that would lead to infinite recursion.
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
return new Writable(options);
}
this._writableState = new WritableState(options, this);
// legacy.
this.writable = true;
if (options) {
if (typeof options.write === 'function') this._write = options.write;
if (typeof options.writev === 'function') this._writev = options.writev;
if (typeof options.destroy === 'function') this._destroy = options.destroy;
if (typeof options.final === 'function') this._final = options.final;
}
Stream.call(this);
}
// Otherwise people can pipe Writable streams, which is just wrong.
Writable.prototype.pipe = function () {
this.emit('error', new Error('Cannot pipe, not readable'));
};
function writeAfterEnd(stream, cb) {
var er = new Error('write after end');
// TODO: defer error events consistently everywhere, not just the cb
stream.emit('error', er);
pna.nextTick(cb, er);
}
// Checks that a user-supplied chunk is valid, especially for the particular
// mode the stream is in. Currently this means that `null` is never accepted
// and undefined/non-string values are only allowed in object mode.
function validChunk(stream, state, chunk, cb) {
var valid = true;
var er = false;
if (chunk === null) {
er = new TypeError('May not write null values to stream');
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
er = new TypeError('Invalid non-string/buffer chunk');
}
if (er) {
stream.emit('error', er);
pna.nextTick(cb, er);
valid = false;
}
return valid;
}
Writable.prototype.write = function (chunk, encoding, cb) {
var state = this._writableState;
var ret = false;
var isBuf = !state.objectMode && _isUint8Array(chunk);
if (isBuf && !Buffer.isBuffer(chunk)) {
chunk = _uint8ArrayToBuffer(chunk);
}
if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
if (typeof cb !== 'function') cb = nop;
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
state.pendingcb++;
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
}
return ret;
};
Writable.prototype.cork = function () {
var state = this._writableState;
state.corked++;
};
Writable.prototype.uncork = function () {
var state = this._writableState;
if (state.corked) {
state.corked--;
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
}
};
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
// node::ParseEncoding() requires lower case.
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
this._writableState.defaultEncoding = encoding;
return this;
};
function decodeChunk(state, chunk, encoding) {
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
chunk = Buffer.from(chunk, encoding);
}
return chunk;
}
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._writableState.highWaterMark;
}
});
// if we're already writing something, then just put this
// in the queue, and wait our turn. Otherwise, call _write
// If we return false, then we need a drain event, so set that flag.
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
if (!isBuf) {
var newChunk = decodeChunk(state, chunk, encoding);
if (chunk !== newChunk) {
isBuf = true;
encoding = 'buffer';
chunk = newChunk;
}
}
var len = state.objectMode ? 1 : chunk.length;
state.length += len;
var ret = state.length < state.highWaterMark;
// we must ensure that previous needDrain will not be reset to false.
if (!ret) state.needDrain = true;
if (state.writing || state.corked) {
var last = state.lastBufferedRequest;
state.lastBufferedRequest = {
chunk: chunk,
encoding: encoding,
isBuf: isBuf,
callback: cb,
next: null
};
if (last) {
last.next = state.lastBufferedRequest;
} else {
state.bufferedRequest = state.lastBufferedRequest;
}
state.bufferedRequestCount += 1;
} else {
doWrite(stream, state, false, len, chunk, encoding, cb);
}
return ret;
}
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
state.writelen = len;
state.writecb = cb;
state.writing = true;
state.sync = true;
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
state.sync = false;
}
function onwriteError(stream, state, sync, er, cb) {
--state.pendingcb;
if (sync) {
// defer the callback if we are being called synchronously
// to avoid piling up things on the stack
pna.nextTick(cb, er);
// this can emit finish, and it will always happen
// after error
pna.nextTick(finishMaybe, stream, state);
stream._writableState.errorEmitted = true;
stream.emit('error', er);
} else {
// the caller expect this to happen before if
// it is async
cb(er);
stream._writableState.errorEmitted = true;
stream.emit('error', er);
// this can emit finish, but finish must
// always follow error
finishMaybe(stream, state);
}
}
function onwriteStateUpdate(state) {
state.writing = false;
state.writecb = null;
state.length -= state.writelen;
state.writelen = 0;
}
function onwrite(stream, er) {
var state = stream._writableState;
var sync = state.sync;
var cb = state.writecb;
onwriteStateUpdate(state);
if (er) onwriteError(stream, state, sync, er, cb);else {
// Check if we're actually ready to finish, but don't emit yet
var finished = needFinish(state);
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
clearBuffer(stream, state);
}
if (sync) {
/*<replacement>*/
asyncWrite(afterWrite, stream, state, finished, cb);
/*</replacement>*/
} else {
afterWrite(stream, state, finished, cb);
}
}
}
function afterWrite(stream, state, finished, cb) {
if (!finished) onwriteDrain(stream, state);
state.pendingcb--;
cb();
finishMaybe(stream, state);
}
// Must force callback to be called on nextTick, so that we don't
// emit 'drain' before the write() consumer gets the 'false' return
// value, and has a chance to attach a 'drain' listener.
function onwriteDrain(stream, state) {
if (state.length === 0 && state.needDrain) {
state.needDrain = false;
stream.emit('drain');
}
}
// if there's something in the buffer waiting, then process it
function clearBuffer(stream, state) {
state.bufferProcessing = true;
var entry = state.bufferedRequest;
if (stream._writev && entry && entry.next) {
// Fast case, write everything using _writev()
var l = state.bufferedRequestCount;
var buffer = new Array(l);
var holder = state.corkedRequestsFree;
holder.entry = entry;
var count = 0;
var allBuffers = true;
while (entry) {
buffer[count] = entry;
if (!entry.isBuf) allBuffers = false;
entry = entry.next;
count += 1;
}
buffer.allBuffers = allBuffers;
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
// doWrite is almost always async, defer these to save a bit of time
// as the hot path ends with doWrite
state.pendingcb++;
state.lastBufferedRequest = null;
if (holder.next) {
state.corkedRequestsFree = holder.next;
holder.next = null;
} else {
state.corkedRequestsFree = new CorkedRequest(state);
}
state.bufferedRequestCount = 0;
} else {
// Slow case, write chunks one-by-one
while (entry) {
var chunk = entry.chunk;
var encoding = entry.encoding;
var cb = entry.callback;
var len = state.objectMode ? 1 : chunk.length;
doWrite(stream, state, false, len, chunk, encoding, cb);
entry = entry.next;
state.bufferedRequestCount--;
// if we didn't call the onwrite immediately, then
// it means that we need to wait until it does.
// also, that means that the chunk and cb are currently
// being processed, so move the buffer counter past them.
if (state.writing) {
break;
}
}
if (entry === null) state.lastBufferedRequest = null;
}
state.bufferedRequest = entry;
state.bufferProcessing = false;
}
Writable.prototype._write = function (chunk, encoding, cb) {
cb(new Error('_write() is not implemented'));
};
Writable.prototype._writev = null;
Writable.prototype.end = function (chunk, encoding, cb) {
var state = this._writableState;
if (typeof chunk === 'function') {
cb = chunk;
chunk = null;
encoding = null;
} else if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
// .end() fully uncorks
if (state.corked) {
state.corked = 1;
this.uncork();
}
// ignore unnecessary end() calls.
if (!state.ending) endWritable(this, state, cb);
};
function needFinish(state) {
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
}
function callFinal(stream, state) {
stream._final(function (err) {
state.pendingcb--;
if (err) {
stream.emit('error', err);
}
state.prefinished = true;
stream.emit('prefinish');
finishMaybe(stream, state);
});
}
function prefinish(stream, state) {
if (!state.prefinished && !state.finalCalled) {
if (typeof stream._final === 'function') {
state.pendingcb++;
state.finalCalled = true;
pna.nextTick(callFinal, stream, state);
} else {
state.prefinished = true;
stream.emit('prefinish');
}
}
}
function finishMaybe(stream, state) {
var need = needFinish(state);
if (need) {
prefinish(stream, state);
if (state.pendingcb === 0) {
state.finished = true;
stream.emit('finish');
}
}
return need;
}
function endWritable(stream, state, cb) {
state.ending = true;
finishMaybe(stream, state);
if (cb) {
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
}
state.ended = true;
stream.writable = false;
}
function onCorkedFinish(corkReq, state, err) {
var entry = corkReq.entry;
corkReq.entry = null;
while (entry) {
var cb = entry.callback;
state.pendingcb--;
cb(err);
entry = entry.next;
}
// reuse the free corkReq.
state.corkedRequestsFree.next = corkReq;
}
Object.defineProperty(Writable.prototype, 'destroyed', {
get: function () {
if (this._writableState === undefined) {
return false;
}
return this._writableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (!this._writableState) {
return;
}
// backward compatibility, the user is explicitly
// managing destroyed
this._writableState.destroyed = value;
}
});
Writable.prototype.destroy = destroyImpl.destroy;
Writable.prototype._undestroy = destroyImpl.undestroy;
Writable.prototype._destroy = function (err, cb) {
this.end();
cb(err);
};

View File

@ -0,0 +1,78 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Buffer = require('safe-buffer').Buffer;
var util = require('util');
function copyBuffer(src, target, offset) {
src.copy(target, offset);
}
module.exports = function () {
function BufferList() {
_classCallCheck(this, BufferList);
this.head = null;
this.tail = null;
this.length = 0;
}
BufferList.prototype.push = function push(v) {
var entry = { data: v, next: null };
if (this.length > 0) this.tail.next = entry;else this.head = entry;
this.tail = entry;
++this.length;
};
BufferList.prototype.unshift = function unshift(v) {
var entry = { data: v, next: this.head };
if (this.length === 0) this.tail = entry;
this.head = entry;
++this.length;
};
BufferList.prototype.shift = function shift() {
if (this.length === 0) return;
var ret = this.head.data;
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
--this.length;
return ret;
};
BufferList.prototype.clear = function clear() {
this.head = this.tail = null;
this.length = 0;
};
BufferList.prototype.join = function join(s) {
if (this.length === 0) return '';
var p = this.head;
var ret = '' + p.data;
while (p = p.next) {
ret += s + p.data;
}return ret;
};
BufferList.prototype.concat = function concat(n) {
if (this.length === 0) return Buffer.alloc(0);
var ret = Buffer.allocUnsafe(n >>> 0);
var p = this.head;
var i = 0;
while (p) {
copyBuffer(p.data, ret, i);
i += p.data.length;
p = p.next;
}
return ret;
};
return BufferList;
}();
if (util && util.inspect && util.inspect.custom) {
module.exports.prototype[util.inspect.custom] = function () {
var obj = util.inspect({ length: this.length });
return this.constructor.name + ' ' + obj;
};
}

View File

@ -0,0 +1,84 @@
'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
// undocumented cb() API, needed for core, not for public API
function destroy(err, cb) {
var _this = this;
var readableDestroyed = this._readableState && this._readableState.destroyed;
var writableDestroyed = this._writableState && this._writableState.destroyed;
if (readableDestroyed || writableDestroyed) {
if (cb) {
cb(err);
} else if (err) {
if (!this._writableState) {
pna.nextTick(emitErrorNT, this, err);
} else if (!this._writableState.errorEmitted) {
this._writableState.errorEmitted = true;
pna.nextTick(emitErrorNT, this, err);
}
}
return this;
}
// we set destroyed to true before firing error callbacks in order
// to make it re-entrance safe in case destroy() is called within callbacks
if (this._readableState) {
this._readableState.destroyed = true;
}
// if this is a duplex stream mark the writable part as destroyed as well
if (this._writableState) {
this._writableState.destroyed = true;
}
this._destroy(err || null, function (err) {
if (!cb && err) {
if (!_this._writableState) {
pna.nextTick(emitErrorNT, _this, err);
} else if (!_this._writableState.errorEmitted) {
_this._writableState.errorEmitted = true;
pna.nextTick(emitErrorNT, _this, err);
}
} else if (cb) {
cb(err);
}
});
return this;
}
function undestroy() {
if (this._readableState) {
this._readableState.destroyed = false;
this._readableState.reading = false;
this._readableState.ended = false;
this._readableState.endEmitted = false;
}
if (this._writableState) {
this._writableState.destroyed = false;
this._writableState.ended = false;
this._writableState.ending = false;
this._writableState.finalCalled = false;
this._writableState.prefinished = false;
this._writableState.finished = false;
this._writableState.errorEmitted = false;
}
}
function emitErrorNT(self, err) {
self.emit('error', err);
}
module.exports = {
destroy: destroy,
undestroy: undestroy
};

View File

@ -0,0 +1 @@
module.exports = require('events').EventEmitter;

View File

@ -0,0 +1 @@
module.exports = require('stream');

View File

@ -0,0 +1,52 @@
{
"name": "readable-stream",
"version": "2.3.8",
"description": "Streams3, a user-land copy of the stream library from Node.js",
"main": "readable.js",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
},
"devDependencies": {
"assert": "^1.4.0",
"babel-polyfill": "^6.9.1",
"buffer": "^4.9.0",
"lolex": "^2.3.2",
"nyc": "^6.4.0",
"tap": "^0.7.0",
"tape": "^4.8.0"
},
"scripts": {
"test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js",
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
"cover": "nyc npm test",
"report": "nyc report --reporter=lcov"
},
"repository": {
"type": "git",
"url": "git://github.com/nodejs/readable-stream"
},
"keywords": [
"readable",
"stream",
"pipe"
],
"browser": {
"util": false,
"./readable.js": "./readable-browser.js",
"./writable.js": "./writable-browser.js",
"./duplex.js": "./duplex-browser.js",
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
},
"nyc": {
"include": [
"lib/**.js"
]
},
"license": "MIT"
}

View File

@ -0,0 +1 @@
module.exports = require('./readable').PassThrough

View File

@ -0,0 +1,7 @@
exports = module.exports = require('./lib/_stream_readable.js');
exports.Stream = exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');

View File

@ -0,0 +1,19 @@
var Stream = require('stream');
if (process.env.READABLE_STREAM === 'disable' && Stream) {
module.exports = Stream;
exports = module.exports = Stream.Readable;
exports.Readable = Stream.Readable;
exports.Writable = Stream.Writable;
exports.Duplex = Stream.Duplex;
exports.Transform = Stream.Transform;
exports.PassThrough = Stream.PassThrough;
exports.Stream = Stream;
} else {
exports = module.exports = require('./lib/_stream_readable.js');
exports.Stream = Stream || exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');
}

View File

@ -0,0 +1 @@
module.exports = require('./readable').Transform

View File

@ -0,0 +1 @@
module.exports = require('./lib/_stream_writable.js');

View File

@ -0,0 +1,8 @@
var Stream = require("stream")
var Writable = require("./lib/_stream_writable.js")
if (process.env.READABLE_STREAM === 'disable') {
module.exports = Stream && Stream.Writable || Writable
} else {
module.exports = Writable
}

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Feross Aboukhadijeh
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:
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.

View File

@ -0,0 +1,584 @@
# safe-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[travis-image]: https://img.shields.io/travis/feross/safe-buffer/master.svg
[travis-url]: https://travis-ci.org/feross/safe-buffer
[npm-image]: https://img.shields.io/npm/v/safe-buffer.svg
[npm-url]: https://npmjs.org/package/safe-buffer
[downloads-image]: https://img.shields.io/npm/dm/safe-buffer.svg
[downloads-url]: https://npmjs.org/package/safe-buffer
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com
#### Safer Node.js Buffer API
**Use the new Node.js Buffer APIs (`Buffer.from`, `Buffer.alloc`,
`Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`) in all versions of Node.js.**
**Uses the built-in implementation when available.**
## install
```
npm install safe-buffer
```
## usage
The goal of this package is to provide a safe replacement for the node.js `Buffer`.
It's a drop-in replacement for `Buffer`. You can use it by adding one `require` line to
the top of your node.js modules:
```js
var Buffer = require('safe-buffer').Buffer
// Existing buffer code will continue to work without issues:
new Buffer('hey', 'utf8')
new Buffer([1, 2, 3], 'utf8')
new Buffer(obj)
new Buffer(16) // create an uninitialized buffer (potentially unsafe)
// But you can use these new explicit APIs to make clear what you want:
Buffer.from('hey', 'utf8') // convert from many types to a Buffer
Buffer.alloc(16) // create a zero-filled buffer (safe)
Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe)
```
## api
### Class Method: Buffer.from(array)
<!-- YAML
added: v3.0.0
-->
* `array` {Array}
Allocates a new `Buffer` using an `array` of octets.
```js
const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
// creates a new Buffer containing ASCII bytes
// ['b','u','f','f','e','r']
```
A `TypeError` will be thrown if `array` is not an `Array`.
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
<!-- YAML
added: v5.10.0
-->
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
a `new ArrayBuffer()`
* `byteOffset` {Number} Default: `0`
* `length` {Number} Default: `arrayBuffer.length - byteOffset`
When passed a reference to the `.buffer` property of a `TypedArray` instance,
the newly created `Buffer` will share the same allocated memory as the
TypedArray.
```js
const arr = new Uint16Array(2);
arr[0] = 5000;
arr[1] = 4000;
const buf = Buffer.from(arr.buffer); // shares the memory with arr;
console.log(buf);
// Prints: <Buffer 88 13 a0 0f>
// changing the TypedArray changes the Buffer also
arr[1] = 6000;
console.log(buf);
// Prints: <Buffer 88 13 70 17>
```
The optional `byteOffset` and `length` arguments specify a memory range within
the `arrayBuffer` that will be shared by the `Buffer`.
```js
const ab = new ArrayBuffer(10);
const buf = Buffer.from(ab, 0, 2);
console.log(buf.length);
// Prints: 2
```
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
### Class Method: Buffer.from(buffer)
<!-- YAML
added: v3.0.0
-->
* `buffer` {Buffer}
Copies the passed `buffer` data onto a new `Buffer` instance.
```js
const buf1 = Buffer.from('buffer');
const buf2 = Buffer.from(buf1);
buf1[0] = 0x61;
console.log(buf1.toString());
// 'auffer'
console.log(buf2.toString());
// 'buffer' (copy is not changed)
```
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
### Class Method: Buffer.from(str[, encoding])
<!-- YAML
added: v5.10.0
-->
* `str` {String} String to encode.
* `encoding` {String} Encoding to use, Default: `'utf8'`
Creates a new `Buffer` containing the given JavaScript string `str`. If
provided, the `encoding` parameter identifies the character encoding.
If not provided, `encoding` defaults to `'utf8'`.
```js
const buf1 = Buffer.from('this is a tést');
console.log(buf1.toString());
// prints: this is a tést
console.log(buf1.toString('ascii'));
// prints: this is a tC)st
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
console.log(buf2.toString());
// prints: this is a tést
```
A `TypeError` will be thrown if `str` is not a string.
### Class Method: Buffer.alloc(size[, fill[, encoding]])
<!-- YAML
added: v5.10.0
-->
* `size` {Number}
* `fill` {Value} Default: `undefined`
* `encoding` {String} Default: `utf8`
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
`Buffer` will be *zero-filled*.
```js
const buf = Buffer.alloc(5);
console.log(buf);
// <Buffer 00 00 00 00 00>
```
The `size` must be less than or equal to the value of
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
be created if a `size` less than or equal to 0 is specified.
If `fill` is specified, the allocated `Buffer` will be initialized by calling
`buf.fill(fill)`. See [`buf.fill()`][] for more information.
```js
const buf = Buffer.alloc(5, 'a');
console.log(buf);
// <Buffer 61 61 61 61 61>
```
If both `fill` and `encoding` are specified, the allocated `Buffer` will be
initialized by calling `buf.fill(fill, encoding)`. For example:
```js
const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
console.log(buf);
// <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
```
Calling `Buffer.alloc(size)` can be significantly slower than the alternative
`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance
contents will *never contain sensitive data*.
A `TypeError` will be thrown if `size` is not a number.
### Class Method: Buffer.allocUnsafe(size)
<!-- YAML
added: v5.10.0
-->
* `size` {Number}
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
thrown. A zero-length Buffer will be created if a `size` less than or equal to
0 is specified.
The underlying memory for `Buffer` instances created in this way is *not
initialized*. The contents of the newly created `Buffer` are unknown and
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
`Buffer` instances to zeroes.
```js
const buf = Buffer.allocUnsafe(5);
console.log(buf);
// <Buffer 78 e0 82 02 01>
// (octets will be different, every time)
buf.fill(0);
console.log(buf);
// <Buffer 00 00 00 00 00>
```
A `TypeError` will be thrown if `size` is not a number.
Note that the `Buffer` module pre-allocates an internal `Buffer` instance of
size `Buffer.poolSize` that is used as a pool for the fast allocation of new
`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the deprecated
`new Buffer(size)` constructor) only when `size` is less than or equal to
`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default
value of `Buffer.poolSize` is `8192` but can be modified.
Use of this pre-allocated internal memory pool is a key difference between
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer
pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The
difference is subtle but can be important when an application requires the
additional performance that `Buffer.allocUnsafe(size)` provides.
### Class Method: Buffer.allocUnsafeSlow(size)
<!-- YAML
added: v5.10.0
-->
* `size` {Number}
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
`size` must be less than or equal to the value of
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
be created if a `size` less than or equal to 0 is specified.
The underlying memory for `Buffer` instances created in this way is *not
initialized*. The contents of the newly created `Buffer` are unknown and
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
`Buffer` instances to zeroes.
When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
allocations under 4KB are, by default, sliced from a single pre-allocated
`Buffer`. This allows applications to avoid the garbage collection overhead of
creating many individually allocated Buffers. This approach improves both
performance and memory usage by eliminating the need to track and cleanup as
many `Persistent` objects.
However, in the case where a developer may need to retain a small chunk of
memory from a pool for an indeterminate amount of time, it may be appropriate
to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then
copy out the relevant bits.
```js
// need to keep around a few small chunks of memory
const store = [];
socket.on('readable', () => {
const data = socket.read();
// allocate for retained data
const sb = Buffer.allocUnsafeSlow(10);
// copy the data into the new allocation
data.copy(sb, 0, 0, 10);
store.push(sb);
});
```
Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after*
a developer has observed undue memory retention in their applications.
A `TypeError` will be thrown if `size` is not a number.
### All the Rest
The rest of the `Buffer` API is exactly the same as in node.js.
[See the docs](https://nodejs.org/api/buffer.html).
## Related links
- [Node.js issue: Buffer(number) is unsafe](https://github.com/nodejs/node/issues/4660)
- [Node.js Enhancement Proposal: Buffer.from/Buffer.alloc/Buffer.zalloc/Buffer() soft-deprecate](https://github.com/nodejs/node-eps/pull/4)
## Why is `Buffer` unsafe?
Today, the node.js `Buffer` constructor is overloaded to handle many different argument
types like `String`, `Array`, `Object`, `TypedArrayView` (`Uint8Array`, etc.),
`ArrayBuffer`, and also `Number`.
The API is optimized for convenience: you can throw any type at it, and it will try to do
what you want.
Because the Buffer constructor is so powerful, you often see code like this:
```js
// Convert UTF-8 strings to hex
function toHex (str) {
return new Buffer(str).toString('hex')
}
```
***But what happens if `toHex` is called with a `Number` argument?***
### Remote Memory Disclosure
If an attacker can make your program call the `Buffer` constructor with a `Number`
argument, then they can make it allocate uninitialized memory from the node.js process.
This could potentially disclose TLS private keys, user data, or database passwords.
When the `Buffer` constructor is passed a `Number` argument, it returns an
**UNINITIALIZED** block of memory of the specified `size`. When you create a `Buffer` like
this, you **MUST** overwrite the contents before returning it to the user.
From the [node.js docs](https://nodejs.org/api/buffer.html#buffer_new_buffer_size):
> `new Buffer(size)`
>
> - `size` Number
>
> The underlying memory for `Buffer` instances created in this way is not initialized.
> **The contents of a newly created `Buffer` are unknown and could contain sensitive
> data.** Use `buf.fill(0)` to initialize a Buffer to zeroes.
(Emphasis our own.)
Whenever the programmer intended to create an uninitialized `Buffer` you often see code
like this:
```js
var buf = new Buffer(16)
// Immediately overwrite the uninitialized buffer with data from another buffer
for (var i = 0; i < buf.length; i++) {
buf[i] = otherBuf[i]
}
```
### Would this ever be a problem in real code?
Yes. It's surprisingly common to forget to check the type of your variables in a
dynamically-typed language like JavaScript.
Usually the consequences of assuming the wrong type is that your program crashes with an
uncaught exception. But the failure mode for forgetting to check the type of arguments to
the `Buffer` constructor is more catastrophic.
Here's an example of a vulnerable service that takes a JSON payload and converts it to
hex:
```js
// Take a JSON payload {str: "some string"} and convert it to hex
var server = http.createServer(function (req, res) {
var data = ''
req.setEncoding('utf8')
req.on('data', function (chunk) {
data += chunk
})
req.on('end', function () {
var body = JSON.parse(data)
res.end(new Buffer(body.str).toString('hex'))
})
})
server.listen(8080)
```
In this example, an http client just has to send:
```json
{
"str": 1000
}
```
and it will get back 1,000 bytes of uninitialized memory from the server.
This is a very serious bug. It's similar in severity to the
[the Heartbleed bug](http://heartbleed.com/) that allowed disclosure of OpenSSL process
memory by remote attackers.
### Which real-world packages were vulnerable?
#### [`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht)
[Mathias Buus](https://github.com/mafintosh) and I
([Feross Aboukhadijeh](http://feross.org/)) found this issue in one of our own packages,
[`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht). The bug would allow
anyone on the internet to send a series of messages to a user of `bittorrent-dht` and get
them to reveal 20 bytes at a time of uninitialized memory from the node.js process.
Here's
[the commit](https://github.com/feross/bittorrent-dht/commit/6c7da04025d5633699800a99ec3fbadf70ad35b8)
that fixed it. We released a new fixed version, created a
[Node Security Project disclosure](https://nodesecurity.io/advisories/68), and deprecated all
vulnerable versions on npm so users will get a warning to upgrade to a newer version.
#### [`ws`](https://www.npmjs.com/package/ws)
That got us wondering if there were other vulnerable packages. Sure enough, within a short
period of time, we found the same issue in [`ws`](https://www.npmjs.com/package/ws), the
most popular WebSocket implementation in node.js.
If certain APIs were called with `Number` parameters instead of `String` or `Buffer` as
expected, then uninitialized server memory would be disclosed to the remote peer.
These were the vulnerable methods:
```js
socket.send(number)
socket.ping(number)
socket.pong(number)
```
Here's a vulnerable socket server with some echo functionality:
```js
server.on('connection', function (socket) {
socket.on('message', function (message) {
message = JSON.parse(message)
if (message.type === 'echo') {
socket.send(message.data) // send back the user's message
}
})
})
```
`socket.send(number)` called on the server, will disclose server memory.
Here's [the release](https://github.com/websockets/ws/releases/tag/1.0.1) where the issue
was fixed, with a more detailed explanation. Props to
[Arnout Kazemier](https://github.com/3rd-Eden) for the quick fix. Here's the
[Node Security Project disclosure](https://nodesecurity.io/advisories/67).
### What's the solution?
It's important that node.js offers a fast way to get memory otherwise performance-critical
applications would needlessly get a lot slower.
But we need a better way to *signal our intent* as programmers. **When we want
uninitialized memory, we should request it explicitly.**
Sensitive functionality should not be packed into a developer-friendly API that loosely
accepts many different types. This type of API encourages the lazy practice of passing
variables in without checking the type very carefully.
#### A new API: `Buffer.allocUnsafe(number)`
The functionality of creating buffers with uninitialized memory should be part of another
API. We propose `Buffer.allocUnsafe(number)`. This way, it's not part of an API that
frequently gets user input of all sorts of different types passed into it.
```js
var buf = Buffer.allocUnsafe(16) // careful, uninitialized memory!
// Immediately overwrite the uninitialized buffer with data from another buffer
for (var i = 0; i < buf.length; i++) {
buf[i] = otherBuf[i]
}
```
### How do we fix node.js core?
We sent [a PR to node.js core](https://github.com/nodejs/node/pull/4514) (merged as
`semver-major`) which defends against one case:
```js
var str = 16
new Buffer(str, 'utf8')
```
In this situation, it's implied that the programmer intended the first argument to be a
string, since they passed an encoding as a second argument. Today, node.js will allocate
uninitialized memory in the case of `new Buffer(number, encoding)`, which is probably not
what the programmer intended.
But this is only a partial solution, since if the programmer does `new Buffer(variable)`
(without an `encoding` parameter) there's no way to know what they intended. If `variable`
is sometimes a number, then uninitialized memory will sometimes be returned.
### What's the real long-term fix?
We could deprecate and remove `new Buffer(number)` and use `Buffer.allocUnsafe(number)` when
we need uninitialized memory. But that would break 1000s of packages.
~~We believe the best solution is to:~~
~~1. Change `new Buffer(number)` to return safe, zeroed-out memory~~
~~2. Create a new API for creating uninitialized Buffers. We propose: `Buffer.allocUnsafe(number)`~~
#### Update
We now support adding three new APIs:
- `Buffer.from(value)` - convert from any type to a buffer
- `Buffer.alloc(size)` - create a zero-filled buffer
- `Buffer.allocUnsafe(size)` - create an uninitialized buffer with given size
This solves the core problem that affected `ws` and `bittorrent-dht` which is
`Buffer(variable)` getting tricked into taking a number argument.
This way, existing code continues working and the impact on the npm ecosystem will be
minimal. Over time, npm maintainers can migrate performance-critical code to use
`Buffer.allocUnsafe(number)` instead of `new Buffer(number)`.
### Conclusion
We think there's a serious design issue with the `Buffer` API as it exists today. It
promotes insecure software by putting high-risk functionality into a convenient API
with friendly "developer ergonomics".
This wasn't merely a theoretical exercise because we found the issue in some of the
most popular npm packages.
Fortunately, there's an easy fix that can be applied today. Use `safe-buffer` in place of
`buffer`.
```js
var Buffer = require('safe-buffer').Buffer
```
Eventually, we hope that node.js core can switch to this new, safer behavior. We believe
the impact on the ecosystem would be minimal since it's not a breaking change.
Well-maintained, popular packages would be updated to use `Buffer.alloc` quickly, while
older, insecure packages would magically become safe from this attack vector.
## links
- [Node.js PR: buffer: throw if both length and enc are passed](https://github.com/nodejs/node/pull/4514)
- [Node Security Project disclosure for `ws`](https://nodesecurity.io/advisories/67)
- [Node Security Project disclosure for`bittorrent-dht`](https://nodesecurity.io/advisories/68)
## credit
The original issues in `bittorrent-dht`
([disclosure](https://nodesecurity.io/advisories/68)) and
`ws` ([disclosure](https://nodesecurity.io/advisories/67)) were discovered by
[Mathias Buus](https://github.com/mafintosh) and
[Feross Aboukhadijeh](http://feross.org/).
Thanks to [Adam Baldwin](https://github.com/evilpacket) for helping disclose these issues
and for his work running the [Node Security Project](https://nodesecurity.io/).
Thanks to [John Hiesey](https://github.com/jhiesey) for proofreading this README and
auditing the code.
## license
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org)

View File

@ -0,0 +1,187 @@
declare module "safe-buffer" {
export class Buffer {
length: number
write(string: string, offset?: number, length?: number, encoding?: string): number;
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): { type: 'Buffer', data: any[] };
equals(otherBuffer: Buffer): boolean;
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt8(offset: number, noAssert?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readInt8(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readFloatLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
swap16(): Buffer;
swap32(): Buffer;
swap64(): Buffer;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): this;
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
/**
* Allocates a new buffer containing the given {str}.
*
* @param str String to store in buffer.
* @param encoding encoding to use, optional. Default is 'utf8'
*/
constructor (str: string, encoding?: string);
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
*/
constructor (size: number);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: Uint8Array);
/**
* Produces a Buffer backed by the same allocated memory as
* the given {ArrayBuffer}.
*
*
* @param arrayBuffer The ArrayBuffer with which to share memory.
*/
constructor (arrayBuffer: ArrayBuffer);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: any[]);
/**
* Copies the passed {buffer} data onto a new {Buffer} instance.
*
* @param buffer The buffer to copy.
*/
constructor (buffer: Buffer);
prototype: Buffer;
/**
* Allocates a new Buffer using an {array} of octets.
*
* @param array
*/
static from(array: any[]): Buffer;
/**
* When passed a reference to the .buffer property of a TypedArray instance,
* the newly created Buffer will share the same allocated memory as the TypedArray.
* The optional {byteOffset} and {length} arguments specify a memory range
* within the {arrayBuffer} that will be shared by the Buffer.
*
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
* @param byteOffset
* @param length
*/
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
/**
* Copies the passed {buffer} data onto a new Buffer instance.
*
* @param buffer
*/
static from(buffer: Buffer): Buffer;
/**
* Creates a new Buffer containing the given JavaScript string {str}.
* If provided, the {encoding} parameter identifies the character encoding.
* If not provided, {encoding} defaults to 'utf8'.
*
* @param str
*/
static from(str: string, encoding?: string): Buffer;
/**
* Returns true if {obj} is a Buffer
*
* @param obj object to test.
*/
static isBuffer(obj: any): obj is Buffer;
/**
* Returns true if {encoding} is a valid encoding argument.
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
*
* @param encoding string to test.
*/
static isEncoding(encoding: string): boolean;
/**
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
* This is not the same as String.prototype.length since that returns the number of characters in a string.
*
* @param string string to test.
* @param encoding encoding used to evaluate (defaults to 'utf8')
*/
static byteLength(string: string, encoding?: string): number;
/**
* Returns a buffer which is the result of concatenating all the buffers in the list together.
*
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
* If the list has exactly one item, then the first item of the list is returned.
* If the list has more than one item, then a new Buffer is created.
*
* @param list An array of Buffer objects to concatenate
* @param totalLength Total length of the buffers when concatenated.
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
*/
static concat(list: Buffer[], totalLength?: number): Buffer;
/**
* The same as buf1.compare(buf2).
*/
static compare(buf1: Buffer, buf2: Buffer): number;
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
* If parameter is omitted, buffer will be filled with zeros.
* @param encoding encoding used for call to buf.fill while initalizing
*/
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
/**
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafe(size: number): Buffer;
/**
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafeSlow(size: number): Buffer;
}
}

View File

@ -0,0 +1,62 @@
/* eslint-disable node/no-deprecated-api */
var buffer = require('buffer')
var Buffer = buffer.Buffer
// alternative to using Object.keys for old browsers
function copyProps (src, dst) {
for (var key in src) {
dst[key] = src[key]
}
}
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer
} else {
// Copy properties from require('buffer')
copyProps(buffer, exports)
exports.Buffer = SafeBuffer
}
function SafeBuffer (arg, encodingOrOffset, length) {
return Buffer(arg, encodingOrOffset, length)
}
// Copy static methods from Buffer
copyProps(Buffer, SafeBuffer)
SafeBuffer.from = function (arg, encodingOrOffset, length) {
if (typeof arg === 'number') {
throw new TypeError('Argument must not be a number')
}
return Buffer(arg, encodingOrOffset, length)
}
SafeBuffer.alloc = function (size, fill, encoding) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
var buf = Buffer(size)
if (fill !== undefined) {
if (typeof encoding === 'string') {
buf.fill(fill, encoding)
} else {
buf.fill(fill)
}
} else {
buf.fill(0)
}
return buf
}
SafeBuffer.allocUnsafe = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return Buffer(size)
}
SafeBuffer.allocUnsafeSlow = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return buffer.SlowBuffer(size)
}

View File

@ -0,0 +1,37 @@
{
"name": "safe-buffer",
"description": "Safer Node.js Buffer API",
"version": "5.1.2",
"author": {
"name": "Feross Aboukhadijeh",
"email": "feross@feross.org",
"url": "http://feross.org"
},
"bugs": {
"url": "https://github.com/feross/safe-buffer/issues"
},
"devDependencies": {
"standard": "*",
"tape": "^4.0.0"
},
"homepage": "https://github.com/feross/safe-buffer",
"keywords": [
"buffer",
"buffer allocate",
"node security",
"safe",
"safe-buffer",
"security",
"uninitialized"
],
"license": "MIT",
"main": "index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/feross/safe-buffer.git"
},
"scripts": {
"test": "standard && tape test/*.js"
}
}

View File

@ -0,0 +1,50 @@
sudo: false
language: node_js
before_install:
- npm install -g npm@2
- test $NPM_LEGACY && npm install -g npm@latest-3 || npm install npm -g
notifications:
email: false
matrix:
fast_finish: true
include:
- node_js: '0.8'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.10'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.11'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.12'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 1
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 2
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 3
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 4
env: TASK=test
- node_js: 5
env: TASK=test
- node_js: 6
env: TASK=test
- node_js: 7
env: TASK=test
- node_js: 8
env: TASK=test
- node_js: 9
env: TASK=test

View File

@ -0,0 +1,48 @@
Node.js is licensed for use as follows:
"""
Copyright Node.js contributors. All rights reserved.
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:
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.
"""
This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:
"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
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:
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.
"""

View File

@ -0,0 +1,47 @@
# string_decoder
***Node-core v8.9.4 string_decoder for userland***
[![NPM](https://nodei.co/npm/string_decoder.png?downloads=true&downloadRank=true)](https://nodei.co/npm/string_decoder/)
[![NPM](https://nodei.co/npm-dl/string_decoder.png?&months=6&height=3)](https://nodei.co/npm/string_decoder/)
```bash
npm install --save string_decoder
```
***Node-core string_decoder for userland***
This package is a mirror of the string_decoder implementation in Node-core.
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.9.4/docs/api/).
As of version 1.0.0 **string_decoder** uses semantic versioning.
## Previous versions
Previous version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10.
## Update
The *build/* directory contains a build script that will scrape the source from the [nodejs/node](https://github.com/nodejs/node) repo given a specific Node version.
## Streams Working Group
`string_decoder` is maintained by the Streams Working Group, which
oversees the development and maintenance of the Streams API within
Node.js. The responsibilities of the Streams Working Group include:
* Addressing stream issues on the Node.js issue tracker.
* Authoring and editing stream documentation within the Node.js project.
* Reviewing changes to stream subclasses within the Node.js project.
* Redirecting changes to streams from the Node.js project to this
project.
* Assisting in the implementation of stream providers within Node.js.
* Recommending versions of `readable-stream` to be included in Node.js.
* Messaging about the future of streams to give the community advance
notice of changes.
See [readable-stream](https://github.com/nodejs/readable-stream) for
more details.

View File

@ -0,0 +1,296 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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:
//
// 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.
'use strict';
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
var isEncoding = Buffer.isEncoding || function (encoding) {
encoding = '' + encoding;
switch (encoding && encoding.toLowerCase()) {
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
return true;
default:
return false;
}
};
function _normalizeEncoding(enc) {
if (!enc) return 'utf8';
var retried;
while (true) {
switch (enc) {
case 'utf8':
case 'utf-8':
return 'utf8';
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return 'utf16le';
case 'latin1':
case 'binary':
return 'latin1';
case 'base64':
case 'ascii':
case 'hex':
return enc;
default:
if (retried) return; // undefined
enc = ('' + enc).toLowerCase();
retried = true;
}
}
};
// Do not cache `Buffer.isEncoding` when checking encoding names as some
// modules monkey-patch it to support additional encodings
function normalizeEncoding(enc) {
var nenc = _normalizeEncoding(enc);
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
return nenc || enc;
}
// StringDecoder provides an interface for efficiently splitting a series of
// buffers into a series of JS strings without breaking apart multi-byte
// characters.
exports.StringDecoder = StringDecoder;
function StringDecoder(encoding) {
this.encoding = normalizeEncoding(encoding);
var nb;
switch (this.encoding) {
case 'utf16le':
this.text = utf16Text;
this.end = utf16End;
nb = 4;
break;
case 'utf8':
this.fillLast = utf8FillLast;
nb = 4;
break;
case 'base64':
this.text = base64Text;
this.end = base64End;
nb = 3;
break;
default:
this.write = simpleWrite;
this.end = simpleEnd;
return;
}
this.lastNeed = 0;
this.lastTotal = 0;
this.lastChar = Buffer.allocUnsafe(nb);
}
StringDecoder.prototype.write = function (buf) {
if (buf.length === 0) return '';
var r;
var i;
if (this.lastNeed) {
r = this.fillLast(buf);
if (r === undefined) return '';
i = this.lastNeed;
this.lastNeed = 0;
} else {
i = 0;
}
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
return r || '';
};
StringDecoder.prototype.end = utf8End;
// Returns only complete characters in a Buffer
StringDecoder.prototype.text = utf8Text;
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
StringDecoder.prototype.fillLast = function (buf) {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
this.lastNeed -= buf.length;
};
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
// continuation byte. If an invalid byte is detected, -2 is returned.
function utf8CheckByte(byte) {
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
return byte >> 6 === 0x02 ? -1 : -2;
}
// Checks at most 3 bytes at the end of a Buffer in order to detect an
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
// needed to complete the UTF-8 character (if applicable) are returned.
function utf8CheckIncomplete(self, buf, i) {
var j = buf.length - 1;
if (j < i) return 0;
var nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 1;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 2;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) {
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
}
return nb;
}
return 0;
}
// Validates as many continuation bytes for a multi-byte UTF-8 character as
// needed or are available. If we see a non-continuation byte where we expect
// one, we "replace" the validated continuation bytes we've seen so far with
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
// behavior. The continuation byte check is included three times in the case
// where all of the continuation bytes for a character exist in the same buffer.
// It is also done this way as a slight performance increase instead of using a
// loop.
function utf8CheckExtraBytes(self, buf, p) {
if ((buf[0] & 0xC0) !== 0x80) {
self.lastNeed = 0;
return '\ufffd';
}
if (self.lastNeed > 1 && buf.length > 1) {
if ((buf[1] & 0xC0) !== 0x80) {
self.lastNeed = 1;
return '\ufffd';
}
if (self.lastNeed > 2 && buf.length > 2) {
if ((buf[2] & 0xC0) !== 0x80) {
self.lastNeed = 2;
return '\ufffd';
}
}
}
}
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
function utf8FillLast(buf) {
var p = this.lastTotal - this.lastNeed;
var r = utf8CheckExtraBytes(this, buf, p);
if (r !== undefined) return r;
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, p, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, p, 0, buf.length);
this.lastNeed -= buf.length;
}
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
// partial character, the character's bytes are buffered until the required
// number of bytes are available.
function utf8Text(buf, i) {
var total = utf8CheckIncomplete(this, buf, i);
if (!this.lastNeed) return buf.toString('utf8', i);
this.lastTotal = total;
var end = buf.length - (total - this.lastNeed);
buf.copy(this.lastChar, 0, end);
return buf.toString('utf8', i, end);
}
// For UTF-8, a replacement character is added when ending on a partial
// character.
function utf8End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + '\ufffd';
return r;
}
// UTF-16LE typically needs two bytes per character, but even if we have an even
// number of bytes available, we need to check if we end on a leading/high
// surrogate. In that case, we need to wait for the next two bytes in order to
// decode the last character properly.
function utf16Text(buf, i) {
if ((buf.length - i) % 2 === 0) {
var r = buf.toString('utf16le', i);
if (r) {
var c = r.charCodeAt(r.length - 1);
if (c >= 0xD800 && c <= 0xDBFF) {
this.lastNeed = 2;
this.lastTotal = 4;
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
return r.slice(0, -1);
}
}
return r;
}
this.lastNeed = 1;
this.lastTotal = 2;
this.lastChar[0] = buf[buf.length - 1];
return buf.toString('utf16le', i, buf.length - 1);
}
// For UTF-16LE we do not explicitly append special replacement characters if we
// end on a partial character, we simply let v8 handle that.
function utf16End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) {
var end = this.lastTotal - this.lastNeed;
return r + this.lastChar.toString('utf16le', 0, end);
}
return r;
}
function base64Text(buf, i) {
var n = (buf.length - i) % 3;
if (n === 0) return buf.toString('base64', i);
this.lastNeed = 3 - n;
this.lastTotal = 3;
if (n === 1) {
this.lastChar[0] = buf[buf.length - 1];
} else {
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
}
return buf.toString('base64', i, buf.length - n);
}
function base64End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
return r;
}
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
function simpleWrite(buf) {
return buf.toString(this.encoding);
}
function simpleEnd(buf) {
return buf && buf.length ? this.write(buf) : '';
}

View File

@ -0,0 +1,31 @@
{
"name": "string_decoder",
"version": "1.1.1",
"description": "The string_decoder module from Node core",
"main": "lib/string_decoder.js",
"dependencies": {
"safe-buffer": "~5.1.0"
},
"devDependencies": {
"babel-polyfill": "^6.23.0",
"core-util-is": "^1.0.2",
"inherits": "^2.0.3",
"tap": "~0.4.8"
},
"scripts": {
"test": "tap test/parallel/*.js && node test/verify-dependencies",
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js"
},
"repository": {
"type": "git",
"url": "git://github.com/nodejs/string_decoder.git"
},
"homepage": "https://github.com/nodejs/string_decoder",
"keywords": [
"string",
"decoder",
"browser",
"browserify"
],
"license": "MIT"
}

35
app_vue/node_modules/hpack.js/package.json generated vendored Normal file
View File

@ -0,0 +1,35 @@
{
"name": "hpack.js",
"version": "2.1.6",
"description": "HPACK implementation",
"main": "lib/hpack.js",
"scripts": {
"test": "mocha test/*-test.js"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/indutny/hpack.js.git"
},
"keywords": [
"HPACK",
"HTTP2",
"compress",
"decompress",
"headers"
],
"author": "Fedor Indutny <fedor@indutny.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/indutny/hpack.js/issues"
},
"homepage": "https://github.com/indutny/hpack.js#readme",
"devDependencies": {
"mocha": "^2.2.5"
},
"dependencies": {
"inherits": "^2.0.1",
"obuf": "^1.0.0",
"readable-stream": "^2.0.1",
"wbuf": "^1.1.0"
}
}

136
app_vue/node_modules/hpack.js/test/compressor-test.js generated vendored Normal file
View 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
View 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
View 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
View 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
View 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 ]
]
}
];

309
app_vue/node_modules/hpack.js/tools/gen-huffman.js generated vendored Normal file
View File

@ -0,0 +1,309 @@
var utils = require('./utils');
var table = `
( 0) |11111111|11000 1ff8 [13]
( 1) |11111111|11111111|1011000 7fffd8 [23]
( 2) |11111111|11111111|11111110|0010 fffffe2 [28]
( 3) |11111111|11111111|11111110|0011 fffffe3 [28]
( 4) |11111111|11111111|11111110|0100 fffffe4 [28]
( 5) |11111111|11111111|11111110|0101 fffffe5 [28]
( 6) |11111111|11111111|11111110|0110 fffffe6 [28]
( 7) |11111111|11111111|11111110|0111 fffffe7 [28]
( 8) |11111111|11111111|11111110|1000 fffffe8 [28]
( 9) |11111111|11111111|11101010 ffffea [24]
( 10) |11111111|11111111|11111111|111100 3ffffffc [30]
( 11) |11111111|11111111|11111110|1001 fffffe9 [28]
( 12) |11111111|11111111|11111110|1010 fffffea [28]
( 13) |11111111|11111111|11111111|111101 3ffffffd [30]
( 14) |11111111|11111111|11111110|1011 fffffeb [28]
( 15) |11111111|11111111|11111110|1100 fffffec [28]
( 16) |11111111|11111111|11111110|1101 fffffed [28]
( 17) |11111111|11111111|11111110|1110 fffffee [28]
( 18) |11111111|11111111|11111110|1111 fffffef [28]
( 19) |11111111|11111111|11111111|0000 ffffff0 [28]
( 20) |11111111|11111111|11111111|0001 ffffff1 [28]
( 21) |11111111|11111111|11111111|0010 ffffff2 [28]
( 22) |11111111|11111111|11111111|111110 3ffffffe [30]
( 23) |11111111|11111111|11111111|0011 ffffff3 [28]
( 24) |11111111|11111111|11111111|0100 ffffff4 [28]
( 25) |11111111|11111111|11111111|0101 ffffff5 [28]
( 26) |11111111|11111111|11111111|0110 ffffff6 [28]
( 27) |11111111|11111111|11111111|0111 ffffff7 [28]
( 28) |11111111|11111111|11111111|1000 ffffff8 [28]
( 29) |11111111|11111111|11111111|1001 ffffff9 [28]
( 30) |11111111|11111111|11111111|1010 ffffffa [28]
( 31) |11111111|11111111|11111111|1011 ffffffb [28]
' ' ( 32) |010100 14 [ 6]
'!' ( 33) |11111110|00 3f8 [10]
'"' ( 34) |11111110|01 3f9 [10]
'#' ( 35) |11111111|1010 ffa [12]
'$' ( 36) |11111111|11001 1ff9 [13]
'%' ( 37) |010101 15 [ 6]
'&' ( 38) |11111000 f8 [ 8]
''' ( 39) |11111111|010 7fa [11]
'(' ( 40) |11111110|10 3fa [10]
')' ( 41) |11111110|11 3fb [10]
'*' ( 42) |11111001 f9 [ 8]
'+' ( 43) |11111111|011 7fb [11]
',' ( 44) |11111010 fa [ 8]
'-' ( 45) |010110 16 [ 6]
'.' ( 46) |010111 17 [ 6]
'/' ( 47) |011000 18 [ 6]
'0' ( 48) |00000 0 [ 5]
'1' ( 49) |00001 1 [ 5]
'2' ( 50) |00010 2 [ 5]
'3' ( 51) |011001 19 [ 6]
'4' ( 52) |011010 1a [ 6]
'5' ( 53) |011011 1b [ 6]
'6' ( 54) |011100 1c [ 6]
'7' ( 55) |011101 1d [ 6]
'8' ( 56) |011110 1e [ 6]
'9' ( 57) |011111 1f [ 6]
':' ( 58) |1011100 5c [ 7]
';' ( 59) |11111011 fb [ 8]
'<' ( 60) |11111111|1111100 7ffc [15]
'=' ( 61) |100000 20 [ 6]
'>' ( 62) |11111111|1011 ffb [12]
'?' ( 63) |11111111|00 3fc [10]
'@' ( 64) |11111111|11010 1ffa [13]
'A' ( 65) |100001 21 [ 6]
'B' ( 66) |1011101 5d [ 7]
'C' ( 67) |1011110 5e [ 7]
'D' ( 68) |1011111 5f [ 7]
'E' ( 69) |1100000 60 [ 7]
'F' ( 70) |1100001 61 [ 7]
'G' ( 71) |1100010 62 [ 7]
'H' ( 72) |1100011 63 [ 7]
'I' ( 73) |1100100 64 [ 7]
'J' ( 74) |1100101 65 [ 7]
'K' ( 75) |1100110 66 [ 7]
'L' ( 76) |1100111 67 [ 7]
'M' ( 77) |1101000 68 [ 7]
'N' ( 78) |1101001 69 [ 7]
'O' ( 79) |1101010 6a [ 7]
'P' ( 80) |1101011 6b [ 7]
'Q' ( 81) |1101100 6c [ 7]
'R' ( 82) |1101101 6d [ 7]
'S' ( 83) |1101110 6e [ 7]
'T' ( 84) |1101111 6f [ 7]
'U' ( 85) |1110000 70 [ 7]
'V' ( 86) |1110001 71 [ 7]
'W' ( 87) |1110010 72 [ 7]
'X' ( 88) |11111100 fc [ 8]
'Y' ( 89) |1110011 73 [ 7]
'Z' ( 90) |11111101 fd [ 8]
'[' ( 91) |11111111|11011 1ffb [13]
'\\' ( 92) |11111111|11111110|000 7fff0 [19]
']' ( 93) |11111111|11100 1ffc [13]
'^' ( 94) |11111111|111100 3ffc [14]
'_' ( 95) |100010 22 [ 6]
'\`' ( 96) |11111111|1111101 7ffd [15]
'a' ( 97) |00011 3 [ 5]
'b' ( 98) |100011 23 [ 6]
'c' ( 99) |00100 4 [ 5]
'd' (100) |100100 24 [ 6]
'e' (101) |00101 5 [ 5]
'f' (102) |100101 25 [ 6]
'g' (103) |100110 26 [ 6]
'h' (104) |100111 27 [ 6]
'i' (105) |00110 6 [ 5]
'j' (106) |1110100 74 [ 7]
'k' (107) |1110101 75 [ 7]
'l' (108) |101000 28 [ 6]
'm' (109) |101001 29 [ 6]
'n' (110) |101010 2a [ 6]
'o' (111) |00111 7 [ 5]
'p' (112) |101011 2b [ 6]
'q' (113) |1110110 76 [ 7]
'r' (114) |101100 2c [ 6]
's' (115) |01000 8 [ 5]
't' (116) |01001 9 [ 5]
'u' (117) |101101 2d [ 6]
'v' (118) |1110111 77 [ 7]
'w' (119) |1111000 78 [ 7]
'x' (120) |1111001 79 [ 7]
'y' (121) |1111010 7a [ 7]
'z' (122) |1111011 7b [ 7]
'{' (123) |11111111|1111110 7ffe [15]
'|' (124) |11111111|100 7fc [11]
'}' (125) |11111111|111101 3ffd [14]
'~' (126) |11111111|11101 1ffd [13]
(127) |11111111|11111111|11111111|1100 ffffffc [28]
(128) |11111111|11111110|0110 fffe6 [20]
(129) |11111111|11111111|010010 3fffd2 [22]
(130) |11111111|11111110|0111 fffe7 [20]
(131) |11111111|11111110|1000 fffe8 [20]
(132) |11111111|11111111|010011 3fffd3 [22]
(133) |11111111|11111111|010100 3fffd4 [22]
(134) |11111111|11111111|010101 3fffd5 [22]
(135) |11111111|11111111|1011001 7fffd9 [23]
(136) |11111111|11111111|010110 3fffd6 [22]
(137) |11111111|11111111|1011010 7fffda [23]
(138) |11111111|11111111|1011011 7fffdb [23]
(139) |11111111|11111111|1011100 7fffdc [23]
(140) |11111111|11111111|1011101 7fffdd [23]
(141) |11111111|11111111|1011110 7fffde [23]
(142) |11111111|11111111|11101011 ffffeb [24]
(143) |11111111|11111111|1011111 7fffdf [23]
(144) |11111111|11111111|11101100 ffffec [24]
(145) |11111111|11111111|11101101 ffffed [24]
(146) |11111111|11111111|010111 3fffd7 [22]
(147) |11111111|11111111|1100000 7fffe0 [23]
(148) |11111111|11111111|11101110 ffffee [24]
(149) |11111111|11111111|1100001 7fffe1 [23]
(150) |11111111|11111111|1100010 7fffe2 [23]
(151) |11111111|11111111|1100011 7fffe3 [23]
(152) |11111111|11111111|1100100 7fffe4 [23]
(153) |11111111|11111110|11100 1fffdc [21]
(154) |11111111|11111111|011000 3fffd8 [22]
(155) |11111111|11111111|1100101 7fffe5 [23]
(156) |11111111|11111111|011001 3fffd9 [22]
(157) |11111111|11111111|1100110 7fffe6 [23]
(158) |11111111|11111111|1100111 7fffe7 [23]
(159) |11111111|11111111|11101111 ffffef [24]
(160) |11111111|11111111|011010 3fffda [22]
(161) |11111111|11111110|11101 1fffdd [21]
(162) |11111111|11111110|1001 fffe9 [20]
(163) |11111111|11111111|011011 3fffdb [22]
(164) |11111111|11111111|011100 3fffdc [22]
(165) |11111111|11111111|1101000 7fffe8 [23]
(166) |11111111|11111111|1101001 7fffe9 [23]
(167) |11111111|11111110|11110 1fffde [21]
(168) |11111111|11111111|1101010 7fffea [23]
(169) |11111111|11111111|011101 3fffdd [22]
(170) |11111111|11111111|011110 3fffde [22]
(171) |11111111|11111111|11110000 fffff0 [24]
(172) |11111111|11111110|11111 1fffdf [21]
(173) |11111111|11111111|011111 3fffdf [22]
(174) |11111111|11111111|1101011 7fffeb [23]
(175) |11111111|11111111|1101100 7fffec [23]
(176) |11111111|11111111|00000 1fffe0 [21]
(177) |11111111|11111111|00001 1fffe1 [21]
(178) |11111111|11111111|100000 3fffe0 [22]
(179) |11111111|11111111|00010 1fffe2 [21]
(180) |11111111|11111111|1101101 7fffed [23]
(181) |11111111|11111111|100001 3fffe1 [22]
(182) |11111111|11111111|1101110 7fffee [23]
(183) |11111111|11111111|1101111 7fffef [23]
(184) |11111111|11111110|1010 fffea [20]
(185) |11111111|11111111|100010 3fffe2 [22]
(186) |11111111|11111111|100011 3fffe3 [22]
(187) |11111111|11111111|100100 3fffe4 [22]
(188) |11111111|11111111|1110000 7ffff0 [23]
(189) |11111111|11111111|100101 3fffe5 [22]
(190) |11111111|11111111|100110 3fffe6 [22]
(191) |11111111|11111111|1110001 7ffff1 [23]
(192) |11111111|11111111|11111000|00 3ffffe0 [26]
(193) |11111111|11111111|11111000|01 3ffffe1 [26]
(194) |11111111|11111110|1011 fffeb [20]
(195) |11111111|11111110|001 7fff1 [19]
(196) |11111111|11111111|100111 3fffe7 [22]
(197) |11111111|11111111|1110010 7ffff2 [23]
(198) |11111111|11111111|101000 3fffe8 [22]
(199) |11111111|11111111|11110110|0 1ffffec [25]
(200) |11111111|11111111|11111000|10 3ffffe2 [26]
(201) |11111111|11111111|11111000|11 3ffffe3 [26]
(202) |11111111|11111111|11111001|00 3ffffe4 [26]
(203) |11111111|11111111|11111011|110 7ffffde [27]
(204) |11111111|11111111|11111011|111 7ffffdf [27]
(205) |11111111|11111111|11111001|01 3ffffe5 [26]
(206) |11111111|11111111|11110001 fffff1 [24]
(207) |11111111|11111111|11110110|1 1ffffed [25]
(208) |11111111|11111110|010 7fff2 [19]
(209) |11111111|11111111|00011 1fffe3 [21]
(210) |11111111|11111111|11111001|10 3ffffe6 [26]
(211) |11111111|11111111|11111100|000 7ffffe0 [27]
(212) |11111111|11111111|11111100|001 7ffffe1 [27]
(213) |11111111|11111111|11111001|11 3ffffe7 [26]
(214) |11111111|11111111|11111100|010 7ffffe2 [27]
(215) |11111111|11111111|11110010 fffff2 [24]
(216) |11111111|11111111|00100 1fffe4 [21]
(217) |11111111|11111111|00101 1fffe5 [21]
(218) |11111111|11111111|11111010|00 3ffffe8 [26]
(219) |11111111|11111111|11111010|01 3ffffe9 [26]
(220) |11111111|11111111|11111111|1101 ffffffd [28]
(221) |11111111|11111111|11111100|011 7ffffe3 [27]
(222) |11111111|11111111|11111100|100 7ffffe4 [27]
(223) |11111111|11111111|11111100|101 7ffffe5 [27]
(224) |11111111|11111110|1100 fffec [20]
(225) |11111111|11111111|11110011 fffff3 [24]
(226) |11111111|11111110|1101 fffed [20]
(227) |11111111|11111111|00110 1fffe6 [21]
(228) |11111111|11111111|101001 3fffe9 [22]
(229) |11111111|11111111|00111 1fffe7 [21]
(230) |11111111|11111111|01000 1fffe8 [21]
(231) |11111111|11111111|1110011 7ffff3 [23]
(232) |11111111|11111111|101010 3fffea [22]
(233) |11111111|11111111|101011 3fffeb [22]
(234) |11111111|11111111|11110111|0 1ffffee [25]
(235) |11111111|11111111|11110111|1 1ffffef [25]
(236) |11111111|11111111|11110100 fffff4 [24]
(237) |11111111|11111111|11110101 fffff5 [24]
(238) |11111111|11111111|11111010|10 3ffffea [26]
(239) |11111111|11111111|1110100 7ffff4 [23]
(240) |11111111|11111111|11111010|11 3ffffeb [26]
(241) |11111111|11111111|11111100|110 7ffffe6 [27]
(242) |11111111|11111111|11111011|00 3ffffec [26]
(243) |11111111|11111111|11111011|01 3ffffed [26]
(244) |11111111|11111111|11111100|111 7ffffe7 [27]
(245) |11111111|11111111|11111101|000 7ffffe8 [27]
(246) |11111111|11111111|11111101|001 7ffffe9 [27]
(247) |11111111|11111111|11111101|010 7ffffea [27]
(248) |11111111|11111111|11111101|011 7ffffeb [27]
(249) |11111111|11111111|11111111|1110 ffffffe [28]
(250) |11111111|11111111|11111101|100 7ffffec [27]
(251) |11111111|11111111|11111101|101 7ffffed [27]
(252) |11111111|11111111|11111101|110 7ffffee [27]
(253) |11111111|11111111|11111101|111 7ffffef [27]
(254) |11111111|11111111|11111110|000 7fffff0 [27]
(255) |11111111|11111111|11111011|10 3ffffee [26]
EOS (256) |11111111|11111111|11111111|111111 3fffffff [30]
`;
table = table.split('\n').filter(function(line) {
return line.length > 0;
});
function createNode() {
// See `encodeBits`
var arr = new Array(256);
for (var i = 0; i < arr.length; i++)
arr[i] = 0;
return arr;
}
var decode = createNode();
var encode = createNode();
function encodeBits(bits) {
var num = parseInt(bits, 2);
return num;
}
table.forEach(function(line) {
var match = line.match(/\(\s*([\d]+)\)\s+\|([^\s]+)\s+([^\s]+)/);
var octet = match[1] | 0;
var bits = match[2].split(/\|/g);
var hex = parseInt(match[3], 16);
var node = decode;
var totalLen = 0;
for (var i = 0; i < bits.length - 1; i++) {
var b = encodeBits(bits[i]);
totalLen += bits[i].length;
if (node[b] === 0)
node[b] = createNode();
node = node[b];
}
totalLen += bits[i].length;
node[encodeBits(bits[i])] = (bits[i].length << 9) | octet;
encode[octet] = [ totalLen, hex ];
});
// Wrap lines after 79 chars
out = 'exports.decode =\n' + utils.wrap(JSON.stringify(decode)) + ';';
console.log(out);
out = 'exports.encode =\n' + utils.wrap(JSON.stringify(encode)) + ';';
console.log(out);

103
app_vue/node_modules/hpack.js/tools/gen-static-table.js generated vendored Normal file
View File

@ -0,0 +1,103 @@
var utils = require('./utils');
var table = `
1 :authority
2 :method GET
3 :method POST
4 :path /
5 :path /index.html
6 :scheme http
7 :scheme https
8 :status 200
9 :status 204
10 :status 206
11 :status 304
12 :status 400
13 :status 404
14 :status 500
15 accept-charset
16 accept-encoding gzip, deflate
17 accept-language
18 accept-ranges
19 accept
20 access-control-allow-origin
21 age
22 allow
23 authorization
24 cache-control
25 content-disposition
26 content-encoding
27 content-language
28 content-length
29 content-location
30 content-range
31 content-type
32 cookie
33 date
34 etag
35 expect
36 expires
37 from
38 host
39 if-match
40 if-modified-since
41 if-none-match
42 if-range
43 if-unmodified-since
44 last-modified
45 link
46 location
47 max-forwards
48 proxy-authenticate
49 proxy-authorization
50 range
51 referer
52 refresh
53 retry-after
54 server
55 set-cookie
56 strict-transport-security
57 transfer-encoding
58 user-agent
59 vary
60 via
61 www-authenticate
`;
var out = [];
table.split('\n').filter(function(line) {
return line;
}).forEach(function(line) {
var columns = line.split(/\t/g);
var name = columns[1];
var value = columns[2];
var nameSize = Buffer.byteLength(name);
var valueSize = Buffer.byteLength(value);
out.push({
name: name,
value: value,
nameSize: nameSize,
totalSize: nameSize + valueSize + 32
});
});
console.log('exports.table = ' + JSON.stringify(out, false, 2) + ';');
var map = {};
table.split('\n').filter(function(line) {
return line;
}).forEach(function(line) {
var columns = line.split(/\t/g);
var name = columns[1];
var value = columns[2];
var index = columns[0] | 0;
if (!map[name]) {
map[name] = {
index: index,
values: {}
};
}
map[name].values[value] = index;
});
console.log('exports.map = ' + JSON.stringify(map, false, 2) + ';');

23
app_vue/node_modules/hpack.js/tools/utils.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
// Wrap lines after 79 chars
exports.wrap = function wrap(str) {
var out = [];
var pad = ' ';
var line = pad;
var chunks = str.split(/,/g);
chunks.forEach(function(chunk, i) {
var append = chunk;
if (i !== chunks.length - 1)
append += ',';
if (line.length + append.length > 79) {
out.push(line);
line = pad;
}
line += append;
});
if (line !== pad)
out.push(line);
return out.join('\n');
};