mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-11 22:02:21 +00:00
docs: keep media response documentation with its implementation
This commit is contained in:
1 parent
2e3cb6270a
commit
bac45815d1
2 files changed
+12
-12
No files matched your search
@@ -65,18 +65,6 @@ export function coalesceProxyRequest(inFlight, key, create) {
|
|||||||
return { promise, shared: false };
|
return { promise, shared: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Read a fetch Response body as text while enforcing a hard byte cap during
|
* Read a fetch Response body as text while enforcing a hard byte cap during
|
||||||
* the read — so a malicious or buggy upstream that streams an unbounded body
|
* the read — so a malicious or buggy upstream that streams an unbounded body
|
||||||
|
|||||||
@@ -3540,6 +3540,18 @@ function toReadable(body) {
|
|||||||
return null;
|
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' } = {}) {
|
async function proxyMediaResponse(res, upstream, { sourceHeader = 'upstream' } = {}) {
|
||||||
const contentType = upstream.headers.get('content-type') || 'application/octet-stream';
|
const contentType = upstream.headers.get('content-type') || 'application/octet-stream';
|
||||||
const cacheControl = upstream.headers.get('cache-control') || 'no-store';
|
const cacheControl = upstream.headers.get('cache-control') || 'no-store';
|
||||||
|
|||||||
Reference in new issue
Block a user