Files
renovate[bot] 2561284dc4 build(deps): update dependency got to v15 (main) (#43120)
* build(deps): update dependency got to v15

| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | got     | 14.6.6 | 15.0.5 |

* chore: adapt code to breaking changes

* test: fix test

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
Co-authored-by: Michael Kriese <michael.kriese@mend.io>
2026-09-09 09:01:11 +00:00

24 lines
571 B
TypeScript

import { clone } from '../clone.ts';
import type { HttpResponse } from './types.ts';
// Copying will help to avoid circular structure
// and mutation of the cached response.
export function copyResponse<T>(
{ statusCode, headers, body, cached }: HttpResponse<T>,
deep: boolean,
): HttpResponse<T> {
const res: HttpResponse<T> = { statusCode, headers, body };
if (deep) {
res.headers = clone(headers);
res.body =
body instanceof Uint8Array ? (body.subarray() as T) : clone<T>(body);
}
if (cached) {
res.cached = true;
}
return res;
}