| 376 | const formDecoder = new TextDecoder("utf-8", { ignoreBOM: true }) |
| 377 | |
| 378 | class UndiciResponse extends Inspectable.Class implements HttpClientResponse, Pipeable { |
| 379 | readonly [IncomingMessage.TypeId]: typeof IncomingMessage.TypeId |
| 380 | readonly [Response.TypeId]: typeof Response.TypeId |
| 381 | readonly request: HttpClientRequest |
| 382 | readonly source: UndiciResponseSource |
| 383 | readonly url: string |
| 384 | |
| 385 | constructor( |
| 386 | request: HttpClientRequest, |
| 387 | source: UndiciResponseSource, |
| 388 | url: string |
| 389 | ) { |
| 390 | super() |
| 391 | this[IncomingMessage.TypeId] = IncomingMessage.TypeId |
| 392 | this[Response.TypeId] = Response.TypeId |
| 393 | this.request = request |
| 394 | this.source = source |
| 395 | this.url = url |
| 396 | source.body.on("error", noopErrorHandler) |
| 397 | } |
| 398 | |
| 399 | get status() { |
| 400 | return this.source.statusCode! |
| 401 | } |
| 402 | |
| 403 | get statusText() { |
| 404 | return undefined |
| 405 | } |
| 406 | |
| 407 | cachedHeaders?: Headers.Headers |
| 408 | get headers(): Headers.Headers { |
| 409 | return this.cachedHeaders ??= Headers.fromInput(this.source.headers) |
| 410 | } |
| 411 | |
| 412 | cachedCookies?: Cookies.Cookies |
| 413 | get cookies(): Cookies.Cookies { |
| 414 | if (this.cachedCookies !== undefined) { |
| 415 | return this.cachedCookies |
| 416 | } |
| 417 | const header = this.source.headers["set-cookie"] |
| 418 | return this.cachedCookies = header ? Cookies.fromSetCookie(header) : Cookies.empty |
| 419 | } |
| 420 | |
| 421 | get remoteAddress(): Option.Option<string> { |
| 422 | return Option.none() |
| 423 | } |
| 424 | |
| 425 | get stream(): Stream.Stream<Uint8Array, Error.HttpClientError> { |
| 426 | return NodeStream.fromReadable({ |
| 427 | evaluate: () => this.source.body, |
| 428 | onError: (cause) => |
| 429 | new Error.HttpClientError({ |
| 430 | reason: new Error.DecodeError({ |
| 431 | request: this.request, |
| 432 | response: this, |
| 433 | cause |
| 434 | }) |
| 435 | }) |
nothing calls this directly
no outgoing calls
no test coverage detected