MCPcopy
hub / github.com/continuedev/continue / startHttpsServer

Function startHttpsServer

packages/fetch/src/fetch.e2e.test.ts:174–207  ·  view source on GitHub ↗

* Start an HTTPS server with given certificates

(
  certPath: string,
  keyPath: string,
)

Source from the content-addressed store, hash-verified

172 * Start an HTTPS server with given certificates
173 */
174async function startHttpsServer(
175 certPath: string,
176 keyPath: string,
177): Promise<https.Server> {
178 const server = https.createServer(
179 {
180 cert: fs.readFileSync(certPath),
181 key: fs.readFileSync(keyPath),
182 },
183 (req, res) => {
184 const url = new URL(req.url!, `https://localhost:${HTTPS_PORT}`);
185
186 if (url.pathname === "/secure") {
187 res.writeHead(200, { "Content-Type": "application/json" });
188 res.end(
189 JSON.stringify({ message: "Hello from HTTPS server", secure: true }),
190 );
191 } else if (url.pathname === "/headers") {
192 res.writeHead(200, { "Content-Type": "application/json" });
193 res.end(JSON.stringify({ headers: req.headers }));
194 } else {
195 res.writeHead(404);
196 res.end("Not Found");
197 }
198 },
199 );
200
201 await new Promise<void>((resolve) => {
202 server.listen(HTTPS_PORT, () => resolve());
203 });
204
205 serversToCleanup.push(server);
206 return server;
207}
208
209describe("fetchwithRequestOptions E2E tests", () => {
210 describe("HTTP requests", () => {

Callers 1

fetch.e2e.test.tsFile · 0.85

Calls 2

listenMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected