Files
node/test/parallel/test-http2-compat-method-connect.js
T
James M Snell e01daec4e1 http2: remove --expose-http2 flag from tests, etc
Remove the --expose-http2 flag from tests and benchmarks

PR-URL: https://github.com/nodejs/node/pull/15685
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2017-10-23 08:59:06 -05:00

41 lines
993 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const http2 = require('http2');
const server = http2.createServer(common.mustNotCall());
server.listen(0, common.mustCall(() => testMethodConnect(2)));
server.once('connect', common.mustCall((req, res) => {
assert.strictEqual(req.headers[':method'], 'CONNECT');
res.statusCode = 405;
res.end();
}));
function testMethodConnect(testsToRun) {
if (!testsToRun) {
return server.close();
}
const port = server.address().port;
const client = http2.connect(`http://localhost:${port}`);
const req = client.request({
':method': 'CONNECT',
':authority': `localhost:${port}`
});
req.on('response', common.mustCall((headers) => {
assert.strictEqual(headers[':status'], 405);
}));
req.resume();
req.on('end', common.mustCall(() => {
client.destroy();
testMethodConnect(testsToRun - 1);
}));
req.end();
}