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

Function rawGet

packages/platform/node/test/NodeHttpServer.test.ts:2682–2699  ·  view source on GitHub ↗
(port: number, paths: ReadonlyArray<string>, method = "GET")

Source from the content-addressed store, hash-verified

2680
2681// Sends the requests pipelined on one connection and returns everything received until the connection closes.
2682const rawGet = (port: number, paths: ReadonlyArray<string>, method = "GET") =>
2683 Effect.callback<string>((resume) => {
2684 const socket = Net.connect({ port, host: "127.0.0.1" }, () => {
2685 socket.write(
2686 paths.map((path, index) =>
2687 `${method} ${path} HTTP/1.1\r\nHost: 127.0.0.1\r\n${
2688 index === paths.length - 1 ? "Connection: close\r\n" : ""
2689 }\r\n`
2690 ).join("")
2691 )
2692 })
2693 let received = ""
2694 socket.setEncoding("latin1")
2695 socket.on("data", (chunk) => received += chunk)
2696 socket.on("error", constVoid)
2697 socket.on("close", () => resume(Effect.succeed(received)))
2698 return Effect.sync(() => socket.destroy())
2699 }).pipe(Effect.timeout("2 seconds"))
2700
2701interface WebSocketFrame {
2702 readonly opcode: number

Callers 1

Calls 10

pipeMethod · 0.65
connectMethod · 0.65
writeMethod · 0.65
onMethod · 0.65
resumeFunction · 0.50
joinMethod · 0.45
mapMethod · 0.45
succeedMethod · 0.45
syncMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected