mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

In preparation for a linting rule, use consistent quotation for properties in objects. PR-URL: https://github.com/nodejs/node/pull/19156 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Roman Reiss <me@silverwind.io>
46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const assert = require('assert');
|
|
const http2 = require('http2');
|
|
|
|
const expectValue = 'meoww';
|
|
|
|
const server = http2.createServer(common.mustNotCall());
|
|
|
|
server.once('checkExpectation', common.mustCall((req, res) => {
|
|
assert.strictEqual(req.headers.expect, expectValue);
|
|
res.statusCode = 417;
|
|
res.end();
|
|
}));
|
|
|
|
server.listen(0, common.mustCall(() => nextTest(2)));
|
|
|
|
function nextTest(testsToRun) {
|
|
if (!testsToRun) {
|
|
return server.close();
|
|
}
|
|
|
|
const port = server.address().port;
|
|
const client = http2.connect(`http://localhost:${port}`);
|
|
const req = client.request({
|
|
':path': '/',
|
|
':method': 'GET',
|
|
':scheme': 'http',
|
|
':authority': `localhost:${port}`,
|
|
'expect': expectValue
|
|
});
|
|
|
|
req.on('response', common.mustCall((headers) => {
|
|
assert.strictEqual(headers[':status'], 417);
|
|
req.resume();
|
|
}));
|
|
|
|
req.on('end', common.mustCall(() => {
|
|
client.close();
|
|
nextTest(testsToRun - 1);
|
|
}));
|
|
}
|