How to use spdy-transport - 6 common examples

To help you get started, we’ve selected a few spdy-transport 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 sx1989827 / DOClever / Desktop / node_modules / spdy / lib / spdy / server.js View on Github external
if (!protocol) {
    protocol = state.options.protocol
  }

  debug('incoming socket protocol=%j', protocol)

  // No way we can do anything with the socket
  if (!protocol || protocol === 'http/1.1' || protocol === 'http/1.0') {
    debug('to default handler it goes')
    return this._invokeDefault(socket)
  }

  socket.setNoDelay(true)

  var connection = transport.connection.create(socket, Object.assign({
    protocol: /spdy/.test(protocol) ? 'spdy' : 'http2',
    isServer: true
  }, state.options.connection || {}))

  // Set version when we are certain
  if (protocol === 'http2') { connection.start(4) } else if (protocol === 'spdy/3.1') {
    connection.start(3.1)
  } else if (protocol === 'spdy/3') { connection.start(3) } else if (protocol === 'spdy/2') {
    connection.start(2)
  }

  connection.on('error', function () {
    socket.destroy()
  })

  var self = this
github spdy-http2 / node-spdy / lib / spdy / server.js View on Github external
if (!protocol) {
    protocol = state.options.protocol
  }

  debug('incoming socket protocol=%j', protocol)

  // No way we can do anything with the socket
  if (!protocol || protocol === 'http/1.1' || protocol === 'http/1.0') {
    debug('to default handler it goes')
    return this._invokeDefault(socket)
  }

  socket.setNoDelay(true)

  var connection = transport.connection.create(socket, Object.assign({
    protocol: /spdy/.test(protocol) ? 'spdy' : 'http2',
    isServer: true
  }, state.options.connection || {}))

  // Set version when we are certain
  if (protocol === 'http2') { connection.start(4) } else if (protocol === 'spdy/3.1') {
    connection.start(3.1)
  } else if (protocol === 'spdy/3') { connection.start(3) } else if (protocol === 'spdy/2') {
    connection.start(2)
  }

  connection.on('error', function () {
    socket.destroy()
  })

  var self = this
github spdy-http2 / node-spdy / lib / spdy / agent.js View on Github external
socket.alpnProtocol ||
                 state.options.protocol
    } else {
      protocol = state.options.protocol
    }

    // HTTP server - kill socket and switch to the fallback mode
    if (!protocol || protocol === 'http/1.1' || protocol === 'http/1.0') {
      debug('activating fallback')
      socket.destroy()
      state.fallback = true
      return
    }

    debug('connected protocol=%j', protocol)
    var connection = transport.connection.create(socket, Object.assign({
      protocol: /spdy/.test(protocol) ? 'spdy' : 'http2',
      isServer: false
    }, state.options.connection || {}))

    // Pass connection level errors are passed to the agent.
    connection.on('error', function (err) {
      self.emit('error', err)
    })

    // Set version when we are certain
    if (protocol === 'h2') {
      connection.start(4)
    } else if (protocol === 'spdy/3.1') {
      connection.start(3.1)
    } else if (protocol === 'spdy/3') {
      connection.start(3)
github sx1989827 / DOClever / Desktop / node_modules / spdy / lib / spdy / agent.js View on Github external
socket.alpnProtocol ||
                 state.options.protocol
    } else {
      protocol = state.options.protocol
    }

    // HTTP server - kill socket and switch to the fallback mode
    if (!protocol || protocol === 'http/1.1' || protocol === 'http/1.0') {
      debug('activating fallback')
      socket.destroy()
      state.fallback = true
      return
    }

    debug('connected protocol=%j', protocol)
    var connection = transport.connection.create(socket, Object.assign({
      protocol: /spdy/.test(protocol) ? 'spdy' : 'http2',
      isServer: false
    }, state.options.connection || {}))

    // Set version when we are certain
    if (protocol === 'h2') {
      connection.start(4)
    } else if (protocol === 'spdy/3.1') {
      connection.start(3.1)
    } else if (protocol === 'spdy/3') {
      connection.start(3)
    } else if (protocol === 'spdy/2') {
      connection.start(2)
    } else {
      socket.destroy()
      callback(new Error('Unexpected protocol: ' + protocol))
github libp2p / js-libp2p-spdy / test / muxer.spec.js View on Github external
it('can be created', () => {
    const p = pair()
    spdyMuxer = spdy.connection.create(toStream(p), {
      protocol: 'spdy',
      isServer: false
    })
    muxer = new Muxer(p, spdyMuxer)
  })
github libp2p / js-libp2p-spdy / src / index.js View on Github external
function create (rawConn, isListener) {
  const conn = toStream(rawConn)
  conn.on('end', () => conn.destroy())

  const spdyMuxer = spdy.connection.create(conn, {
    protocol: 'spdy',
    isServer: isListener
  })

  return new Muxer(rawConn, spdyMuxer)
}

spdy-transport

SPDY v2, v3, v3.1 and HTTP2 transport

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis

Popular spdy-transport functions