Skip to content

Commit

Permalink
test: add http2 compat setTimeout tests
Browse files Browse the repository at this point in the history
Add tests for Http2ServerRequest and Http2ServerResponse setTimeout

PR-URL: #15156
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
apapirovski authored and MylesBorins committed Sep 11, 2017
1 parent 7078c2f commit 5622224
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/parallel/test-http2-compat-serverrequest-settimeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Flags: --expose-http2
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');

const server = http2.createServer();

server.on('request', (req, res) => {
req.setTimeout(common.platformTimeout(1), common.mustCall(() => {
res.end();
}));
});

server.listen(0, common.mustCall(() => {
const port = server.address().port;
const client = http2.connect(`http://localhost:${port}`);
const req = client.request({
':path': '/',
':method': 'GET',
':scheme': 'http',
':authority': `localhost:${port}`
});
req.on('end', common.mustCall(() => {
server.close();
client.destroy();
}));
req.resume();
req.end();
}));
32 changes: 32 additions & 0 deletions test/parallel/test-http2-compat-serverresponse-settimeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Flags: --expose-http2
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');

const server = http2.createServer();

server.on('request', (req, res) => {
res.setTimeout(common.platformTimeout(1), common.mustCall(() => {
res.end();
}));
});

server.listen(0, common.mustCall(() => {
const port = server.address().port;
const client = http2.connect(`http://localhost:${port}`);
const req = client.request({
':path': '/',
':method': 'GET',
':scheme': 'http',
':authority': `localhost:${port}`
});
req.on('end', common.mustCall(() => {
server.close();
client.destroy();
}));
req.resume();
req.end();
}));

0 comments on commit 5622224

Please sign in to comment.