2017-07-17 19:29:42 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2017-08-07 07:54:44 +02:00
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
2017-07-17 19:29:42 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
const h2 = require('http2');
|
|
|
|
const NGHTTP2_INTERNAL_ERROR = h2.constants.NGHTTP2_INTERNAL_ERROR;
|
|
|
|
|
|
|
|
const server = h2.createServer();
|
|
|
|
|
|
|
|
// Do not mustCall the server side callbacks, they may or may not be called
|
|
|
|
// depending on the OS. The determination is based largely on operating
|
|
|
|
// system specific timings
|
|
|
|
server.on('stream', (stream) => {
|
|
|
|
// 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) => {
|
2017-07-31 20:53:15 +02:00
|
|
|
assert.strictEqual(err.code, 'ERR_HTTP2_STREAM_ERROR');
|
2018-02-23 22:28:29 +01:00
|
|
|
assert.strictEqual(err.message,
|
|
|
|
'Stream closed with error code NGHTTP2_INTERNAL_ERROR');
|
2017-07-17 19:29:42 +02:00
|
|
|
});
|
2017-12-12 20:34:17 +01:00
|
|
|
stream.respond();
|
2017-07-17 19:29:42 +02:00
|
|
|
stream.end();
|
|
|
|
});
|
|
|
|
|
2017-12-12 20:34:17 +01:00
|
|
|
server.listen(0, common.mustCall(() => {
|
2017-07-17 19:29:42 +02:00
|
|
|
const client = h2.connect(`http://localhost:${server.address().port}`);
|
|
|
|
|
2017-12-12 20:34:17 +01:00
|
|
|
const req = client.request();
|
|
|
|
req.destroy(new Error('test'));
|
2017-07-17 19:29:42 +02:00
|
|
|
|
2017-12-12 20:34:17 +01:00
|
|
|
req.on('error', common.expectsError({
|
|
|
|
type: Error,
|
|
|
|
message: 'test'
|
2017-08-23 18:29:49 +02:00
|
|
|
}));
|
2017-07-17 19:29:42 +02:00
|
|
|
|
2018-03-19 17:17:23 +01:00
|
|
|
req.on('close', common.mustCall(() => {
|
|
|
|
assert.strictEqual(req.rstCode, NGHTTP2_INTERNAL_ERROR);
|
2017-07-17 19:29:42 +02:00
|
|
|
assert.strictEqual(req.rstCode, NGHTTP2_INTERNAL_ERROR);
|
|
|
|
server.close();
|
2017-12-12 20:34:17 +01:00
|
|
|
client.close();
|
2017-07-17 19:29:42 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
req.on('response', common.mustNotCall());
|
|
|
|
req.resume();
|
|
|
|
}));
|