| 924 | }) |
| 925 | |
| 926 | class NodeHttpResponse extends NodeHttpIncomingMessage<Error.HttpClientError> implements HttpClientResponse, Pipeable { |
| 927 | readonly [Response.TypeId]: typeof Response.TypeId |
| 928 | readonly request: HttpClientRequest |
| 929 | readonly url: string |
| 930 | readonly upgraded: Duplex | undefined |
| 931 | |
| 932 | constructor( |
| 933 | request: HttpClientRequest, |
| 934 | source: Http.IncomingMessage, |
| 935 | url: string, |
| 936 | upgraded: Duplex | undefined |
| 937 | ) { |
| 938 | super(source, (cause) => |
| 939 | new Error.HttpClientError({ |
| 940 | reason: new Error.DecodeError({ |
| 941 | request, |
| 942 | response: this, |
| 943 | cause |
| 944 | }) |
| 945 | })) |
| 946 | this[Response.TypeId] = Response.TypeId |
| 947 | this.request = request |
| 948 | this.url = url |
| 949 | this.upgraded = upgraded |
| 950 | } |
| 951 | |
| 952 | get status() { |
| 953 | return this.source.statusCode! |
| 954 | } |
| 955 | |
| 956 | cachedHeaders?: Headers.Headers |
| 957 | override get headers(): Headers.Headers { |
| 958 | return this.cachedHeaders ??= super.headers |
| 959 | } |
| 960 | |
| 961 | get upgrade(): Effect.Effect<Socket.Socket, Error.HttpClientError> { |
| 962 | return upgradeSocket(this, this.upgraded) |
| 963 | } |
| 964 | |
| 965 | cachedCookies?: Cookies.Cookies |
| 966 | get cookies(): Cookies.Cookies { |
| 967 | if (this.cachedCookies !== undefined) { |
| 968 | return this.cachedCookies |
| 969 | } |
| 970 | const header = this.source.headers["set-cookie"] |
| 971 | return this.cachedCookies = header ? Cookies.fromSetCookie(header) : Cookies.empty |
| 972 | } |
| 973 | |
| 974 | get formData(): Effect.Effect<FormData, Error.HttpClientError> { |
| 975 | return Effect.tryPromise({ |
| 976 | try: () => { |
| 977 | const init: { |
| 978 | headers: HeadersInit |
| 979 | status?: number |
| 980 | statusText?: string |
| 981 | } = { |
| 982 | headers: new globalThis.Headers(this.source.headers as any) |
| 983 | } |
nothing calls this directly
no outgoing calls
no test coverage detected