* Sets the outbound body source for this stream. Accepts all body * source types (string, TypedArray, Blob, AsyncIterable, Promise, null). * Can only be called once. Mutually exclusive with stream.writer. * @param {any} body
(body)
| 2373 | * @param {any} body |
| 2374 | */ |
| 2375 | setBody(body) { |
| 2376 | assertIsQuicStream(this); |
| 2377 | if (this.destroyed) { |
| 2378 | throw new ERR_INVALID_STATE('Stream is destroyed'); |
| 2379 | } |
| 2380 | const inner = this.#inner; |
| 2381 | if (inner.outboundSet) { |
| 2382 | throw new ERR_INVALID_STATE('Stream outbound already configured'); |
| 2383 | } |
| 2384 | if (inner.writer !== undefined) { |
| 2385 | throw new ERR_INVALID_STATE('Stream writer already accessed'); |
| 2386 | } |
| 2387 | inner.outboundSet = true; |
| 2388 | // If the body is a FileHandle, store it so it is closed |
| 2389 | // automatically when the stream finishes. |
| 2390 | if (FileHandle.isFileHandle(body)) { |
| 2391 | inner.fileHandle = body; |
| 2392 | } |
| 2393 | configureOutbound(this.#handle, this, body); |
| 2394 | } |
| 2395 | |
| 2396 | /** |
| 2397 | * Associates a FileHandle with this stream so it is closed automatically |
no test coverage detected