Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Commit

Permalink
http2: fixups after rebasing from nodejs/node master
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Jul 10, 2017
1 parent 8ea8668 commit 5473c35
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 18 deletions.
4 changes: 4 additions & 0 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

/* eslint-disable no-use-before-define */

const binding = process.binding('http2');
const debug = require('util').debuglog('http2');
const assert = require('assert');
Expand Down Expand Up @@ -2254,3 +2256,5 @@ module.exports = {
createSecureServer,
connect
};

/* eslint-enable no-use-before-define */
23 changes: 13 additions & 10 deletions test/parallel/test-http2-client-stream-destroy-before-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ const server = h2.createServer();
// depending on the OS. The determination is based largely on operating
// system specific timings
server.on('stream', (stream) => {
stream.on('error', common.expectsError({
code: 'ERR_HTTP2_STREAM_ERROR',
type: Error,
message: 'Stream closed with error code 2'
}));
// Do not wrap in a must call or use common.expectsError (which now uses
// must call). The error may or may not be reported depending on operating
// system specific timings.
stream.on('error', (err) => {
if (err) {
assert.strictEqual(err.code, 'ERR_HTTP2_STREAM_ERROR');
assert.strictEqual(err.message, 'Stream closed with error code 2');
}
});
stream.respond({});
stream.end();
});
Expand All @@ -31,19 +35,18 @@ server.on('listening', common.mustCall(() => {
const err = new Error('test');
req.destroy(err);

req.on('error', common.mustCall((e) => {
if (e.code === 'ERR_HTTP2_STREAM_ERROR') {
req.on('error', common.mustCall((err) => {
const fn = err.code === 'ERR_HTTP2_STREAM_ERROR' ?
common.expectsError({
code: 'ERR_HTTP2_STREAM_ERROR',
type: Error,
message: 'Stream closed with error code 2'
});
} else {
}) :
common.expectsError({
type: Error,
message: 'test'
});
}
fn(err);
}, 2));

req.on('streamClosed', common.mustCall((code) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { createServer, connect } = require('http2');
const expectedError = expectsError({
code: 'ERR_HTTP2_STREAM_CLOSED',
message: 'The stream is already closed'
});
}, 2);

{
const server = createServer();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-head-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const http2 = require('http2');
const errCheck = common.expectsError({
type: Error,
message: 'write after end'
});
}, 2);

const {
HTTP2_HEADER_PATH,
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-priority-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ server.on('listening', common.mustCall(() => {
req.on('priority', common.mustCall(onPriority));

req.on('response', common.mustCall());
req.on('data', common.noop);
req.resume();
req.on('end', common.mustCall(() => {
server.close();
client.destroy();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-respond-file-fd-invalid.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const errorCheck = common.expectsError({
code: 'ERR_HTTP2_STREAM_ERROR',
type: Error,
message: `Stream closed with error code ${NGHTTP2_INTERNAL_ERROR}`
});
}, 2);

const server = http2.createServer();
server.on('stream', (stream) => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-server-rst-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
NGHTTP2_INTERNAL_ERROR
} = http2.constants;

const errCheck = common.expectsError({ code: 'ERR_HTTP2_STREAM_ERROR' });
const errCheck = common.expectsError({ code: 'ERR_HTTP2_STREAM_ERROR' }, 8);

function checkRstCode(rstMethod, expectRstCode) {
const server = http2.createServer();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-server-startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ assert.doesNotThrow(() => {

// There should not be any throws
assert.doesNotThrow(() => {
const server = http2.createServer(options, common.noop);
const server = http2.createServer(options, common.mustNotCall());

server.listen(0, common.mustCall(() => server.close()));

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-session-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ server.on('listening', common.mustCall(() => {
}));

req.on('response', common.mustCall());
req.on('data', common.noop);
req.resume();
req.on('end', common.mustCall(() => {
server.close();
client.destroy();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-session-stream-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ server.on('listening', common.mustCall(() => {
}));

req.on('response', common.mustCall());
req.on('data', common.noop);
req.resume();
req.on('end', common.mustCall(() => {
server.close();
client.destroy();
Expand Down

0 comments on commit 5473c35

Please sign in to comment.