How to use the http2.createSecureServer function in http2

To help you get started, we’ve selected a few http2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github visionmedia / superagent / test / node / unix-sockets.js View on Github external
before(done => {
    if (fs.existsSync(httpsSockPath) === true) {
      // try unlink if sock file exists
      fs.unlinkSync(httpsSockPath);
    }

    if (process.env.HTTP2_TEST) {
      httpsServer = https.createSecureServer({ key, cert }, app);
    } else {
      httpsServer = https.createServer({ key, cert }, app);
    }

    httpsServer.listen(httpsSockPath, done);
  });
github windyfancy / webcontext / lib / webapplication.js View on Github external
listen() {
    let config=this.config;
    if(config.ssl && config.ssl.enable){
      let sslOptions={
        key: fs.readFileSync(path.resolve(workDirectory,'ssl/privatekey.pem')), // 私钥
        cert: fs.readFileSync(path.resolve(workDirectory,'ssl/certificate.pem')) // 公钥
      }
      const http2 =require('http2');
      var sslServer=http2.createSecureServer(sslOptions, this.createHttpHandler());
      sslServer.listen(config.ssl.port)
    }
    const port=this.config["port"];
    const server = http.createServer(this.createHttpHandler());
    server.listen(port);
  }
github mcollina / h2url / test / basic.js View on Github external
test('https', (t) => {
  const server = http2.createSecureServer({
    key: fs.readFileSync(path.join(__dirname, 'test.key')),
    cert: fs.readFileSync(path.join(__dirname, 'test.cert'))
  })

  server.listen(0, () => {
    server.unref()

    doTests(server, 'https', t.test)
    t.end()
  })
})
github azat-co / practicalnode / code / ch13 / http2 / server-simple.js View on Github external
const http2 = require('http2')
const fs = require('fs')

const server = http2.createSecureServer({
  key: fs.readFileSync('server.key'),
  cert: fs.readFileSync('server.crt')
}, (req, res) => {
  res.end('hello')
})
server.on('error', (err) => console.error(err))

server.listen(3000)
github wavesplatform / WavesGUI / server.ts View on Github external
function createMyServer(port: number) {
    const server = createSecureServer({ key: privateKey, cert: certificate });
    const url = `https://localhost:${port}`;

    server.addListener('request', request);
    server.listen(port);

    console.log(`Listen port ${port}...`);
    console.log('Available urls:');
    console.log(url);

    if (args.openUrl) {
        opn(url);
    }
}

http2

An HTTP/2 client and server implementation

MIT
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis