(chunk: Uint8Array | Buffer | string)
| 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) { |
no test coverage detected