Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
socket.write(createHttpHeader(
`HTTP/${httpVersion} ${statusCode} ${statusMessage}`,
headers
function setRequestParams (req, opts) {
const target = req.rocky.options.target || opts.target
const url = parseUrl(target)
const params = setupReq(opts.ssl || {}, opts, req)
params.hostname = url.hostname
params.port = url.port
const forwardHost = opts.forwardHost
if (typeof forwardHost === 'string') {
params.headers.host = forwardHost
} else if (forwardHost) {
params.headers.host = url.host
}
if ((req.method === 'DELETE' || req.method === 'OPTIONS') && !req.headers['content-length']) {
params.headers['content-length'] = '0'
}
if (opts.replayOriginalBody && req._originalBodyLength) {