All files / worker/utils response.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                    29x              
/**
 * Create a new worker `Response` with the same body and status but new headers.
 *
 * By default, the headers are immutable, even when `Response.clone` is used. This function
 * creates a new `Response` object with the specified headers.
 *
 * @param response the `Response` to copy
 * @param newHeaders the new `Headers` for the `Response`
 */
export function copyResponseWithNewHeaders(response: Response, newHeaders: Headers): Response {
  return new Response(response.body, {
    status: response.status,
    headers: newHeaders,
    statusText: response.statusText,
    cf: response.cf,
  })
}