* Start an HTTPS server with given certificates
( certPath: string, keyPath: string, )
| 172 | * Start an HTTPS server with given certificates |
| 173 | */ |
| 174 | async 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 | |
| 209 | describe("fetchwithRequestOptions E2E tests", () => { |
| 210 | describe("HTTP requests", () => { |
no test coverage detected