openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
30 lines (29 loc) • 895 B
JavaScript
//#region src/infra/http-json.ts
function sendJson(e, t, n) {
e.statusCode = t;
e.setHeader("Content-Type", "application/json; charset=utf-8");
e.end(JSON.stringify(n));
}
function sendJsonNoStore(e, t, n) {
e.setHeader("Cache-Control", "no-store");
sendJson(e, t, n);
}
function sendJsonWithoutCharset(e, t, n) {
e.statusCode = t;
e.setHeader("Content-Type", "application/json");
e.end(JSON.stringify(n));
}
function writeJsonWithoutCharset(e, t, n) {
e.writeHead(t, { "Content-Type": "application/json" });
e.end(JSON.stringify(n));
}
function sendLengthFramedJson(e, t, n) {
const r = JSON.stringify(n);
e.writeHead(t, {
"content-type": "application/json; charset=utf-8",
"content-length": Buffer.byteLength(r)
});
e.end(r);
}
//#endregion
export { writeJsonWithoutCharset as a, sendLengthFramedJson as i, sendJsonNoStore as n, sendJsonWithoutCharset as r, sendJson as t };