http2-protocol
Advanced tools
Comparing version 0.10.0 to 0.11.0
Version history | ||
=============== | ||
### 0.11.0 (2014-04-16) ### | ||
* Upgrade to the latest draft: [draft-ietf-httpbis-http2-11][draft-11] | ||
[draft-11]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-11 | ||
### 0.10.0 (2014-03-12) ### | ||
@@ -5,0 +11,0 @@ |
@@ -16,3 +16,3 @@ // The implementation of the [HTTP/2 Header Compression][http2-compression] spec is separated from | ||
// [node-objectmode]: http://nodejs.org/api/stream.html#stream_new_stream_readable_options | ||
// [http2-compression]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05 | ||
// [http2-compression]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07 | ||
@@ -39,4 +39,4 @@ exports.HeaderTable = HeaderTable; | ||
// In this implementation, the Header Table and the [Static Table] are handled as a single table. | ||
// [Header Table]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-3.1.2 | ||
// [Static Table]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#appendix-B | ||
// [Header Table]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#section-3.1.2 | ||
// [Static Table]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B | ||
function HeaderTable(log, limit) { | ||
@@ -64,3 +64,3 @@ var self = HeaderTable.staticTable.map(entryFromPair); | ||
// | ||
// [referenceset]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-3.1.3 | ||
// [referenceset]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#section-3.1.3 | ||
// | ||
@@ -105,3 +105,3 @@ // Relations of the sets: | ||
// The `add(index, entry)` can be used to [manage the header table][tablemgmt]: | ||
// [tablemgmt]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-3.3 | ||
// [tablemgmt]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#section-3.3 | ||
// | ||
@@ -153,5 +153,5 @@ // * it pushes the new `entry` at the beggining of the table | ||
// [The Static Table](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#appendix-B) | ||
// [The Static Table](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B) | ||
// ------------------ | ||
// [statictable]:http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#appendix-B | ||
// [statictable]:http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B | ||
@@ -171,7 +171,8 @@ // The table is generated with feeding the table from the spec to the following sed command: | ||
[ ':status' , '200' ], | ||
[ ':status' , '204' ], | ||
[ ':status' , '206' ], | ||
[ ':status' , '304' ], | ||
[ ':status' , '400' ], | ||
[ ':status' , '404' ], | ||
[ ':status' , '500' ], | ||
[ ':status' , '404' ], | ||
[ ':status' , '403' ], | ||
[ ':status' , '400' ], | ||
[ ':status' , '401' ], | ||
[ 'accept-charset' , '' ], | ||
@@ -254,3 +255,3 @@ [ 'accept-encoding' , '' ], | ||
// `execute(rep)` executes the given [header representation][representation]. | ||
// [representation]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-3.1.4 | ||
// [representation]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#section-3.1.4 | ||
@@ -282,6 +283,12 @@ // The *JavaScript object representation* of a header representation: | ||
// * An _indexed representation_ with an index value of 0 (in our representation, it means -1) | ||
// entails the following actions: | ||
// * If the following byte starts with a set bit, the reference set is emptied. | ||
// * Else, reduce the size of the header table to the value encoded with a 7-bit prefix | ||
if (rep.contextUpdate) { | ||
if (rep.clearReferenceSet) { | ||
for (var i = 0; i < this._table.length; i++) { | ||
this._table[i].reference = false; | ||
} | ||
} else { | ||
this.setTableSizeLimit(rep.newMaxSize); | ||
} | ||
} | ||
// * An _indexed representation_ corresponding to an entry _present_ in the reference set | ||
@@ -300,18 +307,7 @@ // entails the following actions: | ||
// * The referenced header table entry is added to the reference set | ||
if (typeof rep.value === 'number') { | ||
else if (typeof rep.value === 'number') { | ||
var index = rep.value; | ||
entry = this._table[index]; | ||
if (index == -1) { | ||
if (rep.index) { | ||
for (var i = 0; i < this._table.length; i++) { | ||
this._table[i].reference = false; | ||
} | ||
} else { | ||
// Set a new maximum size | ||
this.setTableSizeLimit(rep.name); | ||
} | ||
} | ||
else if (entry.reference) { | ||
if (entry.reference) { | ||
entry.reference = false; | ||
@@ -372,3 +368,3 @@ } | ||
// * [emits the reference set](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-3.2.2) | ||
// * [emits the reference set](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#section-3.2.2) | ||
for (var index = 0; index < this._table.length; index++) { | ||
@@ -438,2 +434,4 @@ var entry = this._table[index]; | ||
var mustNeverIndex = (name === 'cookie' || name === 'set-cookie' || name === 'authorization'); | ||
// * if there's full match, it will be an indexed representation (or more than one) depending | ||
@@ -463,3 +461,3 @@ // on its presence in the reference, the emitted and the keep set: | ||
// in the reference set (that means don't remove at the end of the encoding process). | ||
if (fullMatch !== -1) { | ||
if (fullMatch !== -1 && !mustNeverIndex) { | ||
rep = { name: fullMatch, value: fullMatch, index: false }; | ||
@@ -501,3 +499,3 @@ | ||
var indexing = (entry._size < this._table._limit / 2); | ||
var indexing = (entry._size < this._table._limit / 2) && !mustNeverIndex; | ||
@@ -518,3 +516,3 @@ if (indexing) { | ||
this.send({ name: (nameMatch !== -1) ? nameMatch : name, value: value, index: indexing }); | ||
this.send({ name: (nameMatch !== -1) ? nameMatch : name, value: value, index: indexing, mustNeverIndex: mustNeverIndex, contextUpdate: false }); | ||
} | ||
@@ -543,3 +541,3 @@ | ||
// [Detailed Format](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-4) | ||
// [Detailed Format](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#section-4) | ||
// ----------------- | ||
@@ -728,224 +726,2 @@ | ||
HuffmanTable.huffmanTable = new HuffmanTable([ | ||
'111111111111111111110111010', | ||
'111111111111111111110111011', | ||
'111111111111111111110111100', | ||
'111111111111111111110111101', | ||
'111111111111111111110111110', | ||
'111111111111111111110111111', | ||
'111111111111111111111000000', | ||
'111111111111111111111000001', | ||
'111111111111111111111000010', | ||
'111111111111111111111000011', | ||
'111111111111111111111000100', | ||
'111111111111111111111000101', | ||
'111111111111111111111000110', | ||
'111111111111111111111000111', | ||
'111111111111111111111001000', | ||
'111111111111111111111001001', | ||
'111111111111111111111001010', | ||
'111111111111111111111001011', | ||
'111111111111111111111001100', | ||
'111111111111111111111001101', | ||
'111111111111111111111001110', | ||
'111111111111111111111001111', | ||
'111111111111111111111010000', | ||
'111111111111111111111010001', | ||
'111111111111111111111010010', | ||
'111111111111111111111010011', | ||
'111111111111111111111010100', | ||
'111111111111111111111010101', | ||
'111111111111111111111010110', | ||
'111111111111111111111010111', | ||
'111111111111111111111011000', | ||
'111111111111111111111011001', | ||
'11101000', | ||
'111111111100', | ||
'11111111111010', | ||
'111111111111100', | ||
'111111111111101', | ||
'100100', | ||
'1101110', | ||
'111111111111110', | ||
'11111111010', | ||
'11111111011', | ||
'1111111010', | ||
'11111111100', | ||
'11101001', | ||
'100101', | ||
'00100', | ||
'0000', | ||
'00101', | ||
'00110', | ||
'00111', | ||
'100110', | ||
'100111', | ||
'101000', | ||
'101001', | ||
'101010', | ||
'101011', | ||
'101100', | ||
'111101100', | ||
'11101010', | ||
'111111111111111110', | ||
'101101', | ||
'11111111111111100', | ||
'111101101', | ||
'11111111111011', | ||
'1101111', | ||
'11101011', | ||
'11101100', | ||
'11101101', | ||
'11101110', | ||
'1110000', | ||
'111101110', | ||
'111101111', | ||
'111110000', | ||
'111110001', | ||
'1111111011', | ||
'111110010', | ||
'11101111', | ||
'111110011', | ||
'111110100', | ||
'111110101', | ||
'111110110', | ||
'111110111', | ||
'11110000', | ||
'11110001', | ||
'111111000', | ||
'111111001', | ||
'111111010', | ||
'111111011', | ||
'111111100', | ||
'1111111100', | ||
'11111111111100', | ||
'111111111111111111111011010', | ||
'1111111111100', | ||
'11111111111101', | ||
'101110', | ||
'1111111111111111110', | ||
'01000', | ||
'101111', | ||
'01001', | ||
'110000', | ||
'0001', | ||
'110001', | ||
'110010', | ||
'110011', | ||
'01010', | ||
'1110001', | ||
'1110010', | ||
'01011', | ||
'110100', | ||
'01100', | ||
'01101', | ||
'01110', | ||
'11110010', | ||
'01111', | ||
'10000', | ||
'10001', | ||
'110101', | ||
'1110011', | ||
'110110', | ||
'11110011', | ||
'11110100', | ||
'11110101', | ||
'11111111111111101', | ||
'11111111101', | ||
'11111111111111110', | ||
'111111111101', | ||
'111111111111111111111011011', | ||
'111111111111111111111011100', | ||
'111111111111111111111011101', | ||
'111111111111111111111011110', | ||
'111111111111111111111011111', | ||
'111111111111111111111100000', | ||
'111111111111111111111100001', | ||
'111111111111111111111100010', | ||
'111111111111111111111100011', | ||
'111111111111111111111100100', | ||
'111111111111111111111100101', | ||
'111111111111111111111100110', | ||
'111111111111111111111100111', | ||
'111111111111111111111101000', | ||
'111111111111111111111101001', | ||
'111111111111111111111101010', | ||
'111111111111111111111101011', | ||
'111111111111111111111101100', | ||
'111111111111111111111101101', | ||
'111111111111111111111101110', | ||
'111111111111111111111101111', | ||
'111111111111111111111110000', | ||
'111111111111111111111110001', | ||
'111111111111111111111110010', | ||
'111111111111111111111110011', | ||
'111111111111111111111110100', | ||
'111111111111111111111110101', | ||
'111111111111111111111110110', | ||
'111111111111111111111110111', | ||
'111111111111111111111111000', | ||
'111111111111111111111111001', | ||
'111111111111111111111111010', | ||
'111111111111111111111111011', | ||
'111111111111111111111111100', | ||
'111111111111111111111111101', | ||
'111111111111111111111111110', | ||
'111111111111111111111111111', | ||
'11111111111111111110000000', | ||
'11111111111111111110000001', | ||
'11111111111111111110000010', | ||
'11111111111111111110000011', | ||
'11111111111111111110000100', | ||
'11111111111111111110000101', | ||
'11111111111111111110000110', | ||
'11111111111111111110000111', | ||
'11111111111111111110001000', | ||
'11111111111111111110001001', | ||
'11111111111111111110001010', | ||
'11111111111111111110001011', | ||
'11111111111111111110001100', | ||
'11111111111111111110001101', | ||
'11111111111111111110001110', | ||
'11111111111111111110001111', | ||
'11111111111111111110010000', | ||
'11111111111111111110010001', | ||
'11111111111111111110010010', | ||
'11111111111111111110010011', | ||
'11111111111111111110010100', | ||
'11111111111111111110010101', | ||
'11111111111111111110010110', | ||
'11111111111111111110010111', | ||
'11111111111111111110011000', | ||
'11111111111111111110011001', | ||
'11111111111111111110011010', | ||
'11111111111111111110011011', | ||
'11111111111111111110011100', | ||
'11111111111111111110011101', | ||
'11111111111111111110011110', | ||
'11111111111111111110011111', | ||
'11111111111111111110100000', | ||
'11111111111111111110100001', | ||
'11111111111111111110100010', | ||
'11111111111111111110100011', | ||
'11111111111111111110100100', | ||
'11111111111111111110100101', | ||
'11111111111111111110100110', | ||
'11111111111111111110100111', | ||
'11111111111111111110101000', | ||
'11111111111111111110101001', | ||
'11111111111111111110101010', | ||
'11111111111111111110101011', | ||
'11111111111111111110101100', | ||
'11111111111111111110101101', | ||
'11111111111111111110101110', | ||
'11111111111111111110101111', | ||
'11111111111111111110110000', | ||
'11111111111111111110110001', | ||
'11111111111111111110110010', | ||
'11111111111111111110110011', | ||
'11111111111111111110110100', | ||
'11111111111111111110110101', | ||
'11111111111111111110110110', | ||
'11111111111111111110110111', | ||
'11111111111111111110111000', | ||
'11111111111111111110111001', | ||
'11111111111111111110111010', | ||
@@ -983,5 +759,227 @@ '11111111111111111110111011', | ||
'11111111111111111111011001', | ||
'00110', | ||
'1111111111100', | ||
'111110000', | ||
'11111111111100', | ||
'111111111111100', | ||
'011110', | ||
'1100100', | ||
'1111111111101', | ||
'1111111010', | ||
'111110001', | ||
'1111111011', | ||
'1111111100', | ||
'1100101', | ||
'1100110', | ||
'011111', | ||
'00111', | ||
'0000', | ||
'0001', | ||
'0010', | ||
'01000', | ||
'100000', | ||
'100001', | ||
'100010', | ||
'100011', | ||
'100100', | ||
'100101', | ||
'100110', | ||
'11101100', | ||
'11111111111111100', | ||
'100111', | ||
'111111111111101', | ||
'1111111101', | ||
'111111111111110', | ||
'1100111', | ||
'11101101', | ||
'11101110', | ||
'1101000', | ||
'11101111', | ||
'1101001', | ||
'1101010', | ||
'111110010', | ||
'11110000', | ||
'111110011', | ||
'111110100', | ||
'111110101', | ||
'1101011', | ||
'1101100', | ||
'11110001', | ||
'11110010', | ||
'111110110', | ||
'111110111', | ||
'1101101', | ||
'101000', | ||
'11110011', | ||
'111111000', | ||
'111111001', | ||
'11110100', | ||
'111111010', | ||
'111111011', | ||
'11111111100', | ||
'11111111111111111111011010', | ||
'11111111101', | ||
'11111111111101', | ||
'1101110', | ||
'111111111111111110', | ||
'01001', | ||
'1101111', | ||
'01010', | ||
'101001', | ||
'01011', | ||
'1110000', | ||
'101010', | ||
'101011', | ||
'01100', | ||
'11110101', | ||
'11110110', | ||
'101100', | ||
'101101', | ||
'101110', | ||
'01101', | ||
'101111', | ||
'111111100', | ||
'110000', | ||
'110001', | ||
'01110', | ||
'1110001', | ||
'1110010', | ||
'1110011', | ||
'1110100', | ||
'1110101', | ||
'11110111', | ||
'11111111111111101', | ||
'111111111100', | ||
'11111111111111110', | ||
'111111111101', | ||
'11111111111111111111011011', | ||
'11111111111111111111011100' | ||
'11111111111111111111011100', | ||
'11111111111111111111011101', | ||
'11111111111111111111011110', | ||
'11111111111111111111011111', | ||
'11111111111111111111100000', | ||
'11111111111111111111100001', | ||
'11111111111111111111100010', | ||
'11111111111111111111100011', | ||
'11111111111111111111100100', | ||
'11111111111111111111100101', | ||
'11111111111111111111100110', | ||
'11111111111111111111100111', | ||
'11111111111111111111101000', | ||
'11111111111111111111101001', | ||
'11111111111111111111101010', | ||
'11111111111111111111101011', | ||
'11111111111111111111101100', | ||
'11111111111111111111101101', | ||
'11111111111111111111101110', | ||
'11111111111111111111101111', | ||
'11111111111111111111110000', | ||
'11111111111111111111110001', | ||
'11111111111111111111110010', | ||
'11111111111111111111110011', | ||
'11111111111111111111110100', | ||
'11111111111111111111110101', | ||
'11111111111111111111110110', | ||
'11111111111111111111110111', | ||
'11111111111111111111111000', | ||
'11111111111111111111111001', | ||
'11111111111111111111111010', | ||
'11111111111111111111111011', | ||
'11111111111111111111111100', | ||
'11111111111111111111111101', | ||
'11111111111111111111111110', | ||
'11111111111111111111111111', | ||
'1111111111111111110000000', | ||
'1111111111111111110000001', | ||
'1111111111111111110000010', | ||
'1111111111111111110000011', | ||
'1111111111111111110000100', | ||
'1111111111111111110000101', | ||
'1111111111111111110000110', | ||
'1111111111111111110000111', | ||
'1111111111111111110001000', | ||
'1111111111111111110001001', | ||
'1111111111111111110001010', | ||
'1111111111111111110001011', | ||
'1111111111111111110001100', | ||
'1111111111111111110001101', | ||
'1111111111111111110001110', | ||
'1111111111111111110001111', | ||
'1111111111111111110010000', | ||
'1111111111111111110010001', | ||
'1111111111111111110010010', | ||
'1111111111111111110010011', | ||
'1111111111111111110010100', | ||
'1111111111111111110010101', | ||
'1111111111111111110010110', | ||
'1111111111111111110010111', | ||
'1111111111111111110011000', | ||
'1111111111111111110011001', | ||
'1111111111111111110011010', | ||
'1111111111111111110011011', | ||
'1111111111111111110011100', | ||
'1111111111111111110011101', | ||
'1111111111111111110011110', | ||
'1111111111111111110011111', | ||
'1111111111111111110100000', | ||
'1111111111111111110100001', | ||
'1111111111111111110100010', | ||
'1111111111111111110100011', | ||
'1111111111111111110100100', | ||
'1111111111111111110100101', | ||
'1111111111111111110100110', | ||
'1111111111111111110100111', | ||
'1111111111111111110101000', | ||
'1111111111111111110101001', | ||
'1111111111111111110101010', | ||
'1111111111111111110101011', | ||
'1111111111111111110101100', | ||
'1111111111111111110101101', | ||
'1111111111111111110101110', | ||
'1111111111111111110101111', | ||
'1111111111111111110110000', | ||
'1111111111111111110110001', | ||
'1111111111111111110110010', | ||
'1111111111111111110110011', | ||
'1111111111111111110110100', | ||
'1111111111111111110110101', | ||
'1111111111111111110110110', | ||
'1111111111111111110110111', | ||
'1111111111111111110111000', | ||
'1111111111111111110111001', | ||
'1111111111111111110111010', | ||
'1111111111111111110111011', | ||
'1111111111111111110111100', | ||
'1111111111111111110111101', | ||
'1111111111111111110111110', | ||
'1111111111111111110111111', | ||
'1111111111111111111000000', | ||
'1111111111111111111000001', | ||
'1111111111111111111000010', | ||
'1111111111111111111000011', | ||
'1111111111111111111000100', | ||
'1111111111111111111000101', | ||
'1111111111111111111000110', | ||
'1111111111111111111000111', | ||
'1111111111111111111001000', | ||
'1111111111111111111001001', | ||
'1111111111111111111001010', | ||
'1111111111111111111001011', | ||
'1111111111111111111001100', | ||
'1111111111111111111001101', | ||
'1111111111111111111001110', | ||
'1111111111111111111001111', | ||
'1111111111111111111010000', | ||
'1111111111111111111010001', | ||
'1111111111111111111010010', | ||
'1111111111111111111010011', | ||
'1111111111111111111010100', | ||
'1111111111111111111010101', | ||
'1111111111111111111010110', | ||
'1111111111111111111010111', | ||
'1111111111111111111011000', | ||
'1111111111111111111011001', | ||
'1111111111111111111011010', | ||
'1111111111111111111011011', | ||
'1111111111111111111011100' | ||
]); | ||
@@ -1060,3 +1058,3 @@ | ||
// | 0 | 1 | Index (6+) | | ||
// +---+---+---+-------------------+ Literal w/o Indexing | ||
// +---+---+---+-------------------+ Literal w/ Indexing | ||
// | Value Length (8+) | | ||
@@ -1072,3 +1070,3 @@ // +-------------------------------+ w/ Indexed Name | ||
// | Name Length (8+) | | ||
// +-------------------------------+ Literal w/o Indexing | ||
// +-------------------------------+ Literal w/ Indexing | ||
// | Name String (Length octets) | | ||
@@ -1083,4 +1081,4 @@ // +-------------------------------+ w/ New Name | ||
// +---+---+---+---+---+---+---+---+ | ||
// | 0 | 0 | Index (6+) | | ||
// +---+---+---+-------------------+ Literal w/ Incremental Indexing | ||
// | 0 | 0 | 0 | 0 | Index (4+) | | ||
// +---+---+---+-------------------+ Literal w/o Incremental Indexing | ||
// | Value Length (8+) | | ||
@@ -1093,6 +1091,6 @@ // +-------------------------------+ w/ Indexed Name | ||
// +---+---+---+---+---+---+---+---+ | ||
// | 0 | 0 | 0 | | ||
// | 0 | 0 | 0 | 0 | 0 | | ||
// +---+---+---+-------------------+ | ||
// | Name Length (8+) | | ||
// +-------------------------------+ Literal w/ Incremental Indexing | ||
// +-------------------------------+ Literal w/o Incremental Indexing | ||
// | Name String (Length octets) | | ||
@@ -1105,2 +1103,24 @@ // +-------------------------------+ w/ New Name | ||
// | ||
// 0 1 2 3 4 5 6 7 | ||
// +---+---+---+---+---+---+---+---+ | ||
// | 0 | 0 | 0 | 1 | Index (4+) | | ||
// +---+---+---+-------------------+ Literal never indexed | ||
// | Value Length (8+) | | ||
// +-------------------------------+ w/ Indexed Name | ||
// | Value String (Length octets) | | ||
// +-------------------------------+ | ||
// | ||
// 0 1 2 3 4 5 6 7 | ||
// +---+---+---+---+---+---+---+---+ | ||
// | 0 | 0 | 0 | 1 | 0 | | ||
// +---+---+---+-------------------+ | ||
// | Name Length (8+) | | ||
// +-------------------------------+ Literal never indexed | ||
// | Name String (Length octets) | | ||
// +-------------------------------+ w/ New Name | ||
// | Value Length (8+) | | ||
// +-------------------------------+ | ||
// | Value String (Length octets) | | ||
// +-------------------------------+ | ||
// | ||
// The **Indexed Representation** consists of the 1-bit prefix and the Index that is represented as | ||
@@ -1118,4 +1138,6 @@ // a 7-bit prefix coded integer and nothing else. | ||
indexed : { prefix: 7, pattern: 0x80 }, | ||
literal : { prefix: 6, pattern: 0x40 }, | ||
literalIncremental : { prefix: 6, pattern: 0x00 } | ||
literalIncremental : { prefix: 6, pattern: 0x40 }, | ||
contextUpdate : { prefix: 0, pattern: 0x20 }, | ||
literalNeverIndexed : { prefix: 4, pattern: 0x10 }, | ||
literal : { prefix: 4, pattern: 0x00 } | ||
}; | ||
@@ -1126,6 +1148,10 @@ | ||
if (typeof header.value === 'number') { | ||
if (header.contextUpdate) { | ||
representation = representations.contextUpdate; | ||
} else if (typeof header.value === 'number') { | ||
representation = representations.indexed; | ||
} else if (header.index) { | ||
representation = representations.literalIncremental; | ||
} else if (header.mustNeverIndex) { | ||
representation = representations.literalNeverIndexed; | ||
} else { | ||
@@ -1135,13 +1161,15 @@ representation = representations.literal; | ||
if (representation === representations.indexed) { | ||
buffers.push(HeaderSetCompressor.integer(header.value + 1, representation.prefix)); | ||
if (header.value == -1) { | ||
if (header.index) { | ||
buffers.push(HeaderSetCompressor.integer(0x80, 8)); | ||
} else { | ||
buffers.push(HeaderSetCompressor.integer(header.name, 7)); | ||
} | ||
if (representation === representations.contextUpdate) { | ||
if (header.clearReferenceSet) { | ||
var buffer = new Buffer('10', 'hex'); | ||
buffers.push([buffer]); | ||
} else { | ||
buffers.push(HeaderSetCompressor.integer(header.newMaxSize, 4)); | ||
} | ||
} | ||
else if (representation === representations.indexed) { | ||
buffers.push(HeaderSetCompressor.integer(header.value + 1, representation.prefix)); | ||
} | ||
else { | ||
@@ -1169,20 +1197,32 @@ if (typeof header.name === 'number') { | ||
} else if (firstByte & 0x40) { | ||
representation = representations.literalIncremental; | ||
} else if (firstByte & 0x20) { | ||
representation = representations.contextUpdate; | ||
} else if (firstByte & 0x10) { | ||
representation = representations.literalNeverIndexed; | ||
} else { | ||
representation = representations.literal; | ||
} else { | ||
representation = representations.literalIncremental; | ||
} | ||
if (representation === representations.indexed) { | ||
header.value = header.name = HeaderSetDecompressor.integer(buffer, representation.prefix) - 1; | ||
header.index = false; | ||
if (header.value === -1) { | ||
if (buffer[buffer.cursor] & 0x80) { | ||
header.index = true; | ||
buffer.cursor += 1; | ||
} else { | ||
header.name = HeaderSetDecompressor.integer(buffer, 7); | ||
} | ||
header.value = header.name = -1; | ||
header.index = false; | ||
header.contextUpdate = false; | ||
header.clearReferenceSet = false; | ||
header.newMaxSize = 0; | ||
header.mustNeverIndex = false; | ||
if (representation === representations.contextUpdate) { | ||
header.contextUpdate = true; | ||
if (firstByte & 0x10) { | ||
header.clearReferenceSet = true; | ||
buffer.cursor += 1; | ||
} else { | ||
header.newMaxSize = HeaderSetDecompressor.integer(buffer, 4); | ||
} | ||
} | ||
else if (representation === representations.indexed) { | ||
header.value = header.name = HeaderSetDecompressor.integer(buffer, representation.prefix) - 1; | ||
} | ||
else { | ||
@@ -1195,2 +1235,3 @@ header.name = HeaderSetDecompressor.integer(buffer, representation.prefix) - 1; | ||
header.index = (representation === representations.literalIncremental); | ||
header.mustNeverIndex = (representation === representations.literalNeverIndexed); | ||
} | ||
@@ -1197,0 +1238,0 @@ |
@@ -125,3 +125,4 @@ var assert = require('assert'); | ||
if ((frame.type === 'SETTINGS') || (frame.type === 'PING') || | ||
(frame.type === 'GOAWAY') || (frame.type === 'WINDOW_UPDATE')) { | ||
(frame.type === 'GOAWAY') || (frame.type === 'WINDOW_UPDATE') || | ||
(frame.type === 'ALTSVC')) { | ||
this._log.debug({ frame: frame }, 'Receiving connection level frame'); | ||
@@ -128,0 +129,0 @@ this.emit(frame.type, frame); |
@@ -22,3 +22,3 @@ var assert = require('assert'); | ||
// | ||
// [1]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.9.2 | ||
// [1]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.9.2 | ||
@@ -25,0 +25,0 @@ // API for child classes |
@@ -151,3 +151,3 @@ // The framer consists of two [Transform Stream][1] subclasses that operate in [object mode][2]: | ||
// [Frame Header](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-4.1) | ||
// [Frame Header](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-4.1) | ||
// -------------------------------------------------------------- | ||
@@ -266,3 +266,3 @@ // | ||
// [DATA Frames](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.1) | ||
// [DATA Frames](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.1) | ||
// ------------------------------------------------------------ | ||
@@ -282,5 +282,5 @@ // | ||
// forwarding frames. | ||
// * PAD_LOW (0x10): | ||
// * PAD_LOW (0x08): | ||
// Bit 5 being set indicates that the Pad Low field is present. | ||
// * PAD_HIGH (0x20): | ||
// * PAD_HIGH (0x10): | ||
// Bit 6 being set indicates that the Pad High field is present. This bit MUST NOT be set unless | ||
@@ -292,3 +292,3 @@ // the PAD_LOW flag is also set. Endpoints that receive a frame with PAD_HIGH set and PAD_LOW | ||
frameFlags.DATA = ['END_STREAM', 'END_SEGMENT', 'RESERVED4', 'RESERVED8', 'PAD_LOW', 'PAD_HIGH']; | ||
frameFlags.DATA = ['END_STREAM', 'END_SEGMENT', 'RESERVED4', 'PAD_LOW', 'PAD_HIGH']; | ||
@@ -321,3 +321,3 @@ typeSpecificAttributes.DATA = ['data']; | ||
// [HEADERS](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.2) | ||
// [HEADERS](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.2) | ||
// -------------------------------------------------------------- | ||
@@ -339,8 +339,5 @@ // | ||
// a complete set of headers. | ||
// * PRIORITY (0x8): | ||
// Bit 4 being set indicates that the first four octets of this frame contain a single reserved | ||
// bit and a 31-bit priority. | ||
// * PAD_LOW (0x10): | ||
// * PAD_LOW (0x08): | ||
// Bit 5 being set indicates that the Pad Low field is present. | ||
// * PAD_HIGH (0x20): | ||
// * PAD_HIGH (0x10): | ||
// Bit 6 being set indicates that the Pad High field is present. This bit MUST NOT be set unless | ||
@@ -352,5 +349,5 @@ // the PAD_LOW flag is also set. Endpoints that receive a frame with PAD_HIGH set and PAD_LOW | ||
frameFlags.HEADERS = ['END_STREAM', 'END_SEGMENT', 'END_HEADERS', 'PRIORITY', 'PAD_LOW', 'PAD_HIGH']; | ||
frameFlags.HEADERS = ['END_STREAM', 'END_SEGMENT', 'END_HEADERS', 'PAD_LOW', 'PAD_HIGH', 'PRIORITY_GROUP', 'PRIORITY_DEPENDENCY']; | ||
typeSpecificAttributes.HEADERS = ['priority', 'headers', 'data']; | ||
typeSpecificAttributes.HEADERS = ['priorityGroup', 'groupWeight', 'priorityDependency', 'exclusiveDependency', 'headers', 'data']; | ||
@@ -360,6 +357,14 @@ // 0 1 2 3 | ||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
// |X| (Optional) Priority (31) | | ||
// | Pad High? (8) | Pad Low? (8) | | ||
// +-+-------------+---------------+-------------------------------+ | ||
// |R| Priority Group Identifier? (31) | | ||
// +-+-------------+-----------------------------------------------+ | ||
// | Weight? (8) | | ||
// +-+-------------+-----------------------------------------------+ | ||
// |E| Stream Dependency? (31) | | ||
// +-+-------------------------------------------------------------+ | ||
// | Header Block (*) ... | ||
// | Header Block Fragment (*) ... | ||
// +---------------------------------------------------------------+ | ||
// | Padding (*) ... | ||
// +---------------------------------------------------------------+ | ||
// | ||
@@ -369,6 +374,16 @@ // The payload of a HEADERS frame contains a Headers Block | ||
Serializer.HEADERS = function writeHeadersPriority(frame, buffers) { | ||
if (frame.flags.PRIORITY) { | ||
if (frame.flags.PRIORITY_GROUP) { | ||
var buffer = new Buffer(5); | ||
assert((0 <= frame.priorityGroup) && (frame.priorityGroup <= 0x7fffffff), frame.priorityGroup); | ||
buffer.writeUInt32BE(frame.priorityGroup, 0); | ||
assert((0 <= frame.groupWeight) && (frame.groupWeight <= 0xff), frame.groupWeight); | ||
buffer.writeUInt8(frame.groupWeight, 4); | ||
buffers.push(buffer); | ||
} else if (frame.flags.PRIORITY_DEPENDENCY) { | ||
var buffer = new Buffer(4); | ||
assert((0 <= frame.priority) && (frame.priority <= 0xffffffff), frame.priority); | ||
buffer.writeUInt32BE(frame.priority, 0); | ||
assert((0 <= frame.priorityDependency) && (frame.priorityDependency <= 0x7fffffff), frame.priorityDependency); | ||
buffer.writeUInt32BE(frame.priorityDependency, 0); | ||
if (frame.exclusiveDependency) { | ||
buffer[0] |= 0x80; | ||
} | ||
buffers.push(buffer); | ||
@@ -392,6 +407,20 @@ } | ||
} | ||
if (frame.flags.PRIORITY) { | ||
frame.priority = buffer.readUInt32BE(dataOffset) & 0x7fffffff; | ||
if (frame.flags.PRIORITY_GROUP) { | ||
if (frame.flags.PRIORITY_DEPENDENCY) { | ||
return 'HEADERS frame got both PRIORITY_GROUP and PRIORITY_DEPENDENCY'; | ||
} | ||
frame.priorityGroup = buffer.readUInt32BE(dataOffset) & 0x7fffffff; | ||
dataOffset += 4; | ||
frame.groupWeight = buffer.readUInt8(dataOffset); | ||
dataOffset += 1; | ||
} else if (frame.flags.PRIORITY_DEPENDENCY) { | ||
var dependencyData = new Buffer(4); | ||
buffer.copy(dependencyData, 0, dataOffset, dataOffset + 4); | ||
dataOffset += 4; | ||
frame.exclusiveDependency = !!(dependencyData[0] & 0x80); | ||
dependencyData[0] &= 0x7f; | ||
frame.priorityDependency = dependencyData.readUInt32BE(0); | ||
} | ||
if (paddingLength) { | ||
@@ -404,3 +433,3 @@ frame.data = buffer.slice(dataOffset, -1 * paddingLength); | ||
// [PRIORITY](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.3) | ||
// [PRIORITY](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.3) | ||
// ------------------------------------------------------- | ||
@@ -414,5 +443,5 @@ // | ||
frameFlags.PRIORITY = []; | ||
frameFlags.PRIORITY = ['RESERVED1', 'RESERVED2', 'RESERVED4', 'RESERVED8', 'RESERVED16', 'PRIORITY_GROUP', 'PRIORITY_DEPENDENCY']; | ||
typeSpecificAttributes.PRIORITY = ['priority']; | ||
typeSpecificAttributes.PRIORITY = ['priorityGroup', 'groupWeight', 'priorityDependency', 'exclusiveDependency']; | ||
@@ -422,3 +451,7 @@ // 0 1 2 3 | ||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
// |X| Priority (31) | | ||
// |R| Priority Group Identifier? (31) | | ||
// +-+-------------+-----------------------------------------------+ | ||
// | Weight? (8) | | ||
// +-+-------------+-----------------------------------------------+ | ||
// |E| Stream Dependency? (31) | | ||
// +-+-------------------------------------------------------------+ | ||
@@ -429,4 +462,23 @@ // | ||
Serializer.PRIORITY = function writePriority(frame, buffers) { | ||
var buffer = new Buffer(4); | ||
buffer.writeUInt32BE(frame.priority, 0); | ||
var buffer; | ||
assert((frame.flags.PRIORITY_GROUP || frame.flags.PRIORITY_DEPENDENCY) && | ||
!(frame.flags.PRIORITY_GROUP && frame.flags.PRIORITY_DEPENDENCY), | ||
frame.flags.PRIORITY_GROUP && frame.flags.PRIORITY_DEPENDENCY); | ||
if (frame.flags.PRIORITY_GROUP) { | ||
buffer = new Buffer(5); | ||
assert((0 <= frame.priorityGroup) && (frame.priorityGroup <= 0x7fffffff), frame.priorityGroup); | ||
buffer.writeUInt32BE(frame.priorityGroup, 0); | ||
assert((0 <= frame.groupWeight) && (frame.groupWeight <= 0xff), frame.groupWeight); | ||
buffer.writeUInt8(frame.groupWeight, 4); | ||
} else { // frame.flags.PRIORITY_DEPENDENCY | ||
buffer = new Buffer(4); | ||
assert((0 <= frame.priorityDependency) && (frame.priorityDependency <= 0x7fffffff), frame.priorityDependency); | ||
buffer.writeUInt32BE(frame.priorityDependency, 0); | ||
if (frame.exclusiveDependency) { | ||
buffer[0] |= 0x80; | ||
} | ||
} | ||
buffers.push(buffer); | ||
@@ -436,6 +488,20 @@ }; | ||
Deserializer.PRIORITY = function readPriority(buffer, frame) { | ||
frame.priority = buffer.readUInt32BE(0); | ||
if (frame.flags.PRIORITY_GROUP) { | ||
if (frame.flags.PRIORITY_DEPENDENCY) { | ||
return 'PRIORITY frame got both PRIORITY_GROUP and PRIORITY_DEPENDENCY'; | ||
} | ||
frame.priorityGroup = buffer.readUInt32BE(0) & 0x7fffffff; | ||
frame.groupWeight = buffer.readUInt8(4); | ||
} else if (frame.flags.PRIORITY_DEPENDENCY) { | ||
var dependencyData = new Buffer(4); | ||
buffer.copy(dependencyData, 0, 0, 4); | ||
frame.exclusiveDependency = !!(dependencyData[0] & 0x80); | ||
dependencyData[0] &= 0x7f; | ||
frame.priorityDependency = dependencyData.readUInt32BE(0); | ||
} else { | ||
return 'PRIORITY frame got neither PRIORITY_GROUP nor PRIORITY_DEPENDENCY'; | ||
} | ||
}; | ||
// [RST_STREAM](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.4) | ||
// [RST_STREAM](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.4) | ||
// ----------------------------------------------------------- | ||
@@ -474,3 +540,3 @@ // | ||
// [SETTINGS](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.5) | ||
// [SETTINGS](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.5) | ||
// ------------------------------------------------------- | ||
@@ -581,3 +647,3 @@ // | ||
// [PUSH_PROMISE](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.6) | ||
// [PUSH_PROMISE](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.6) | ||
// --------------------------------------------------------------- | ||
@@ -596,3 +662,3 @@ // | ||
frameFlags.PUSH_PROMISE = ['RESERVED1', 'RESERVED2', 'END_PUSH_PROMISE']; | ||
frameFlags.PUSH_PROMISE = ['RESERVED1', 'RESERVED2', 'END_PUSH_PROMISE', 'PAD_LOW', 'PAD_HIGH']; | ||
@@ -625,7 +691,24 @@ typeSpecificAttributes.PUSH_PROMISE = ['promised_stream', 'headers', 'data']; | ||
Deserializer.PUSH_PROMISE = function readPushPromise(buffer, frame) { | ||
frame.promised_stream = buffer.readUInt32BE(0) & 0x7fffffff; | ||
frame.data = buffer.slice(4); | ||
var dataOffset = 0; | ||
var paddingLength = 0; | ||
if (frame.flags.PAD_LOW) { | ||
if (frame.flags.PAD_HIGH) { | ||
paddingLength = (buffer.readUInt8(dataOffset) & 0xff) * 256; | ||
dataOffset += 1; | ||
} | ||
paddingLength += (buffer.readUInt8(dataOffset) & 0xff); | ||
dataOffset += 1; | ||
} else if (frame.flags.PAD_HIGH) { | ||
return 'PUSH_PROMISE frame got PAD_HIGH without PAD_LOW'; | ||
} | ||
frame.promised_stream = buffer.readUInt32BE(dataOffset) & 0x7fffffff; | ||
dataOffset += 4; | ||
if (paddingLength) { | ||
frame.data = buffer.slice(dataOffset, -1 * paddingLength); | ||
} else { | ||
frame.data = buffer.slice(dataOffset); | ||
} | ||
}; | ||
// [PING](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.7) | ||
// [PING](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.7) | ||
// ----------------------------------------------- | ||
@@ -660,3 +743,3 @@ // | ||
// [GOAWAY](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.8) | ||
// [GOAWAY](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.8) | ||
// --------------------------------------------------- | ||
@@ -708,3 +791,3 @@ // | ||
// [WINDOW_UPDATE](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.9) | ||
// [WINDOW_UPDATE](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.9) | ||
// ----------------------------------------------------------------- | ||
@@ -744,6 +827,6 @@ // | ||
// [CONTINUATION](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-6.10) | ||
// [CONTINUATION](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.10) | ||
// ------------------------------------------------------------ | ||
// | ||
// The CONTINUATION frame (type=0xA) is used to continue a sequence of header block fragments. | ||
// The CONTINUATION frame (type=0x9) is used to continue a sequence of header block fragments. | ||
// | ||
@@ -755,5 +838,5 @@ // The CONTINUATION frame defines the following flag: | ||
// necessary to provide a complete set of headers. | ||
// * PAD_LOW (0x10): | ||
// * PAD_LOW (0x08): | ||
// Bit 5 being set indicates that the Pad Low field is present. | ||
// * PAD_HIGH (0x20): | ||
// * PAD_HIGH (0x10): | ||
// Bit 6 being set indicates that the Pad High field is present. This bit MUST NOT be set unless | ||
@@ -765,3 +848,3 @@ // the PAD_LOW flag is also set. Endpoints that receive a frame with PAD_HIGH set and PAD_LOW | ||
frameFlags.CONTINUATION = ['RESERVED1', 'RESERVED2', 'END_HEADERS', 'RESERVED8', 'PAD_LOW', 'PAD_HIGH']; | ||
frameFlags.CONTINUATION = ['RESERVED1', 'RESERVED2', 'END_HEADERS', 'PAD_LOW', 'PAD_HIGH']; | ||
@@ -794,5 +877,94 @@ typeSpecificAttributes.CONTINUATION = ['headers', 'data']; | ||
// [Error Codes](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-7) | ||
// [ALTSVC](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-6.11) | ||
// ------------------------------------------------------------ | ||
// | ||
// The ALTSVC frame (type=0xA) advertises the availability of an alternative service to the client. | ||
// | ||
// The ALTSVC frame does not define any flags. | ||
frameTypes[0xA] = 'ALTSVC'; | ||
frameFlags.ALTSVC = []; | ||
// 0 1 2 3 | ||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | ||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
// | Max-Age (32) | | ||
// +-------------------------------+----------------+--------------+ | ||
// | Port (16) | Reserved (8) | PID_LEN (8) | | ||
// +-------------------------------+----------------+--------------+ | ||
// | Protocol-ID (*) | | ||
// +---------------+-----------------------------------------------+ | ||
// | HOST_LEN (8) | Host (*) ... | ||
// +---------------+-----------------------------------------------+ | ||
// | Origin? (*) ... | ||
// +---------------------------------------------------------------+ | ||
// | ||
// The ALTSVC frame contains the following fields: | ||
// | ||
// Max-Age: An unsigned, 32-bit integer indicating the freshness | ||
// lifetime of the alternative service association, as per [ALT-SVC](http://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-01) | ||
// section 2.2. | ||
// | ||
// Port: An unsigned, 16-bit integer indicating the port that the | ||
// alternative service is available upon. | ||
// | ||
// Reserved: For future use. Senders MUST set these bits to '0', and | ||
// recipients MUST ignore them. | ||
// | ||
// PID_LEN: An unsigned, 8-bit integer indicating the length, in | ||
// octets, of the Protocol-ID field. | ||
// | ||
// Protocol-ID: A sequence of bytes (length determined by PID_LEN) | ||
// containing the ALPN protocol identifier of the alternative | ||
// service. | ||
// | ||
// HOST_LEN: An unsigned, 8-bit integer indicating the length, in | ||
// octets, of the Host field. | ||
// | ||
// Host: A sequence of characters (length determined by HOST_LEN) | ||
// containing an ASCII string indicating the host that the | ||
// alternative service is available upon. An internationalized | ||
// domain [IDNA] MUST be expressed using A-labels. | ||
// | ||
// Origin: An optional sequence of characters (length determined by | ||
// subtracting the length of all lpreceding fields from the frame | ||
// length) containing ASCII serialisation of an origin ([RFC6454](http://tools.ietf.org/html/rfc6454), | ||
// Section 6.2) that the alternate service is applicable to. | ||
typeSpecificAttributes.ALTSVC = ['maxAge', 'port', 'protocolID', 'host', | ||
'origin']; | ||
Serializer.ALTSVC = function writeAltSvc(frame, buffers) { | ||
var buffer = new Buffer(8); | ||
buffer.writeUInt32BE(frame.maxAge, 0); | ||
buffer.writeUInt16BE(frame.port, 4); | ||
buffer.writeUInt8(0, 6); | ||
buffer.writeUInt8(frame.protocolID.length, 7); | ||
buffers.push(buffer); | ||
buffers.push(new Buffer(frame.protocolID, 'ascii')); | ||
buffer = new Buffer(1); | ||
buffer.writeUInt8(frame.host.length, 0); | ||
buffers.push(buffer); | ||
buffers.push(new Buffer(frame.host, 'ascii')); | ||
buffers.push(new Buffer(frame.origin, 'ascii')); | ||
}; | ||
Deserializer.ALTSVC = function readAltSvc(buffer, frame) { | ||
frame.maxAge = buffer.readUInt32BE(0); | ||
frame.port = buffer.readUInt16BE(4); | ||
var pidLength = buffer.readUInt8(7); | ||
frame.protocolID = buffer.toString('ascii', 8, 8 + pidLength); | ||
var hostLength = buffer.readUInt8(8 + pidLength); | ||
frame.host = buffer.toString('ascii', 9 + pidLength, 9 + pidLength + hostLength); | ||
frame.origin = buffer.toString('ascii', 9 + pidLength + hostLength); | ||
}; | ||
// [Error Codes](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-7) | ||
// ------------------------------------------------------------ | ||
var errorCodes = [ | ||
@@ -809,5 +981,6 @@ 'NO_ERROR', | ||
'COMPRESSION_ERROR', | ||
'CONNECT_ERROR' | ||
'CONNECT_ERROR', | ||
'ENHANCE_YOUR_CALM', | ||
'INADEQUATE_SECURITY' | ||
]; | ||
errorCodes[420] = 'ENHANCE_YOUR_CALM'; | ||
@@ -814,0 +987,0 @@ // Logging |
@@ -1,2 +0,2 @@ | ||
// [node-http2-protocol][homepage] is an implementation of the [HTTP/2 (draft 10)][http2] | ||
// [node-http2-protocol][homepage] is an implementation of the [HTTP/2 (draft 11)][http2] | ||
// framing layer for [node.js][node]. | ||
@@ -31,6 +31,6 @@ // | ||
// [homepage]: https://github.com/molnarg/node-http2 | ||
// [http2]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-10 | ||
// [http2-connheader]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-3.5 | ||
// [http2-stream]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-5 | ||
// [http2-streamstate]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-5.1 | ||
// [http2]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-11 | ||
// [http2-connheader]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-3.5 | ||
// [http2-stream]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-5 | ||
// [http2-streamstate]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-5.1 | ||
// [node]: http://nodejs.org/ | ||
@@ -41,3 +41,3 @@ // [node-stream]: http://nodejs.org/api/stream.html | ||
exports.ImplementedVersion = 'h2-10'; | ||
exports.ImplementedVersion = 'h2-11'; | ||
@@ -44,0 +44,0 @@ exports.Endpoint = require('./endpoint').Endpoint; |
@@ -228,2 +228,4 @@ var assert = require('assert'); | ||
this._onPriority(frame); | ||
} else if (frame.type === 'ALTSVC') { | ||
// TODO | ||
} | ||
@@ -326,3 +328,3 @@ | ||
// [Stream States](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10#section-5.1) | ||
// [Stream States](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11#section-5.1) | ||
// ---------------- | ||
@@ -387,3 +389,3 @@ // | ||
var DATA = false, HEADERS = false, PRIORITY = false; | ||
var DATA = false, HEADERS = false, PRIORITY = false, ALTSVC = false; | ||
var RST_STREAM = false, PUSH_PROMISE = false, WINDOW_UPDATE = false; | ||
@@ -397,2 +399,3 @@ switch(frame.type) { | ||
case 'WINDOW_UPDATE': WINDOW_UPDATE = true; break; | ||
case 'ALTSVC' : ALTSVC = true; break; | ||
} | ||
@@ -540,3 +543,3 @@ | ||
(receiving && this._closedByUs && | ||
(this._closedWithRst || WINDOW_UPDATE || PRIORITY || RST_STREAM))) { | ||
(this._closedWithRst || WINDOW_UPDATE || PRIORITY || RST_STREAM || ALTSVC))) { | ||
/* No state change */ | ||
@@ -543,0 +546,0 @@ } else { |
{ | ||
"name": "http2-protocol", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "A JavaScript implementation of the HTTP/2 framing layer", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
node-http2-protocol | ||
=================== | ||
An HTTP/2 ([draft-ietf-httpbis-http2-10](http://tools.ietf.org/html/draft-ietf-httpbis-http2-10)) | ||
An HTTP/2 ([draft-ietf-httpbis-http2-11](http://tools.ietf.org/html/draft-ietf-httpbis-http2-11)) | ||
framing layer implementaion for node.js. | ||
@@ -53,8 +53,8 @@ | ||
To generate a code coverage report, run `npm test --coverage` (it may be slow, be patient). | ||
Code coverage summary as of version 0.9.0: | ||
Code coverage summary as of version 0.11.0: | ||
``` | ||
Statements : 91.86% ( 1276/1389 ) | ||
Branches : 85.62% ( 524/612 ) | ||
Functions : 92.31% ( 144/156 ) | ||
Lines : 91.83% ( 1270/1383 ) | ||
Statements : 91.66% ( 1363/1487 ) | ||
Branches : 85.48% ( 577/675 ) | ||
Functions : 92.41% ( 146/158 ) | ||
Lines : 91.69% ( 1357/1480 ) | ||
``` | ||
@@ -61,0 +61,0 @@ |
@@ -32,30 +32,30 @@ var expect = require('chai').expect; | ||
string: 'www.foo.com', | ||
buffer: new Buffer('88db6d898b5a44b74f', 'hex') | ||
buffer: new Buffer('89e7cf9bfc1ad7d4db7f', 'hex') | ||
}, { | ||
string: 'éáűőúöüó€', | ||
buffer: new Buffer('13C3A9C3A1C5B1C591C3BAC3B6C3BCC3B3E282AC', 'hex') | ||
buffer: new Buffer('13c3a9c3a1c5b1c591c3bac3b6c3bcc3b3e282ac', 'hex') | ||
}]; | ||
test_huffman_request = { | ||
'GET': 'f77778ff', | ||
'http': 'ce3177', | ||
'/': '0f', | ||
'www.foo.com': 'db6d898b5a44b74f', | ||
'https': 'ce31743f', | ||
'www.bar.com': 'db6d897a1e44b74f', | ||
'no-cache': '63654a1398ff', | ||
'/custom-path.css': '04eb08b7495c88e644c21f', | ||
'custom-key': '4eb08b749790fa7f', | ||
'custom-value': '4eb08b74979a17a8ff' | ||
'GET': 'd5df47', | ||
'http': 'adcebf', | ||
'/': '3f', | ||
'www.foo.com': 'e7cf9bfc1ad7d4db7f', | ||
'https': 'adcebf1f', | ||
'www.bar.com': 'e7cf9bfbd383ea6dbf', | ||
'no-cache': 'b9b9949556bf', | ||
'/custom-path.css': '3ab8e2e6db9af4bab7d58e3f', | ||
'custom-key': '571c5cdb737b2faf', | ||
'custom-value': '571c5cdb73724d9c57' | ||
}; | ||
test_huffman_response = { | ||
'302': '98a7', | ||
'private': '73d5cd111f', | ||
'Mon, 21 OCt 2013 20:13:21 GMT': 'ef6b3a7a0e6e8fa7647a0e534dd072fb0d37b0e6e8f777f8ff', | ||
': https://www.bar.com': 'f6746718ba1ec00db6d897a1e44b74', | ||
'200': '394b', | ||
'Mon, 21 OCt 2013 20:13:22 GMT': 'ef6b3a7a0e6e8fa7647a0e534dd072fb0d37b0e7e8f777f8ff', | ||
'https://www.bar.com': 'ce31743d801b6db12f43c896e9', | ||
'gzip': 'cbd54e', | ||
'302': '4017', | ||
'private': 'bf06724b97', | ||
'Mon, 21 OCt 2013 20:13:21 GMT': 'd6dbb29884de3dce3100a0c4130a262136ad747f', | ||
': https://www.bar.com': '98d5b9d7e331cfcf9f37f7a707d4db7f', | ||
'200': '200f', | ||
'Mon, 21 OCt 2013 20:13:22 GMT': 'd6dbb29884de3dce3100a0c4130a262236ad747f', | ||
'https://www.bar.com': 'adcebf198e7e7cf9bfbd383ea6db', | ||
'gzip': 'abdd97ff', | ||
'foo=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\ | ||
@@ -68,18 +68,3 @@ AAAAAAAAAAAAAAAAAAAAAAAAAALASDJKHQKBZXOQWEOPIUAXQWEOIUAXLJKHQWOEIUAL\ | ||
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ1234 m\ | ||
ax-age=3600; version=1': 'c5adb77efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7\ | ||
efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfb\ | ||
f7efdfbf7efdfbf7efdfbfe5bfc3b7e3fdfbfedfdf5ff9fbfa7dbf5ddf4fafc3f1bf\ | ||
f7f6fd777d3e1f8dffbf97c7fbf7fdbf5f4eef87e37fcbedfaeefa7c3f1bff7f2fb7\ | ||
77e37fefe5f2fefe3bfc3b7edfaeefa7e3e1bff7f331e69fe5bfc3b7e3fdfbfedfdf\ | ||
5ff9fbfa7dbf5ddf4fafc3f1bff7f6fd777d3e1f8dffbf97c7fbf7fdbf5f4eef87e3\ | ||
7fcbedfaeefa7c3f1bff7f2fb777e37fefe5f2fefe3bfc3b7edfaeefa7e3e1bff7f3\ | ||
31e69fe5bfc3b7e3fdfbfedfdf5ff9fbfa7dbf5ddf4fafc3f1bff7f6fd777d3e1f8d\ | ||
ffbf97c7fbf7fdbf5f4eef87e37fcbedfaeefa7c3f1bff7f2fb777e37fefe5f2fefe\ | ||
3bfc3b7edfaeefa7e3e1bff7f331e69fe5bfc3b7e3fdfbfedfdf5ff9fbfa7dbf5ddf\ | ||
4fafc3f1bff7f6fd777d3e1f8dffbf97c7fbf7fdbf5f4eef87e37fcbedfaeefa7c3f\ | ||
1bff7f2fb777e37fefe5f2fefe3bfc3b7edfaeefa7e3e1bff7f331e69ffcff3fcff3\ | ||
fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcf\ | ||
f3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3f\ | ||
cff3fcff3fcff3fcff3fcff3fcff3fcff0c79a7e8d11e72a321b66a4a5eae8e62f82\ | ||
9acb4d', | ||
ax-age=3600; version=1': 'e0d6cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cff5cfb747cfe9f2fb7d3b7f7e9e3f6fcf7f8f97879e7f4fb7e7bfc7c3cf3fa7d7e7f4f97dbf3e3dfe1e79febf6fcf7f8f879e7f4fafdbbfcf3fa7d7ebf4f9e7dba3edf9eff1f3f0cfe9b049107d73edd1f3fa7cbedf4edfdfa78fdbf3dfe3e5e1e79fd3edf9eff1f0f3cfe9f5f9fd3e5f6fcf8f7f879e7fafdbf3dfe3e1e79fd3ebf6eff3cfe9f5fafd3e79f6e8fb7e7bfc7cfc33fa6c12441f5cfb747cfe9f2fb7d3b7f7e9e3f6fcf7f8f97879e7f4fb7e7bfc7c3cf3fa7d7e7f4f97dbf3e3dfe1e79febf6fcf7f8f879e7f4fafdbbfcf3fa7d7ebf4f9e7dba3edf9eff1f3f0cfe9b049107d73edd1f3fa7cbedf4edfdfa78fdbf3dfe3e5e1e79fd3edf9eff1f0f3cfe9f5f9fd3e5f6fcf8f7f879e7fafdbf3dfe3e1e79fd3ebf6eff3cfe9f5fafd3e79f6e8fb7e7bfc7cfc33fa6c12441fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff624880d6a7a664d4b9d1100761b92f0c58dba71', | ||
'foo=ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\ | ||
@@ -92,118 +77,231 @@ ZZZZZZZZZZZZZZZZZZZZZZZZZZLASDJKHQKBZXOQWEOPIUAXQWEOIUAXLJKHQWOEIUAL\ | ||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234 m\ | ||
ax-age=3600; version=1': 'c5adb7fcff3fcff3fcff3fcff3fcff3fcff3fcff3f\ | ||
cff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff\ | ||
3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fcff3fc\ | ||
ff3fcff3e5bfc3b7e3fdfbfedfdf5ff9fbfa7dbf5ddf4fafc3f1bff7f6fd777d3e1f\ | ||
8dffbf97c7fbf7fdbf5f4eef87e37fcbedfaeefa7c3f1bff7f2fb777e37fefe5f2fe\ | ||
fe3bfc3b7edfaeefa7e3e1bff7f331e69fe5bfc3b7e3fdfbfedfdf5ff9fbfa7dbf5d\ | ||
df4fafc3f1bff7f6fd777d3e1f8dffbf97c7fbf7fdbf5f4eef87e37fcbedfaeefa7c\ | ||
3f1bff7f2fb777e37fefe5f2fefe3bfc3b7edfaeefa7e3e1bff7f331e69fe5bfc3b7\ | ||
e3fdfbfedfdf5ff9fbfa7dbf5ddf4fafc3f1bff7f6fd777d3e1f8dffbf97c7fbf7fd\ | ||
bf5f4eef87e37fcbedfaeefa7c3f1bff7f2fb777e37fefe5f2fefe3bfc3b7edfaeef\ | ||
a7e3e1bff7f331e69fe5bfc3b7e3fdfbfedfdf5ff9fbfa7dbf5ddf4fafc3f1bff7f6\ | ||
fd777d3e1f8dffbf97c7fbf7fdbf5f4eef87e37fcbedfaeefa7c3f1bff7f2fb777e3\ | ||
7fefe5f2fefe3bfc3b7edfaeefa7e3e1bff7f331e69f7efdfbf7efdfbf7efdfbf7ef\ | ||
dfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7efdfbf7\ | ||
efdfbf7efdfbf7efdfbf7efdfbf7efdfbcc79a7e8d11e72a321b66a4a5eae8e62f82\ | ||
9acb4d' | ||
ax-age=3600; version=1': 'e0d6cffbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7fbfdfeff7f5cfb747cfe9f2fb7d3b7f7e9e3f6fcf7f8f97879e7f4fb7e7bfc7c3cf3fa7d7e7f4f97dbf3e3dfe1e79febf6fcf7f8f879e7f4fafdbbfcf3fa7d7ebf4f9e7dba3edf9eff1f3f0cfe9b049107d73edd1f3fa7cbedf4edfdfa78fdbf3dfe3e5e1e79fd3edf9eff1f0f3cfe9f5f9fd3e5f6fcf8f7f879e7fafdbf3dfe3e1e79fd3ebf6eff3cfe9f5fafd3e79f6e8fb7e7bfc7cfc33fa6c12441f5cfb747cfe9f2fb7d3b7f7e9e3f6fcf7f8f97879e7f4fb7e7bfc7c3cf3fa7d7e7f4f97dbf3e3dfe1e79febf6fcf7f8f879e7f4fafdbbfcf3fa7d7ebf4f9e7dba3edf9eff1f3f0cfe9b049107d73edd1f3fa7cbedf4edfdfa78fdbf3dfe3e5e1e79fd3edf9eff1f0f3cfe9f5f9fd3e5f6fcf8f7f879e7fafdbf3dfe3e1e79fd3ebf6eff3cfe9f5fafd3e79f6e8fb7e7bfc7cfc33fa6c124419f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7cf9f3e7ce24880d6a7a664d4b9d1100761b92f0c58dba71' | ||
}; | ||
var test_headers = [{ | ||
// literal w/index, name index | ||
header: { | ||
name: 1, | ||
value: 'GET', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('02' + '03474554', 'hex') | ||
buffer: new Buffer('42' + '03474554', 'hex') | ||
}, { | ||
// literal w/index, name index | ||
header: { | ||
name: 6, | ||
value: 'http', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('07' + '83ce3177', 'hex') | ||
buffer: new Buffer('47' + '83ADCEBF', 'hex') | ||
}, { | ||
// literal w/index, name index | ||
header: { | ||
name: 5, | ||
value: '/', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('06' + '012f', 'hex') | ||
buffer: new Buffer('46' + '012F', 'hex') | ||
}, { | ||
// literal w/index, name index | ||
header: { | ||
name: 3, | ||
value: 'www.foo.com', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('04' + '88db6d898b5a44b74f', 'hex') | ||
buffer: new Buffer('44' + '89E7CF9BFC1AD7D4DB7F', 'hex') | ||
}, { | ||
// literal w/index, name index | ||
header: { | ||
name: 2, | ||
value: 'https', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('03' + '84ce31743f', 'hex') | ||
buffer: new Buffer('43' + '84ADCEBF1F', 'hex') | ||
}, { | ||
// literal w/index, name index | ||
header: { | ||
name: 1, | ||
value: 'www.bar.com', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('02' + '88db6d897a1e44b74f', 'hex') | ||
buffer: new Buffer('42' + '89E7CF9BFBD383EA6DBF', 'hex') | ||
}, { | ||
// literal w/index, name index | ||
header: { | ||
name: 28, | ||
name: 29, | ||
value: 'no-cache', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('1d' + '8663654a1398ff', 'hex') | ||
buffer: new Buffer('5e' + '86B9B9949556BF', 'hex') | ||
}, { | ||
// indexed | ||
header: { | ||
name: 3, | ||
value: 3, | ||
index: false | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('84', 'hex') | ||
}, { | ||
// indexed | ||
header: { | ||
name: 5, | ||
value: 5, | ||
index: false | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('86', 'hex') | ||
}, { | ||
// literal w/index, name index | ||
header: { | ||
name: 4, | ||
value: '/custom-path.css', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('05' + '8b04eb08b7495c88e644c21f', 'hex') | ||
buffer: new Buffer('45' + '8C3AB8E2E6DB9AF4BAB7D58E3F', 'hex') | ||
}, { | ||
// literal w/index, new name & value | ||
header: { | ||
name: 'custom-key', | ||
value: 'custom-value', | ||
index: true | ||
index: true, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('00' + '884eb08b749790fa7f' + '894eb08b74979a17a8ff', 'hex') | ||
buffer: new Buffer('40' + '88571C5CDB737B2FAF' + '89571C5CDB73724D9C57', 'hex') | ||
}, { | ||
// indexed | ||
header: { | ||
name: 2, | ||
value: 2, | ||
index: false | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('83', 'hex') | ||
}, { | ||
// indexed | ||
header: { | ||
name: 6, | ||
value: 6, | ||
index: false | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('87', 'hex') | ||
}, { | ||
// Literal w/o index, name index | ||
header: { | ||
name: 6, | ||
value: "whatever", | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('07' + '86E75A5CBE4BC3', 'hex') | ||
}, { | ||
// Literal w/o index, new name & value | ||
header: { | ||
name: "foo", | ||
value: "bar", | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('00' + '03666F6F' + '03626172', 'hex') | ||
}, { | ||
// Literal never indexed, name index | ||
header: { | ||
name: 6, | ||
value: "whatever", | ||
index: false, | ||
mustNeverIndex: true, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('17' + '86E75A5CBE4BC3', 'hex') | ||
}, { | ||
// Literal never indexed, new name & value | ||
header: { | ||
name: "foo", | ||
value: "bar", | ||
index: false, | ||
mustNeverIndex: true, | ||
contextUpdate: false, | ||
clearReferenceSet: false, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('10' + '03666F6F' + '03626172', 'hex') | ||
}, { | ||
header: { | ||
name: -1, | ||
value: -1, | ||
index: true | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: true, | ||
clearReferenceSet: true, | ||
newMaxSize: 0 | ||
}, | ||
buffer: new Buffer('8080', 'hex') | ||
buffer: new Buffer('30', 'hex') | ||
}, { | ||
header: { | ||
name: -1, | ||
value: -1, | ||
index: false, | ||
mustNeverIndex: false, | ||
contextUpdate: true, | ||
clearReferenceSet: false, | ||
newMaxSize: 100 | ||
}, | ||
buffer: new Buffer('2F55', 'hex') | ||
}]; | ||
@@ -247,5 +345,2 @@ | ||
}, { | ||
headers: {}, | ||
buffer: test_headers[13].buffer | ||
}, { | ||
headers: { | ||
@@ -363,3 +458,3 @@ ':status': '200', | ||
var decompressor = new Decompressor(util.log, 'REQUEST'); | ||
for (var i = 0; i < 5; i++) { | ||
for (var i = 0; i < test_header_sets.length - 1; i++) { | ||
var header_set = test_header_sets[i]; | ||
@@ -366,0 +461,0 @@ expect(decompressor.decompress(header_set.buffer)).to.deep.equal(header_set.headers); |
@@ -10,4 +10,4 @@ var expect = require('chai').expect; | ||
DATA: ['data'], | ||
HEADERS: ['priority', 'data'], | ||
PRIORITY: ['priority'], | ||
HEADERS: ['priority_information', 'data'], | ||
PRIORITY: ['priority_information'], | ||
RST_STREAM: ['error'], | ||
@@ -26,3 +26,3 @@ SETTINGS: ['settings'], | ||
flags: { END_STREAM: false, END_SEGMENT: false, RESERVED4: false, | ||
RESERVED8: false, PAD_LOW: false, PAD_HIGH: false }, | ||
PAD_LOW: false, PAD_HIGH: false }, | ||
stream: 10, | ||
@@ -39,3 +39,4 @@ | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PRIORITY: false, PAD_LOW: false, PAD_HIGH: false }, | ||
PAD_LOW: false, PAD_HIGH: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: false }, | ||
stream: 15, | ||
@@ -51,22 +52,81 @@ | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PRIORITY: true, PAD_LOW: false, PAD_HIGH: false }, | ||
PAD_LOW: false, PAD_HIGH: false, PRIORITY_GROUP: true, | ||
PRIORITY_DEPENDENCY: false }, | ||
stream: 15, | ||
priorityGroup: 23, | ||
groupWeight: 5, | ||
priority: 3, | ||
data: new Buffer('12345678', 'hex') | ||
}, | ||
buffer: new Buffer('0008' + '01' + '08' + '0000000F' + '00000003' + '12345678', 'hex') | ||
buffer: new Buffer('0009' + '01' + '20' + '0000000F' + '00000017' + '05' + '12345678', 'hex') | ||
}, { | ||
frame: { | ||
type: 'HEADERS', | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PAD_LOW: false, PAD_HIGH: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: true }, | ||
stream: 15, | ||
priorityDependency: 23, | ||
exclusiveDependency: false, | ||
data: new Buffer('12345678', 'hex') | ||
}, | ||
buffer: new Buffer('0008' + '01' + '40' + '0000000F' + '00000017' + '12345678', 'hex') | ||
}, { | ||
frame: { | ||
type: 'HEADERS', | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PAD_LOW: false, PAD_HIGH: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: true }, | ||
stream: 15, | ||
priorityDependency: 23, | ||
exclusiveDependency: true, | ||
data: new Buffer('12345678', 'hex') | ||
}, | ||
buffer: new Buffer('0008' + '01' + '40' + '0000000F' + '80000017' + '12345678', 'hex') | ||
}, { | ||
frame: { | ||
type: 'PRIORITY', | ||
flags: { }, | ||
flags: { RESERVED1: false, RESERVED2: false, RESERVED4: false, | ||
RESERVED8: false, RESERVED16: false, PRIORITY_GROUP: true, | ||
PRIORITY_DEPENDENCY: false }, | ||
stream: 10, | ||
priority: 3 | ||
priorityGroup: 23, | ||
groupWeight: 5 | ||
}, | ||
buffer: new Buffer('0004' + '02' + '00' + '0000000A' + '00000003', 'hex') | ||
buffer: new Buffer('0005' + '02' + '20' + '0000000A' + '00000017' + '05', 'hex') | ||
}, { | ||
frame: { | ||
type: 'PRIORITY', | ||
flags: { RESERVED1: false, RESERVED2: false, RESERVED4: false, | ||
RESERVED8: false, RESERVED16: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: true }, | ||
stream: 10, | ||
priorityDependency: 23, | ||
exclusiveDependency: false | ||
}, | ||
buffer: new Buffer('0004' + '02' + '40' + '0000000A' + '00000017', 'hex') | ||
}, { | ||
frame: { | ||
type: 'PRIORITY', | ||
flags: { RESERVED1: false, RESERVED2: false, RESERVED4: false, | ||
RESERVED8: false, RESERVED16: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: true }, | ||
stream: 10, | ||
priorityDependency: 23, | ||
exclusiveDependency: true | ||
}, | ||
buffer: new Buffer('0004' + '02' + '40' + '0000000A' + '80000017', 'hex') | ||
}, { | ||
frame: { | ||
type: 'RST_STREAM', | ||
@@ -101,3 +161,4 @@ flags: { }, | ||
type: 'PUSH_PROMISE', | ||
flags: { RESERVED1: false, RESERVED2: false, END_PUSH_PROMISE: false }, | ||
flags: { RESERVED1: false, RESERVED2: false, END_PUSH_PROMISE: false, | ||
PAD_LOW: false, PAD_HIGH: false }, | ||
stream: 15, | ||
@@ -144,3 +205,3 @@ | ||
flags: { RESERVED1: false, RESERVED2: false, END_HEADERS: true, | ||
RESERVED8: false, PAD_LOW: false, PAD_HIGH: false }, | ||
PAD_LOW: false, PAD_HIGH: false }, | ||
stream: 10, | ||
@@ -152,2 +213,28 @@ | ||
buffer: new Buffer('0004' + '09' + '04' + '0000000A' + '12345678', 'hex') | ||
}, { | ||
frame: { | ||
type: 'ALTSVC', | ||
flags: { }, | ||
stream: 0, | ||
maxAge: 31536000, | ||
port: 4443, | ||
protocolID: "h2", | ||
host: "altsvc.example.com", | ||
origin: "" | ||
}, | ||
buffer: new Buffer('001D' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D', 'hex') | ||
}, { | ||
frame: { | ||
type: 'ALTSVC', | ||
flags: { }, | ||
stream: 0, | ||
maxAge: 31536000, | ||
port: 4443, | ||
protocolID: "h2", | ||
host: "altsvc.example.com", | ||
origin: "https://onlyme.example.com" | ||
}, | ||
buffer: new Buffer('0037' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D' + '68747470733A2F2F6F6E6C796D652E6578616D706C652E636F6D', 'hex') | ||
}]; | ||
@@ -160,3 +247,3 @@ | ||
flags: { END_STREAM: false, END_SEGMENT: false, RESERVED4: false, | ||
RESERVED8: false, PAD_LOW: true, PAD_HIGH: false }, | ||
PAD_LOW: true, PAD_HIGH: false }, | ||
stream: 10, | ||
@@ -166,3 +253,3 @@ data: new Buffer('12345678', 'hex') | ||
// length + type + flags + stream + pad_low control + content + padding | ||
buffer: new Buffer('000B' + '00' + '10' + '0000000A' + '06' + '12345678' + '000000000000', 'hex') | ||
buffer: new Buffer('000B' + '00' + '08' + '0000000A' + '06' + '12345678' + '000000000000', 'hex') | ||
@@ -173,3 +260,4 @@ }, { | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PRIORITY: false, PAD_LOW: true, PAD_HIGH: false }, | ||
PAD_LOW: true, PAD_HIGH: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: false }, | ||
stream: 15, | ||
@@ -179,3 +267,4 @@ | ||
}, | ||
buffer: new Buffer('000B' + '01' + '10' + '0000000F' + '06' + '12345678' + '000000000000', 'hex') | ||
// length + type + flags + stream + pad_low control + data + padding | ||
buffer: new Buffer('000B' + '01' + '08' + '0000000F' + '06' + '12345678' + '000000000000', 'hex') | ||
@@ -186,15 +275,48 @@ }, { | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PRIORITY: true, PAD_LOW: true, PAD_HIGH: false }, | ||
PAD_LOW: true, PAD_HIGH: false, PRIORITY_GROUP: true, | ||
PRIORITY_DEPENDENCY: false }, | ||
stream: 15, | ||
priorityGroup: 23, | ||
groupWeight: 5, | ||
priority: 3, | ||
data: new Buffer('12345678', 'hex') | ||
}, | ||
buffer: new Buffer('000F' + '01' + '18' + '0000000F' + '06' + '00000003' + '12345678' + '000000000000', 'hex') | ||
// length + type + flags + stream + pad_low control + priority group + group weight + data + padding | ||
buffer: new Buffer('0010' + '01' + '28' + '0000000F' + '06' + '00000017' + '05' + '12345678' + '000000000000', 'hex') | ||
}, { | ||
frame: { | ||
type: 'HEADERS', | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PAD_LOW: true, PAD_HIGH: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: true }, | ||
stream: 15, | ||
priorityDependency: 23, | ||
exclusiveDependency: false, | ||
data: new Buffer('12345678', 'hex') | ||
}, | ||
// length + type + flags + stream + pad_low control + priority dependency + data + padding | ||
buffer: new Buffer('000F' + '01' + '48' + '0000000F' + '06' + '00000017' + '12345678' + '000000000000', 'hex') | ||
}, { | ||
frame: { | ||
type: 'HEADERS', | ||
flags: { END_STREAM: false, END_SEGMENT: false, END_HEADERS: false, | ||
PAD_LOW: true, PAD_HIGH: false, PRIORITY_GROUP: false, | ||
PRIORITY_DEPENDENCY: true }, | ||
stream: 15, | ||
priorityDependency: 23, | ||
exclusiveDependency: true, | ||
data: new Buffer('12345678', 'hex') | ||
}, | ||
// length + type + flags + stream + pad_low control + priority dependency + data + padding | ||
buffer: new Buffer('000F' + '01' + '48' + '0000000F' + '06' + '80000017' + '12345678' + '000000000000', 'hex') | ||
}, { | ||
frame: { | ||
type: 'CONTINUATION', | ||
flags: { RESERVED1: false, RESERVED2: false, END_HEADERS: true, | ||
RESERVED8: false, PAD_LOW: true, PAD_HIGH: false }, | ||
PAD_LOW: true, PAD_HIGH: false }, | ||
stream: 10, | ||
@@ -204,4 +326,17 @@ | ||
}, | ||
// length + type + flags + stream + content | ||
buffer: new Buffer('000B' + '09' + '14' + '0000000A' + '06' + '12345678' + '000000000000', 'hex') | ||
// length + type + flags + stream + pad_low control + data + padding | ||
buffer: new Buffer('000B' + '09' + '0C' + '0000000A' + '06' + '12345678' + '000000000000', 'hex') | ||
}, { | ||
frame: { | ||
type: 'PUSH_PROMISE', | ||
flags: { RESERVED1: false, RESERVED2: false, END_PUSH_PROMISE: false, | ||
PAD_LOW: true, PAD_HIGH: false }, | ||
stream: 15, | ||
promised_stream: 3, | ||
data: new Buffer('12345678', 'hex') | ||
}, | ||
// length + type + flags + stream + pad_low control + promised stream + data + padding | ||
buffer: new Buffer('000F' + '05' + '08' + '0000000F' + '06' + '00000003' + '12345678' + '000000000000', 'hex') | ||
}]; | ||
@@ -208,0 +343,0 @@ for (var idx = 0; idx < padded_test_frames.length; idx++) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
247225
5756