mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-11 08:42:11 +00:00
20 lines
540 B
JavaScript
20 lines
540 B
JavaScript
/**
|
|
* Helpers for Electron net.request calls that ride the OAuth session partition.
|
|
*
|
|
* Electron's ClientRequest forbids app-set restricted headers such as
|
|
* Content-Length. Let Chromium frame the body itself; only set the JSON content
|
|
* type here.
|
|
*/
|
|
|
|
function serializeJsonBody(body) {
|
|
return body === undefined ? undefined : Buffer.from(JSON.stringify(body))
|
|
}
|
|
|
|
function setJsonRequestHeaders(request) {
|
|
request.setHeader('Content-Type', 'application/json')
|
|
}
|
|
|
|
module.exports = {
|
|
serializeJsonBody,
|
|
setJsonRequestHeaders
|
|
}
|