docs: keep media response documentation with its implementation

This commit is contained in:
Sameh Khamis committed 2026-09-11 19:09:07 -07:00
1 parent 2e3cb6270a
commit bac45815d1
2 files changed
+12 -12

No files matched your search

+12
View File
@@ -3540,6 +3540,18 @@ function toReadable(body) {
return null;
}
/**
* Pipe an upstream fetch Response (image or video) to the client HTTP response.
*
* Forwards Content-Type, Content-Length, Content-Range, Accept-Ranges, and
* Cache-Control headers from the upstream. Falls back to buffered arrayBuffer
* if the body is not streamable.
*
* @param {import('http').ServerResponse} res
* @param {Response} upstream - fetch() Response object.
* @param {object} [opts]
* @param {string} [opts.sourceHeader='upstream'] - Value for X-CCTV-Source header.
*/
async function proxyMediaResponse(res, upstream, { sourceHeader = 'upstream' } = {}) {
const contentType = upstream.headers.get('content-type') || 'application/octet-stream';
const cacheControl = upstream.headers.get('cache-control') || 'no-store';