-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checks validity for request, writeHead, and setHeader methods PR-URL: #33193 Refs: #29829 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
- Loading branch information
Showing
4 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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,55 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) { common.skip('missing crypto'); } | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
const server1 = http2.createServer(); | ||
|
||
server1.listen(0, common.mustCall(() => { | ||
const session = http2.connect(`http://localhost:${server1.address().port}`); | ||
// Check for req headers | ||
session.request({ 'no underscore': 123 }); | ||
session.on('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'ERR_INVALID_HTTP_TOKEN'); | ||
server1.close(); | ||
})); | ||
})); | ||
|
||
const server2 = http2.createServer(common.mustCall((req, res) => { | ||
// check for setHeader | ||
res.setHeader('x y z', 123); | ||
res.end(); | ||
})); | ||
|
||
server2.listen(0, common.mustCall(() => { | ||
const session = http2.connect(`http://localhost:${server2.address().port}`); | ||
const req = session.request(); | ||
req.on('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'ERR_HTTP2_STREAM_ERROR'); | ||
session.close(); | ||
server2.close(); | ||
})); | ||
})); | ||
|
||
const server3 = http2.createServer(common.mustCall((req, res) => { | ||
// check for writeHead | ||
assert.throws(common.mustCall(() => { | ||
res.writeHead(200, { | ||
'an invalid header': 123 | ||
}); | ||
}), { | ||
code: 'ERR_HTTP2_INVALID_STREAM' | ||
}); | ||
res.end(); | ||
})); | ||
|
||
server3.listen(0, common.mustCall(() => { | ||
const session = http2.connect(`http://localhost:${server3.address().port}`); | ||
const req = session.request(); | ||
req.on('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'ERR_HTTP2_STREAM_ERROR'); | ||
server3.close(); | ||
session.close(); | ||
})); | ||
})); |