node/test/parallel/test-http2-compat-aborted.js
Robert Nagy b30dca8d9e http2: compat req.complete
PR-URL: https://github.com/nodejs/node/pull/28627
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-20 22:04:17 -07:00

30 lines
814 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const h2 = require('http2');
const assert = require('assert');
const server = h2.createServer(common.mustCall(function(req, res) {
req.on('aborted', common.mustCall(function() {
assert.strictEqual(this.aborted, true);
assert.strictEqual(this.complete, true);
}));
assert.strictEqual(req.aborted, false);
assert.strictEqual(req.complete, false);
res.write('hello');
server.close();
}));
server.listen(0, common.mustCall(function() {
const url = `http://localhost:${server.address().port}`;
const client = h2.connect(url, common.mustCall(() => {
const request = client.request();
request.on('data', common.mustCall((chunk) => {
client.destroy();
}));
}));
}));