* Builds the response headers. Extras go through `new Headers(...)` rather than * an object spread: spreading a `Headers` instance silently yields `{}`, and * losing a `set-cookie` that way would be a very quiet bug.
(defaults: Record<string, string>, extra?: HeadersInit)
| 66 | * losing a `set-cookie` that way would be a very quiet bug. |
| 67 | */ |
| 68 | function headersWith(defaults: Record<string, string>, extra?: HeadersInit): Headers { |
| 69 | const headers = new Headers(defaults); |
| 70 | if (extra) { |
| 71 | for (const [name, value] of new Headers(extra)) headers.set(name, value); |
| 72 | } |
| 73 | return headers; |
| 74 | } |
| 75 | |
| 76 | function html(body: string, init: ResponseInit & { nonce?: string } = {}): Response { |
| 77 | const { nonce, headers, ...rest } = init; |