-
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.
Refs: #29829 PR-URL: #33161 Reviewed-By: Robert Nagy <ronagy@icloud.com> 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: Denys Otrishko <shishugi@gmail.com>
- Loading branch information
Showing
4 changed files
with
84 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) { common.skip('missing crypto'); } | ||
|
||
// Check for: | ||
// Spaced headers | ||
// Psuedo headers | ||
// Capitalized headers | ||
|
||
const http2 = require('http2'); | ||
const { throws, strictEqual } = require('assert'); | ||
|
||
const server = http2.createServer(common.mustCall((req, res) => { | ||
throws(() => { | ||
res.setHeader(':path', '/'); | ||
}, { | ||
code: 'ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED' | ||
}); | ||
throws(() => { | ||
res.setHeader('t est', 123); | ||
}, { | ||
code: 'ERR_INVALID_HTTP_TOKEN' | ||
}); | ||
res.setHeader('TEST', 123); | ||
res.setHeader('test_', 123); | ||
res.setHeader(' test', 123); | ||
res.end(); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const session1 = http2.connect(`http://localhost:${server.address().port}`); | ||
session1.request({ 'test_': 123, 'TEST': 123 }) | ||
.on('end', common.mustCall(() => { | ||
session1.close(); | ||
server.close(); | ||
})); | ||
|
||
const session2 = http2.connect(`http://localhost:${server.address().port}`); | ||
session2.on('error', common.mustCall((e) => { | ||
strictEqual(e.code, 'ERR_INVALID_HTTP_TOKEN'); | ||
})); | ||
throws(() => { | ||
session2.request({ 't est': 123 }); | ||
}, { | ||
code: 'ERR_INVALID_HTTP_TOKEN' | ||
}); | ||
|
||
const session3 = http2.connect(`http://localhost:${server.address().port}`); | ||
session3.on('error', common.mustCall((e) => { | ||
strictEqual(e.code, 'ERR_INVALID_HTTP_TOKEN'); | ||
})); | ||
throws(() => { | ||
session3.request({ ' test': 123 }); | ||
}, { | ||
code: 'ERR_INVALID_HTTP_TOKEN' | ||
}); | ||
|
||
const session4 = http2.connect(`http://localhost:${server.address().port}`); | ||
throws(() => { | ||
session4.request({ ':test': 123 }); | ||
}, { | ||
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER' | ||
}); | ||
session4.close(); | ||
})); |
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