Socket
Socket
Sign inDemoInstall

http2-protocol

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 0.9.0

7

HISTORY.md
Version history
===============
### 0.9.0 (2013-12-25) ###
* Upgrade to the latest draft: [draft-ietf-httpbis-http2-09][draft-09]
* [Tarball](https://github.com/molnarg/node-http2-protocol/archive/node-http2-protocol-0.9.0.tar.gz)
[draft-09]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-09
### 0.7.0 (2013-11-10) ###

@@ -5,0 +12,0 @@

119

lib/compressor.js

@@ -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-04
// [http2-compression]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05

@@ -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-04#section-3.1.2
// [Static Table]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04#appendix-B
// [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
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-04#section-3.1.3
// [referenceset]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#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-04#section-3.3
// [tablemgmt]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#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-04#appendix-B)
// [The Static Table](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#appendix-B)
// ------------------
// [statictable]:http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04#appendix-B
// [statictable]:http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#appendix-B

@@ -199,2 +199,3 @@ // The table is generated with feeding the table from the spec to the following sed command:

[ 'from' , '' ],
[ 'host' , '' ],
[ 'if-match' , '' ],

@@ -254,3 +255,3 @@ [ 'if-modified-since' , '' ],

// `execute(rep)` executes the given [header representation][representation].
// [representation]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04#section-3.1.4
// [representation]: http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-3.1.4

@@ -265,2 +266,4 @@ // The *JavaScript object representation* of a header representation:

//
// *Important:* to ease the indexing of the header table, indexes start at 0 instead of 1.
//
// Examples:

@@ -270,2 +273,3 @@ //

// { name: 2 , value: 2 , index: false }
// { name: -1 , value: -1 , index: false } // reference set emptying
// Literal:

@@ -281,2 +285,5 @@ // { name: 2 , value: 'X', index: false } // without indexing

// * An _indexed representation_ with an index value of 0 (in our representation, it means -1)
// entails the following actions:
// * The reference set is emptied.
// * An _indexed representation_ corresponding to an entry _present_ in the reference set

@@ -299,5 +306,13 @@ // entails the following actions:

if (entry.reference) {
if (index == -1) {
for (var i = 0; i < this._table.length; i++) {
this._table[i].reference = false;
}
}
else if (entry.reference) {
entry.reference = false;
} else {
}
else {
pair = entry.slice();

@@ -354,3 +369,3 @@ this.push(pair);

// * [emits the reference set](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04#section-3.2.2)
// * [emits the reference set](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-3.2.2)
for (var index = 0; index < this._table.length; index++) {

@@ -446,3 +461,3 @@ var entry = this._table[index];

if (fullMatch !== -1) {
rep = { name: fullMatch, value: fullMatch, index: -1 };
rep = { name: fullMatch, value: fullMatch, index: false };

@@ -512,3 +527,3 @@ if (!entry.reference) {

if (entry.reference && !entry.keep && !entry.emitted) {
this.send({ name: index, value: index, index: -1 });
this.send({ name: index, value: index, index: false });
entry.reference = false;

@@ -523,3 +538,3 @@ }

// [Detailed Format](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04#section-4)
// [Detailed Format](http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05#section-4)
// -----------------

@@ -1367,5 +1382,6 @@

if (representation === representations.indexed) {
buffers.push(HeaderSetCompressor.integer(header.value, representation.prefix));
buffers.push(HeaderSetCompressor.integer(header.value + 1, representation.prefix));
}
} else {
else {
if (typeof header.name === 'number') {

@@ -1377,3 +1393,2 @@ buffers.push(HeaderSetCompressor.integer(header.name + 1, representation.prefix));

}
buffers.push(HeaderSetCompressor.string(header.value, huffmanTable));

@@ -1400,6 +1415,7 @@ }

if (representation === representations.indexed) {
header.value = header.name = HeaderSetDecompressor.integer(buffer, representation.prefix);
header.value = header.name = HeaderSetDecompressor.integer(buffer, representation.prefix) - 1;
header.index = false;
}
} else {
else {
header.name = HeaderSetDecompressor.integer(buffer, representation.prefix) - 1;

@@ -1409,5 +1425,3 @@ if (header.name === -1) {

}
header.value = HeaderSetDecompressor.string(buffer, huffmanTable);
header.index = (representation === representations.literalIncremental);

@@ -1471,8 +1485,31 @@ }

var value = headers[name];
name = String(name).toLowerCase();
// * To allow for better compression efficiency, the Cookie header field MAY be split into
// separate header fields, each with one or more cookie-pairs.
if (name == 'cookie') {
if (!(value instanceof Array)) {
value = [value]
}
value = Array.prototype.concat.apply([], value.map(function(cookie) {
return String(cookie).split(';').map(trim)
}));
}
// * To preserve the order of a comma-separated list, the ordered values for a single header
// field name appearing in different header fields are concatenated into a single value.
// A zero-valued octet (0x0) is used to delimit multiple values.
// * Header fields containing multiple values MUST be concatenated into a single value unless
// the ordering of that header field is known to be not significant.
// * Currently, only the Cookie header is considered to be order-insensitive.
if ((value instanceof Array) && (name !== 'cookie')) {
value = value.join('\0');
}
if (value instanceof Array) {
for (var i = 0; i< value.length; i++) {
compressor.write([String(name), String(value[i])]);
for (var i = 0; i < value.length; i++) {
compressor.write([name, String(value[i])]);
}
} else {
compressor.write([String(name), String(value)]);
compressor.write([name, String(value)]);
}

@@ -1573,14 +1610,26 @@ }

var name = pair[0];
var value = pair[1];
if (name in headers) {
if (headers[name] instanceof Array) {
headers[name].push(value);
// * After decompression, header fields that have values containing zero octets (0x0) MUST be
// split into multiple header fields before being processed.
var values = pair[1].split('\0');
for (var i = 0; i < values.length; i++) {
var value = values[i];
if (name in headers) {
if (headers[name] instanceof Array) {
headers[name].push(value);
} else {
headers[name] = [headers[name], value];
}
} else {
headers[name] = [headers[name], value];
headers[name] = value;
}
} else {
headers[name] = value;
}
}
// * If there are multiple Cookie header fields after decompression, these MUST be concatenated
// into a single octet string using the two octet delimiter of 0x3B, 0x20 (the ASCII
// string "; ").
if (('cookie' in headers) && (headers['cookie'] instanceof Array)) {
headers['cookie'] = headers['cookie'].join('; ')
}
return headers;

@@ -1606,3 +1655,3 @@ };

this._inProgress = true;
this._base = frame;
this._base = util._extend({}, frame);
this._frames = [frame];

@@ -1630,3 +1679,3 @@ }

}
this.push(util._extend({ headers: headers }, this._base));
this.push(util._extend(this._base, { headers: headers }));
this._inProgress = false;

@@ -1667,1 +1716,5 @@ }

}
function trim(string) {
return string.trim()
}

@@ -26,3 +26,3 @@ var assert = require('assert');

//
// [1]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-04#section-6.9.2
// [1]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.9.2

@@ -29,0 +29,0 @@ // API for child classes

@@ -146,3 +146,3 @@ // The framer consists of two [Transform Stream][1] subclasses that operate in [object mode][2]:

// [Frame Header](http://http2.github.io/http2-spec/#FrameHeader)
// [Frame Header](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-4.1)
// --------------------------------------------------------------

@@ -263,3 +263,3 @@ //

// [DATA Frames](http://http2.github.io/http2-spec/#DataFrames)
// [DATA Frames](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.1)
// ------------------------------------------------------------

@@ -292,3 +292,3 @@ //

// [HEADERS](http://http2.github.io/http2-spec/#HEADERS)
// [HEADERS](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.2)
// --------------------------------------------------------------

@@ -347,3 +347,3 @@ //

// [PRIORITY](http://http2.github.io/http2-spec/#PRIORITY)
// [PRIORITY](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.3)
// -------------------------------------------------------

@@ -379,3 +379,3 @@ //

// [RST_STREAM](http://http2.github.io/http2-spec/#RST_STREAM)
// [RST_STREAM](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.4)
// -----------------------------------------------------------

@@ -414,3 +414,3 @@ //

// [SETTINGS](http://http2.github.io/http2-spec/#SETTINGS)
// [SETTINGS](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.5)
// -------------------------------------------------------

@@ -516,3 +516,3 @@ //

// [PUSH_PROMISE](http://http2.github.io/http2-spec/#PUSH_PROMISE)
// [PUSH_PROMISE](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.6)
// ---------------------------------------------------------------

@@ -563,3 +563,3 @@ //

// [PING](http://http2.github.io/http2-spec/#PING)
// [PING](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.7)
// -----------------------------------------------

@@ -594,3 +594,3 @@ //

// [GOAWAY](http://http2.github.io/http2-spec/#GOAWAY)
// [GOAWAY](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.8)
// ---------------------------------------------------

@@ -642,3 +642,3 @@ //

// [WINDOW_UPDATE](http://http2.github.io/http2-spec/#WINDOW_UPDATE)
// [WINDOW_UPDATE](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.9)
// -----------------------------------------------------------------

@@ -675,3 +675,3 @@ //

// [CONTINUATION](http://http2.github.io/http2-spec/#CONTINUATION)
// [CONTINUATION](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-6.10)
// ------------------------------------------------------------

@@ -701,3 +701,3 @@ //

// [Error Codes](http://http2.github.io/http2-spec/#ErrorCodes)
// [Error Codes](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-7)
// ------------------------------------------------------------

@@ -704,0 +704,0 @@

@@ -1,2 +0,2 @@

// [node-http2-protocol][homepage] is an implementation of the [HTTP/2 (draft 06)][http2]
// [node-http2-protocol][homepage] is an implementation of the [HTTP/2 (draft 09)][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-06
// [http2-connheader]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-06#section-3.5
// [http2-stream]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-06#section-5
// [http2-streamstate]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-06#section-5.1
// [http2]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-09
// [http2-connheader]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-3.5
// [http2-stream]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-5
// [http2-streamstate]: http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-5.1
// [node]: http://nodejs.org/

@@ -37,0 +37,0 @@ // [node-stream]: http://nodejs.org/api/stream.html

@@ -325,3 +325,3 @@ var assert = require('assert');

// [Stream States](http://tools.ietf.org/id/draft-unicorn-httpbis-http2-01.html#StreamStates)
// [Stream States](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-5.1)
// ----------------

@@ -328,0 +328,0 @@ //

{
"name": "http2-protocol",
"version": "0.7.0",
"version": "0.9.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-07](http://tools.ietf.org/html/draft-ietf-httpbis-http2-07))
An HTTP/2 ([draft-ietf-httpbis-http2-09](http://tools.ietf.org/html/draft-ietf-httpbis-http2-09))
framing layer implementaion for node.js.

@@ -43,3 +43,3 @@

before releasing a new version. To regenerate them manually, run `npm run-script prepublish`.
There's a hosted version which is located [here](http://molnarg.github.io/node-http2/doc/).
There's a hosted version which is located [here](http://molnarg.github.io/node-http2-protocol/doc/).

@@ -56,6 +56,6 @@ ### Running the tests ###

```
Statements : 92.39% ( 1165/1261 )
Branches : 86.57% ( 477/551 )
Functions : 91.22% ( 135/148 )
Lines : 92.35% ( 1159/1255 )
Statements : 92.43% ( 1257/1360 )
Branches : 86.36% ( 500/579 )
Functions : 90.12% ( 146/162 )
Lines : 92.39% ( 1251/1354 )
```

@@ -62,0 +62,0 @@

@@ -161,3 +161,3 @@ var expect = require('chai').expect;

},
buffer: new Buffer('83', 'hex')
buffer: new Buffer('84', 'hex')
}, {

@@ -169,3 +169,3 @@ header: {

},
buffer: new Buffer('85', 'hex')
buffer: new Buffer('86', 'hex')
}, {

@@ -191,3 +191,3 @@ header: {

},
buffer: new Buffer('82', 'hex')
buffer: new Buffer('83', 'hex')
}, {

@@ -199,3 +199,10 @@ header: {

},
buffer: new Buffer('86', 'hex')
buffer: new Buffer('87', 'hex')
}, {
header: {
name: -1,
value: -1,
index: false
},
buffer: new Buffer('80', 'hex')
}];

@@ -239,6 +246,10 @@

}, {
headers: {},
buffer: test_headers[13].buffer
}, {
headers: {
':status': '200',
'user-agent': 'my-user-agent',
'cookie': ['first', 'second', 'third', 'third'],
'cookie': 'first; second; third; third; fourth',
'multiple': ['first', 'second', 'third', 'third; fourth'],
'verylong': (new Buffer(9000)).toString('hex')

@@ -351,3 +362,3 @@ }

var decompressor = new Decompressor(util.log, 'REQUEST');
for (var i = 0; i < 4; i++) {
for (var i = 0; i < 5; i++) {
var header_set = test_header_sets[i];

@@ -354,0 +365,0 @@ expect(decompressor.decompress(header_set.buffer)).to.deep.equal(header_set.headers);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc