UNPKG

astro

Version:

Astro is a modern site builder with web best practices, performance, and DX front-of-mind.

19 lines (18 loc) 620 B
import { INTERNAL_RESPONSE_HEADERS, responseSentSymbol } from "../constants.js"; import { getSetCookiesFromResponse } from "../cookies/index.js"; function prepareResponse(response, { addCookieHeader }) { for (const headerName of INTERNAL_RESPONSE_HEADERS) { if (response.headers.has(headerName)) { response.headers.delete(headerName); } } if (addCookieHeader) { for (const setCookieHeaderValue of getSetCookiesFromResponse(response)) { response.headers.append("set-cookie", setCookieHeaderValue); } } Reflect.set(response, responseSentSymbol, true); } export { prepareResponse };