How to use the http-proxy/lib/http-proxy/common.isSSL function in http-proxy

To help you get started, we’ve selected a few http-proxy 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 embark-framework / embark / packages / embark-blockchain-process / src / httpProxyOverride.js View on Github external
head.push(`${key}: ${value}`);
        return head;
      }
      for (let i = 0; i < value.length; i++) {
        head.push(`${key}: ${value[i]}`);
      }
      return head;
    }, [line])
      .join(CRLF) + `${CRLF}${CRLF}`;
  };

  common.setupSocket(socket);

  if (head && head.length) socket.unshift(head);

  const protocol = common.isSSL.test(options.target.protocol) ? https : http;

  const proxyReq = protocol.request(
    common.setupOutgoing(options.ssl || {}, options, req)
  );

  // Enable developers to modify the proxyReq before headers are sent
  if (server) {
    server.emit('proxyReqWs', proxyReq, req, socket, options, head);
  }

  // Error Handler
  proxyReq.on('error', onOutgoingError);
  proxyReq.on('response', function (res) {
    // if upgrade event isn't going to happen, close the socket
    if (!res.upgrade) {
      const {httpVersion, statusCode, statusMessage, headers} = res;