MCPcopy
hub / github.com/Effect-TS/effect / make

Function make

packages/platform-node/src/internal/httpClientUndici.ts:43–73  ·  view source on GitHub ↗
(dispatcher: Undici.Dispatcher)

Source from the content-addressed store, hash-verified

41
42/** @internal */
43export const make = (dispatcher: Undici.Dispatcher): Client.HttpClient =>
44 Client.make((request, url, signal, fiber) => {
45 const context = fiber.getFiberRef(FiberRef.currentContext)
46 const options: Undici.Dispatcher.RequestOptions = context.unsafeMap.get(undiciOptionsTagKey) ?? {}
47 return convertBody(request.body).pipe(
48 Effect.flatMap((body) =>
49 Effect.tryPromise({
50 try: () =>
51 dispatcher.request({
52 ...options,
53 signal,
54 method: request.method,
55 headers: request.headers,
56 origin: url.origin,
57 path: url.pathname + url.search + url.hash,
58 body,
59 // leave timeouts to Effect.timeout etc
60 headersTimeout: 60 * 60 * 1000,
61 bodyTimeout: 0
62 }),
63 catch: (cause) =>
64 new Error.RequestError({
65 request,
66 reason: "Transport",
67 cause
68 })
69 })
70 ),
71 Effect.map((response) => new ClientResponseImpl(request, response))
72 )
73 })
74
75function convertBody(
76 body: Body.HttpBody

Callers

nothing calls this directly

Calls 7

convertBodyFunction · 0.85
requestMethod · 0.80
makeMethod · 0.65
getFiberRefMethod · 0.65
getMethod · 0.65
pipeMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…