| 92 | * @returns A response for the request. |
| 93 | */ |
| 94 | export async function serveFile( |
| 95 | req: Request, |
| 96 | filePath: string, |
| 97 | options?: ServeFileOptions, |
| 98 | ): Promise<Response> { |
| 99 | const response = await stableServeFile(req, filePath, options); |
| 100 | |
| 101 | if (options?.headers) { |
| 102 | for (const header of options.headers) { |
| 103 | const headerSplit = header.split(":"); |
| 104 | const name = headerSplit[0]!; |
| 105 | const value = headerSplit.slice(1).join(":"); |
| 106 | response.headers.append(name, value); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | return response; |
| 111 | } |