mirror of https://github.com/lukechilds/node.git
Browse Source
Add tests for Http2ServerRequest and Http2ServerResponse setTimeout PR-URL: https://github.com/nodejs/node/pull/15156 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>canary-base
committed by
James M Snell
2 changed files with 64 additions and 0 deletions
@ -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(); |
||||
|
})); |
@ -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(); |
||||
|
})); |
Loading…
Reference in new issue