MCPcopy
hub / github.com/gildas-lormeau/zip.js / getContentLength

Function getContentLength

index.cjs:2849–2861  ·  view source on GitHub ↗
(httpReader, sendRequest, getRequestData)

Source from the content-addressed store, hash-verified

2847}
2848
2849async function getContentLength(httpReader, sendRequest, getRequestData) {
2850 if (httpReader.preventHeadRequest) {
2851 await getRequestData(httpReader, httpReader.options);
2852 } else {
2853 const response = await sendRequest(HTTP_METHOD_HEAD, httpReader, getHeaders(httpReader));
2854 const contentLength = response.headers.get(HTTP_HEADER_CONTENT_LENGTH);
2855 if (contentLength) {
2856 httpReader.size = Number(contentLength);
2857 } else {
2858 await getRequestData(httpReader, httpReader.options);
2859 }
2860 }
2861}
2862
2863async function sendFetchRequest(method, { options, url }, headers) {
2864 const response = await fetch(url, Object.assign({}, options, { method, headers }));

Callers 1

initHttpReaderFunction · 0.70

Calls 3

getRequestDataFunction · 0.70
getHeadersFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…