Bug 1429973 part 0 - Update node-http2 to v3.3.8 for required bugfix. r=bagder

MozReview-Commit-ID: 60AQesLEA3K

--HG--
extra : rebase_source : 06d45452136e599e9116106712b1e8ac2c5aa0a9
This commit is contained in:
Nicholas Hurley 2018-02-15 10:12:38 -08:00
parent 1e1e41ffe2
commit d956bcaac3
8 changed files with 36 additions and 10 deletions

View File

@ -1,6 +1,12 @@
Version history
===============
### 3.3.8 (2018-02-15) ###
* Fix an issue with HTTP trailers and END_STREAM.
### 3.3.7 (2017-09-21) ###
* Mark as incompatible with node >= 9.0.0 (to encourage using the built-in http2 module available by default in node >= 9.0.0).
### 3.3.6 (2016-09-16) ###
* We were not appropriately sending HPACK context updates when receiving SETTINGS_HEADER_TABLE_SIZE. This release fixes that bug.

View File

@ -6,6 +6,8 @@ client and server implementation for node.js.
![Travis CI status](https://travis-ci.org/molnarg/node-http2.svg?branch=master)
**NOTE WELL** This package is officially deprecated. As of node 9.0.0, there is an 'http2' package built-in. You should use that one instead.
Installation
------------

View File

@ -345,7 +345,7 @@ OutgoingMessage.prototype._finish = function _finish() {
if (this.request) {
this.request.addTrailers(this._trailers);
} else {
this.stream.headers(this._trailers);
this.stream.trailers(this._trailers);
}
}
this.finished = true;
@ -360,7 +360,7 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
return this.emit('error', new Error('Can\'t set headers after they are sent.'));
} else {
name = name.toLowerCase();
if (deprecatedHeaders.includes(name)) {
if (deprecatedHeaders.indexOf(name) !== -1) {
return this.emit('error', new Error('Cannot set deprecated header: ' + name));
}
this._headers[name] = value;

View File

@ -87,13 +87,13 @@ Flow.prototype._write = function _write(frame, encoding, callback) {
}
if ((frame.type === 'DATA') && (frame.data.length > 0)) {
this._receive(frame, () => {
this._receive(frame, function() {
this._received += frame.data.length;
if (!this._restoreWindowTimer) {
this._restoreWindowTimer = setImmediate(this._restoreWindow.bind(this));
}
callback();
});
}.bind(this));
}
else {

View File

@ -62,6 +62,7 @@ function Stream(log, connection) {
this._initializeState();
this.connection = connection;
this.sentEndStream = false;
}
Stream.prototype = Object.create(Duplex.prototype, { constructor: { value: Stream } });
@ -106,6 +107,16 @@ Stream.prototype.headers = function headers(headers) {
});
};
Stream.prototype.trailers = function trailers(trailers) {
this.sentEndStream = true;
this._pushUpstream({
type: 'HEADERS',
flags: {'END_STREAM': true},
stream: this.id,
headers: trailers
});
};
Stream.prototype._onHeaders = function _onHeaders(frame) {
if (frame.priority !== undefined) {
this.priority(frame.priority, true);
@ -342,6 +353,13 @@ Stream.prototype._finishing = function _finishing() {
stream: this.id,
data: emptyBuffer
};
if (this.sentEndStream) {
this._log.debug('Already sent END_STREAM, not sending again.');
return;
}
this.sentEndStream = true;
var lastFrame = this.upstream.getLastQueuedFrame();
if (lastFrame && ((lastFrame.type === 'DATA') || (lastFrame.type === 'HEADERS'))) {
this._log.debug({ frame: lastFrame }, 'Marking last frame with END_STREAM flag.');

View File

@ -1,10 +1,10 @@
{
"name": "http2",
"version": "3.3.6",
"version": "3.3.8",
"description": "An HTTP/2 client and server implementation",
"main": "lib/index.js",
"engines" : {
"node" : ">=0.12.0"
"engines": {
"node": ">=0.12.0 <9.0.0"
},
"devDependencies": {
"istanbul": "*",

View File

@ -229,7 +229,7 @@ describe('flow.js', function() {
this.emit('end_stream');
}
if (frame.type === 'BLOCKED') {
setTimeout(() => {
setTimeout(function() {
this._push({
type: 'WINDOW_UPDATE',
flags: {},
@ -237,7 +237,7 @@ describe('flow.js', function() {
window_size: this._received
});
this._received = 0;
}, 20);
}.bind(this), 20);
}
callback();
};

View File

@ -23,7 +23,7 @@ function execute_sequence(stream, sequence, done) {
var emit = stream.emit, events = [];
stream.emit = function(name) {
if (recorded_events.includes(name)) {
if (recorded_events.indexOf(name) !== -1) {
events.push({ name: name, data: Array.prototype.slice.call(arguments, 1) });
}
return emit.apply(this, arguments);