Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _getFakeClientResponse (opts: {
statusCode: number
headers: {
[k: string]: string
}
body: string
}) {
const clientResponse = new IncomingMessage(new Socket)
// be nice and infer this content-type for the user
if (!_.keys(opts.headers).map(_.toLower).includes('content-type') && isHtml(opts.body)) {
opts.headers['content-type'] = 'text/html'
}
_.merge(clientResponse, opts)
return clientResponse
}
process.stdout.on('data', data => {
const html = data.toString('utf8')
assert.equal(isHtml(html), true)
done()
})
})
_parseText(text) {
if (!text || isHtml(text)) {
return {};
}
try {
return JSON.parse(text);
} catch (e) {
return text;
}
}
}