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

Method write

packages/next/src/server/lib/mock-request.ts:241–262  ·  view source on GitHub ↗
(chunk: Uint8Array | Buffer | string)

Source from the content-addressed store, hash-verified

239 }
240
241 public write(chunk: Uint8Array | Buffer | string) {
242 if (this.resWriter) {
243 return this.resWriter(chunk)
244 }
245
246 const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)
247
248 if (this.maximumResponseBody !== undefined) {
249 this.totalSize += buffer.byteLength
250 if (this.totalSize > this.maximumResponseBody) {
251 const error = new Error(
252 `Response body exceeded maximum size of ${this.maximumResponseBody} bytes`
253 ) as NodeJS.ErrnoException
254 error.code = 'ERR_MAX_BODY_SIZE_EXCEEDED'
255 this.destroy(error)
256 return true
257 }
258 }
259
260 this.buffers.push(buffer)
261 return true
262 }
263
264 public end() {
265 if (this.destroyed) {

Callers 6

_writeMethod · 0.95
createWriterFromResponseFunction · 0.45
web.test.tsFile · 0.45
logRequestsFunction · 0.45
writeLineFunction · 0.45
redirectFunction · 0.45

Calls 4

isBufferMethod · 0.80
pushMethod · 0.65
fromMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected