MCPcopy Create free account
hub / github.com/Effect-TS/effect / exchange

Function exchange

packages/effect/src/http/HttpClient.ts:730–755  ·  view source on GitHub ↗
(
          request: HttpClientRequest.HttpClientRequest,
          onResponse?: (response: HttpClientResponse.HttpClientResponse) => void
        )

Source from the content-addressed store, hash-verified

728 () => f(request, url, controller.signal, fiber as any)
729 )
730 const exchange = (
731 request: HttpClientRequest.HttpClientRequest,
732 onResponse?: (response: HttpClientResponse.HttpClientResponse) => void
733 ) =>
734 Effect.uninterruptibleMask((restore) =>
735 Effect.matchCauseEffect(restore(send(request)), {
736 onSuccess: (response) => {
737 response = trackResponse(
738 response,
739 controller,
740 scope !== undefined,
741 urlParamsRedactedNames,
742 redactedPath
743 )
744 onResponse?.(response)
745 return Effect.succeed(response)
746 },
747 onFailure: (cause) => {
748 if (Cause.hasInterrupts(cause)) {
749 controller.abort()
750 }
751 Error.addFailureRedactedNames(cause, urlParamsRedactedNames, redactedPath)
752 return Effect.failCause(cause)
753 }
754 })
755 )
756 const tracerDisabled = !fiber.getRef(References.TracerEnabled) ||
757 fiber.getRef(Tracer.DisablePropagation) ||
758 fiber.getRef(TracerDisabledWhen)(request)

Callers 1

makeFunction · 0.70

Calls 6

trackResponseFunction · 0.85
sendFunction · 0.70
abortMethod · 0.65
restoreFunction · 0.50
onResponseFunction · 0.50
succeedMethod · 0.45

Tested by

no test coverage detected