Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
statCheck: 'function'
};
const types = {
boolean: true,
function: () => {},
number: 1,
object: {},
array: [],
null: null,
symbol: Symbol('test')
};
const fname = fixtures.path('elipses.txt');
const server = http2.createServer();
server.on('stream', common.mustCall((stream) => {
// Check for all possible TypeError triggers on options
Object.keys(optionsWithTypeError).forEach((option) => {
Object.keys(types).forEach((type) => {
if (type === optionsWithTypeError[option]) {
return;
}
common.expectsError(
() => stream.respondWithFile(fname, {
'content-type': 'text/plain'
}, {
[option]: types[type]
}),
'use strict';
// Flags: --expose-internals
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');
const { internalBinding } = require('internal/test/binding');
const { Http2Stream } = internalBinding('http2');
const server = http2.createServer();
Http2Stream.prototype.respond = () => 1;
server.on('stream', common.mustCall((stream) => {
// Send headers
stream.respond({ 'content-type': 'text/plain' });
// Should throw if headers already sent
common.expectsError(
() => stream.respond(),
{
type: Error,
code: 'ERR_HTTP2_HEADERS_SENT',
message: 'Response has already been initiated.'
}
);
test('http', (t) => {
const server = http2.createServer()
server.listen(0, () => {
server.unref()
doTests(server, 'http', t.test)
t.end()
})
})
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');
const assert = require('assert');
const {
NGHTTP2_ENHANCE_YOUR_CALM
} = http2.constants;
const server = http2.createServer({ settings: { maxHeaderListSize: 100 } });
server.on('stream', common.mustNotCall());
server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}`);
client.on('remoteSettings', () => {
const req = client.request({ 'foo': 'a'.repeat(1000) });
req.on('error', common.expectsError({
code: 'ERR_HTTP2_STREAM_ERROR',
type: Error,
message: 'Stream closed with error code NGHTTP2_ENHANCE_YOUR_CALM'
}));
req.on('close', common.mustCall(() => {
assert.strictEqual(req.rstCode, NGHTTP2_ENHANCE_YOUR_CALM);
server.close();
client.close();
before(function listen(done) {
server = http.createServer(app);
server = server.listen(0, function listening() {
base += `:${server.address().port}`;
done();
});
});
before(function listen(done) {
server = http.createServer(app);
server = server.listen(0, function listening() {
base += `:${server.address().port}`;
done();
});
});
before(function listen(done) {
server = http.createServer(app);
server = server.listen(0, function listening() {
base += `:${server.address().port}`;
done();
});
});
app.get('/binary', (req, res) => {
before(function listen(done) {
server = http.createServer(app);
server.listen(0, function listening() {
base += `:${server.address().port}`;
done();
});
});
before(function listen(done) {
server = http.createServer(app);
server = server.listen(0, function listening() {
base += `:${server.address().port}`;
done();
});
});
_startServer(port) {
const server = http2.createServer();
server.once('error', err => { this.emit('error', err); });
server.on('session', session => { this._handleSocket(session); });
server.on('stream', (stream, headers) => { this._handleStream(stream, headers); });
server.listen(port, () => {
const realPort = server.address().port;
if (port === this.publishPort && port === 0) {
this.publishPort = realPort;
}
this.logger.info('[RpcServer] server start on %s', realPort);
});
return server;
}