MCPcopy Create free account
hub / github.com/effect-app/libs / UndiciResponse

Class UndiciResponse

repos/effect/packages/platform-node/src/NodeHttpClient.ts:197–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195 }
196 }
197}
198
199function noopErrorHandler(_: any) {}
200
201class UndiciResponse extends Inspectable.Class implements HttpClientResponse, Pipeable {
202 readonly [IncomingMessage.TypeId]: typeof IncomingMessage.TypeId
203 readonly [Response.TypeId]: typeof Response.TypeId
204 readonly request: HttpClientRequest
205 readonly source: Undici.Dispatcher.ResponseData
206
207 constructor(
208 request: HttpClientRequest,
209 source: Undici.Dispatcher.ResponseData
210 ) {
211 super()
212 this[IncomingMessage.TypeId] = IncomingMessage.TypeId
213 this[Response.TypeId] = Response.TypeId
214 this.request = request
215 this.source = source
216 source.body.on("error", noopErrorHandler)
217 }
218
219 get status() {
220 return this.source.statusCode!
221 }
222
223 get statusText() {
224 return undefined
225 }
226
227 get headers(): Headers.Headers {
228 return Headers.fromInput(this.source.headers)
229 }
230
231 cachedCookies?: Cookies.Cookies
232 get cookies(): Cookies.Cookies {
233 if (this.cachedCookies !== undefined) {
234 return this.cachedCookies
235 }
236 const header = this.source.headers["set-cookie"]
237 return this.cachedCookies = header ? Cookies.fromSetCookie(header) : Cookies.empty
238 }
239
240 get remoteAddress(): Option.Option<string> {
241 return Option.none()
242 }
243
244 get stream(): Stream.Stream<Uint8Array, Error.HttpClientError> {
245 return NodeStream.fromReadable({
246 evaluate: () => this.source.body,
247 onError: (cause) =>
248 new Error.HttpClientError({
249 reason: new Error.DecodeError({
250 request: this.request,
251 response: this,
252 cause
253 })
254 })

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…