(port: number, path: string)
| 2831 | }) |
| 2832 | |
| 2833 | const 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. |
| 2853 | const expectContinueRequest = (port: number, payload: string, headers: Http.OutgoingHttpHeaders = {}) => |
no test coverage detected