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

Function rawUpgradeRequest

packages/platform/node/test/NodeHttpServer.test.ts:2833–2850  ·  view source on GitHub ↗
(port: number, path: string)

Source from the content-addressed store, hash-verified

2831 })
2832
2833const rawUpgradeRequest = (port: number, path: string): Promise<string> =>
2834 new Promise((resolve, reject) => {
2835 const socket = Net.createConnection({ host: "127.0.0.1", port })
2836 const timer = setTimeout(() => {
2837 socket.destroy()
2838 reject(new Error("the upgrade request was not answered in time"))
2839 }, 5000)
2840 let stream = Buffer.Buffer.alloc(0)
2841 socket.on("connect", () => socket.write(upgradeRequest(path)))
2842 socket.on("data", (data) => {
2843 stream = Buffer.Buffer.concat([stream, Buffer.Buffer.from(data)])
2844 })
2845 socket.on("error", constVoid)
2846 socket.on("close", () => {
2847 clearTimeout(timer)
2848 resolve(stream.toString())
2849 })
2850 })
2851
2852// Flush only headers. Like curl, upload only after the server asks for the body.
2853const expectContinueRequest = (port: number, payload: string, headers: Http.OutgoingHttpHeaders = {}) =>

Callers 1

Calls 8

upgradeRequestFunction · 0.85
fromMethod · 0.80
onMethod · 0.65
writeMethod · 0.65
toStringMethod · 0.65
rejectFunction · 0.50
resolveFunction · 0.50
destroyMethod · 0.45

Tested by

no test coverage detected