Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global require */
const http = require('http');
const https = require('https');
const httpProxyWsIncoming = require('http-proxy/lib/http-proxy/passes/ws-incoming');
const common = require('http-proxy/lib/http-proxy/common');
const CRLF = '\r\n';
httpProxyWsIncoming.stream = (req, socket, options, head, server, cb) => {
const createHttpHeader = function(line, headers) {
return Object.keys(headers).reduce(function (head, key) {
const value = headers[key];
if (!Array.isArray(value)) {
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);