( response: HttpServerResponse )
| 311 | * @since 4.0.0 |
| 312 | */ |
| 313 | export const scopeTransferToStream = ( |
| 314 | response: HttpServerResponse |
| 315 | ): HttpServerResponse => { |
| 316 | if (response.body._tag !== "Stream") { |
| 317 | return response |
| 318 | } |
| 319 | const fiber = Fiber.getCurrent()! |
| 320 | const scope = Context.getUnsafe(fiber.context, Scope.Scope) as Scope.Closeable |
| 321 | scopeDisableClose(scope) |
| 322 | const join: RequestScopeJoin | undefined = (scope as any)[requestScopeJoin] |
| 323 | if (join !== undefined) join.transferred = true |
| 324 | return Response.setBodyKeepHeaders( |
| 325 | response, |
| 326 | HttpBody.stream( |
| 327 | Stream.onExit( |
| 328 | response.body.stream, |
| 329 | join === undefined ? (exit) => Scope.close(scope, exit) : (exit) => join.finishBody(exit) |
| 330 | ), |
| 331 | response.body.contentType, |
| 332 | response.body.contentLength |
| 333 | ) |
| 334 | ) |
| 335 | } |
| 336 | |
| 337 | const scopeEjected = Symbol.for("effect/http/HttpEffect/scopeEjected") |
| 338 |
no test coverage detected