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

Function rawUpgradeRequest

packages/platform-node/test/HttpServer.test.ts:1070–1087  ·  view source on GitHub ↗
(port: number, path: string)

Source from the content-addressed store, hash-verified

1068 })
1069
1070const rawUpgradeRequest = (port: number, path: string): Promise<string> =>
1071 new Promise((resolve, reject) => {
1072 const socket = createConnection({ host: "127.0.0.1", port })
1073 const timer = setTimeout(() => {
1074 socket.destroy()
1075 reject(new Error("the upgrade request was not answered in time"))
1076 }, 5000)
1077 let stream = Buffer.Buffer.alloc(0)
1078 socket.on("connect", () => socket.write(upgradeRequest(path)))
1079 socket.on("data", (data) => {
1080 stream = Buffer.Buffer.concat([stream, data])
1081 })
1082 socket.on("error", constVoid)
1083 socket.on("close", () => {
1084 clearTimeout(timer)
1085 resolve(stream.toString())
1086 })
1087 })

Callers 1

HttpServer.test.tsFile · 0.85

Calls 5

upgradeRequestFunction · 0.85
resolveFunction · 0.85
destroyMethod · 0.80
writeMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected