lib/protocols/ws/proxy.js

Summary

Maintainability
A
35 mins
Test Coverage
const HttpProxy = require('http-proxy')

module.exports = function wsProxy (opts, req, socket, head, done) {
  const proxy = new HttpProxy(opts)

  function onOpen () { done() }
  proxy.once('open', onOpen)

  proxy.ws(req, socket, head, function (err, req, socket) {
    done(err, req, socket)
    proxy.removeListener('open', onOpen)
  })
}