| 1679 | const scopedRequests = new WeakMap<HttpClientRequest.HttpClientRequest, AbortController>() |
| 1680 | |
| 1681 | class InterruptibleResponse implements HttpClientResponse.HttpClientResponse, Pipeable { |
| 1682 | readonly original: HttpClientResponse.HttpClientResponse |
| 1683 | readonly controller: AbortController |
| 1684 | |
| 1685 | constructor( |
| 1686 | original: HttpClientResponse.HttpClientResponse, |
| 1687 | controller: AbortController |
| 1688 | ) { |
| 1689 | this.original = original |
| 1690 | this.controller = controller |
| 1691 | } |
| 1692 | |
| 1693 | readonly [HttpClientResponse.TypeId] = HttpClientResponse.TypeId |
| 1694 | readonly [HttpIncomingMessage.TypeId] = HttpIncomingMessage.TypeId |
| 1695 | |
| 1696 | private applyInterrupt<A, E, R>(effect: Effect.Effect<A, E, R>) { |
| 1697 | return Effect.suspend(() => { |
| 1698 | responseRegistry.unregister(this.original) |
| 1699 | return Effect.onInterrupt( |
| 1700 | effect, |
| 1701 | () => |
| 1702 | Effect.sync(() => { |
| 1703 | this.controller.abort() |
| 1704 | }) |
| 1705 | ) |
| 1706 | }) |
| 1707 | } |
| 1708 | |
| 1709 | get request() { |
| 1710 | return this.original.request |
| 1711 | } |
| 1712 | |
| 1713 | get status() { |
| 1714 | return this.original.status |
| 1715 | } |
| 1716 | |
| 1717 | get headers() { |
| 1718 | return this.original.headers |
| 1719 | } |
| 1720 | |
| 1721 | get cookies() { |
| 1722 | return this.original.cookies |
| 1723 | } |
| 1724 | |
| 1725 | get remoteAddress() { |
| 1726 | return this.original.remoteAddress |
| 1727 | } |
| 1728 | |
| 1729 | get formData() { |
| 1730 | return this.applyInterrupt(this.original.formData) |
| 1731 | } |
| 1732 | |
| 1733 | get text() { |
| 1734 | return this.applyInterrupt(this.original.text) |
| 1735 | } |
| 1736 | |
| 1737 | get json() { |
| 1738 | return this.applyInterrupt(this.original.json) |
nothing calls this directly
no outgoing calls
no test coverage detected