MCPcopy Index your code
hub / github.com/Effect-TS/effect / fromAgent

Function fromAgent

packages/platform-node/src/internal/httpClient.ts:57–78  ·  view source on GitHub ↗
(agent: NodeClient.HttpAgent)

Source from the content-addressed store, hash-verified

55export const agentLayer = makeAgentLayer()
56
57const fromAgent = (agent: NodeClient.HttpAgent): Client.HttpClient =>
58 Client.make((request, url, signal) => {
59 const nodeRequest = url.protocol === "https:" ?
60 Https.request(url, {
61 agent: agent.https,
62 method: request.method,
63 headers: request.headers,
64 signal
65 }) :
66 Http.request(url, {
67 agent: agent.http,
68 method: request.method,
69 headers: request.headers,
70 signal
71 })
72 return pipe(
73 Effect.zipRight(sendBody(nodeRequest, request, request.body), waitForResponse(nodeRequest, request), {
74 concurrent: true
75 }),
76 Effect.map((_) => new ClientResponseImpl(request, _))
77 )
78 })
79
80const sendBody = (
81 nodeRequest: Http.ClientRequest,

Callers

nothing calls this directly

Calls 6

waitForResponseFunction · 0.85
requestMethod · 0.80
sendBodyFunction · 0.70
makeMethod · 0.65
mapMethod · 0.65
pipeFunction · 0.50

Tested by

no test coverage detected