MCPcopy
hub / github.com/vercel/next.js / requestToBodyStream

Function requestToBodyStream

packages/next/src/server/body-streams.ts:8–21  ·  view source on GitHub ↗
(
  context: { ReadableStream: typeof ReadableStream },
  KUint8Array: typeof Uint8Array,
  stream: Readable
)

Source from the content-addressed store, hash-verified

6const DEFAULT_BODY_CLONE_SIZE_LIMIT = 10 * 1024 * 1024 // 10MB
7
8export function requestToBodyStream(
9 context: { ReadableStream: typeof ReadableStream },
10 KUint8Array: typeof Uint8Array,
11 stream: Readable
12) {
13 return new context.ReadableStream({
14 start: async (controller) => {
15 for await (const chunk of stream) {
16 controller.enqueue(new KUint8Array(chunk))
17 }
18 controller.close()
19 },
20 })
21}
22
23function replaceRequestBody<T extends IncomingMessage>(
24 base: T,

Callers 2

sandbox.tsFile · 0.90
fetchInlineAssetFunction · 0.90

Calls 2

closeMethod · 0.65
enqueueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…