MCPcopy Create free account
hub / github.com/electric-sql/electric / sendNodeResponse

Function sendNodeResponse

packages/agents-runtime/src/create-handler.ts:806–827  ·  view source on GitHub ↗
(
  res: ServerResponse,
  response: Response
)

Source from the content-addressed store, hash-verified

804}
805
806async function sendNodeResponse(
807 res: ServerResponse,
808 response: Response
809): Promise<void> {
810 const headers: Record<string, string> = {}
811 response.headers.forEach((value, key) => {
812 headers[key] = value
813 })
814 res.writeHead(response.status, headers)
815
816 const contentType = response.headers.get(`content-type`) ?? ``
817 if (
818 contentType.startsWith(`application/json`) ||
819 contentType.startsWith(`text/`)
820 ) {
821 res.end(await response.text())
822 return
823 }
824
825 const buffer = await response.arrayBuffer()
826 res.end(Buffer.from(buffer))
827}
828
829function readBody(req: IncomingMessage): Promise<Uint8Array> {
830 return new Promise((resolve, reject) => {

Callers 1

onEnterFunction · 0.85

Calls 5

endMethod · 0.80
textMethod · 0.80
getMethod · 0.65
forEachMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected