node/test/parallel/test-http2-server-push-disabled.js
Tobias Nießen e890344d18
test: fix spelling in test case comments
PR-URL: https://github.com/nodejs/node/pull/18018
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2018-01-11 16:49:38 +01:00

55 lines
1.4 KiB
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();
server.on('session', common.mustCall((session) => {
// Verify that the settings disabling push is received
session.on('remoteSettings', common.mustCall((settings) => {
assert.strictEqual(settings.enablePush, false);
}));
}));
server.on('stream', common.mustCall((stream) => {
// The client has disabled push streams, so pushAllowed must be false,
// and pushStream() must throw.
assert.strictEqual(stream.pushAllowed, false);
common.expectsError(() => {
stream.pushStream({
':scheme': 'http',
':path': '/foobar',
':authority': `localhost:${server.address().port}`,
}, common.mustNotCall());
}, {
code: 'ERR_HTTP2_PUSH_DISABLED',
type: Error
});
stream.respond({ ':status': 200 });
stream.end('test');
}));
server.listen(0, common.mustCall(() => {
const options = { settings: { enablePush: false } };
const client = http2.connect(`http://localhost:${server.address().port}`,
options);
const req = client.request({ ':path': '/' });
// Because push streams are disabled, this must not be called.
client.on('stream', common.mustNotCall());
req.resume();
req.on('end', common.mustCall(() => {
server.close();
client.close();
}));
req.end();
}));