How to use the spdy.createServer function in spdy

To help you get started, we’ve selected a few spdy 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 zettajs / zetta / lib / http_server.js View on Github external
var tlsCheckOptions = ['cert', 'key', 'pfx', 'ca'];
  var usingSSL = false;
  Object.keys(options).forEach(function(k) {
    httpOptions[k] = options[k];
    if (tlsCheckOptions.indexOf(k) > -1) {
      usingSSL = true;
    }
  });

  // If any tls options were specified, use ssl and not plain
  httpOptions.plain = (usingSSL) ? false : true;
  httpOptions.ssl = (usingSSL) ? true : false;
  this.server = spdy.createServer(httpOptions);

  // internal server for z2z, allways ssl: false, plain: true
  this.spdyServer = spdy.createServer({
    windowSize: 1024 * 1024,
    plain: true,
    ssl: false
  });

  var ValidWSUrls = [
      /^\/events$/, // /events
      /^\/events\?.+$/, // /events?topic=query:where type="led"
      /^\/servers\/(.+)\/events/, // /servers/BC2832FD-9437-4473-A4A8-AC1D56B12C61/events
      /^\/peers\/(.+)$/, // /peers/123123...
      /^\/peer-management$/, // /peer-management
  ];

  function match(request) {
    return ValidWSUrls.some(function(re) {
      return re.test(request.url);
github sx1989827 / DOClever / Desktop / node_modules / webpack-dev-server / lib / Server.js View on Github external
});

			fs.writeFileSync(certPath, pems.private + pems.cert, { encoding: "utf-8" });
		}

		const fakeCert = fs.readFileSync(certPath);
		options.https.key = options.https.key || fakeCert;
		options.https.cert = options.https.cert || fakeCert;

		if(!options.https.spdy) {
			options.https.spdy = {
				protocols: ["h2", "http/1.1"]
			};
		}

		this.listeningApp = spdy.createServer(options.https, app);
	} else {
		this.listeningApp = http.createServer(app);
	}

	// Proxy websockets without the initial http request
	// https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade
	websocketProxies.forEach(function(wsProxy) {
		this.listeningApp.on("upgrade", wsProxy.upgrade);
	}, this);
}
github restify / node-restify / lib / server.js View on Github external
var fmt = mergeFormatters(options.formatters);
    this.acceptable = fmt.acceptable;
    this.formatters = fmt.formatters;
    this.proxyEvents = [
        'clientError',
        'close',
        'connection',
        'error',
        'listening',
        'secureConnection'
    ];

    if (options.spdy) {
        this.spdy = true;
        this.server = spdy.createServer(options.spdy);
    } else if (options.http2) {
        // http2 module is not available < v8.4.0 (only with flag <= 8.8.0)
        // load http2 module here to avoid experimental warning in other cases
        if (!http2) {
            try {
                http2 = require('http2');
                patchResponse(http2.Http2ServerResponse);
                patchRequest(http2.Http2ServerRequest);
                // eslint-disable-next-line no-empty
            } catch (err) {}
        }

        assert(
            http2,
            'http2 module is not available, ' +
                'upgrade your Node.js version to >= 8.8.0'
github tdack / unifi-parental / index.js View on Github external
let group = req.params.group
    data[group].block = req.body
    return res.json(data[group].block)
})

app.get('/api/unifi-clients', (req, res) => {
    controllerLogin( () =>
        controller.getAllUsers(nconf.get('controller:site'), (err, users) => {
            clients = {}
            users[0].forEach(user => clients[user.mac] = user.name || user.hostname || user.mac )
            res.status(200).json(users[0] || [{name: "Error: " + err.code}])
        })
    )
})

spdy.createServer(serverOptions, app)
    .listen(port, host, (error) => {
        if (error) {
            console.error(error)
            return process.exit(1)
        } else {
            debug('Listening on port', port)
            controllerLogin( () =>
                controller.getAllUsers(nconf.get('controller:site'), (err, users) => {
                    users[0].forEach(user => clients[user.mac] = user.name || user.hostname || user.mac )
                })
            )

            Object.values(data).forEach(group => {
              scheduleJobs(group.name, group.timers)
            })
        }
github GoogleChromeLabs / samples-module-loading-comparison / gulpfile.js View on Github external
opts['spdy'] = { protocols: ['h2', 'http/1.1', 'http/1.0'] };
  }

  if (push && !http1) {
    console.log('HTTP server: using HTTP 2 push.');
  } else if (push && http1) {
    console.log('HTTP server: no push support on HTTP 1.');
  }

  if (preload) {
    console.log('HTTP server: using .');
  }

  _cacheEverything();

  server = spdy.createServer(opts, _onRequest);
  console.log('HTTP server: listening...')
  server.listen(44333);
});
github invisible-college / statebus / server.js View on Github external
var fd
            if (options.use_ssl)
                try {
                    fd = bind(443)
                    bus.port = 443
                    bus.redirect_port_80()
                } catch (e) {fd = find_a_port()}
            else fd = find_a_port()
            var http_server = http.createServer(ssl_options)
            http_server.listen({fd: fd}, () => {
                console.log('Listening on '+protocol+'://:'+bus.port)
            })
        }
        else {
            bus.port = bus.options.port
            var http_server = http.createServer(ssl_options)
            http_server.listen(bus.options.port, () => {
                console.log('Listening on '+protocol+'://:'+bus.port)
            })
        }

        bus[options.name || 'http_server'] = http_server
    },
github vogloblinsky / web-components-benchmark / pascal-triangle / server.js View on Github external
path = require('path'),
    spdy = require('spdy'),
    http = require('http'),
    app = express();

let cache = {};

app.set('etag', false);

app.use(express.static('./'));

http.createServer(app).listen(3000, () => {
    return console.log(`HTTP/1 use http://localhost:3000`);
});

spdy
    .createServer(
        {
            key: fs.readFileSync(path.join(__dirname, '../http2-keys/server.key')),
            cert: fs.readFileSync(path.join(__dirname, '../http2-keys/server.crt')),
            spdy: { protocols: ['h2', 'http/1.1', 'http/1.0'] }
        },
        app
    )
    .listen(3001, err => {
        if (err) {
            throw new Error(err);
        }
        console.log(`
HTTP/2 use https://localhost:3001`);
    });
github IBM / kar / examples / misc / stockPriceEvents / .yalc / kar / index.js View on Github external
const h2c = app => spdy.createServer({ spdy: { plain: true, ssl: false, connection: { maxStreams: 262144 } } }, app).setTimeout(0)
/***************************************************
github hyron-group / hyron / addons / tcp-connecter / tcp.addons.js View on Github external
},
        ...options
    };

    if (key != null) {
        tcpCfg.key = fs.readFileSync(key);
    }
    if (cert != null) {
        tcpCfg.cert = fs.readFileSync(cert);
    }

    this.protocol = "https";
    this.baseURL = getBaseURL(this);

    ModuleManager.setServer(this.host, this.port, null);
    this.initServer(spdy.createServer(tcpCfg));
}
github IBM / kar / examples / misc / karamel / .yalc / kar / index.js View on Github external
const h2c = app => spdy.createServer({ spdy: { plain: true, ssl: false, connection: { maxStreams: 262144 } } }, app).setTimeout(0)
/***************************************************

spdy

Implementation of the SPDY protocol on node.js.

MIT
Latest version published 4 years ago

Package Health Score

76 / 100
Full package analysis