forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add http2 compat setTimeout tests
Add tests for Http2ServerRequest and Http2ServerResponse setTimeout PR-URL: nodejs#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
1 parent
9cfa57d
commit 993faa7
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
test/parallel/test-http2-compat-serverrequest-settimeout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
test/parallel/test-http2-compat-serverresponse-settimeout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
})); |