Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;