Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CGI.sendResponse = function sendResponse(res) {
if (typeof res != "object") {
CGI.sendResponse(CGI.handleError("response is not an object"));
return;
}
var { status: code, headers: headers, body: body } = res;
if (code && parseInt(code) != code || code < 100) {
CGI.sendResponse(CGI.handleError("invalid code"));
return;
}
var hdrs = new juice.Utils.Headers(Iterator(headers));
if (typeof body == "function") {
//system.stderr.print("body is a function, calling");
body = body();
}
var h_string = hdrs.toString();
if (h_string.length)
h_string += "\r\n"
system.stdout.write("Status: " + code + "\r\n" +
h_string + "\r\n");
// Work out what kind of body we have.