MCPcopy Create free account
hub / github.com/anomalyco/opencode / captureResponseBody

Function captureResponseBody

packages/http-recorder/src/internal-effect.ts:55–62  ·  view source on GitHub ↗
(response: HttpClientResponse.HttpClientResponse, contentType: string | undefined)

Source from the content-addressed store, hash-verified

53}
54
55const captureResponseBody = (response: HttpClientResponse.HttpClientResponse, contentType: string | undefined) =>
56 response.arrayBuffer.pipe(
57 Effect.map((bytes) =>
58 isTextContentType(contentType)
59 ? { body: new TextDecoder().decode(bytes) }
60 : { body: Buffer.from(bytes).toString("base64"), bodyEncoding: "base64" as const },
61 ),
62 )
63
64const decodeResponseBody = (snapshot: ResponseSnapshot) =>
65 snapshot.bodyEncoding === "base64" ? Buffer.from(snapshot.body, "base64") : snapshot.body

Callers 1

recordingLayerFunction · 0.85

Calls 2

isTextContentTypeFunction · 0.85
fromMethod · 0.45

Tested by

no test coverage detected