MCPcopy
hub / github.com/di-sukharev/opencommit / put

Method put

out/cli.cjs:61856–61935  ·  view source on GitHub ↗
(request3, response)

Source from the content-addressed store, hash-verified

61854 if (errorData === null) {
61855 cacheJobPromise.resolve(void 0);
61856 } else {
61857 cacheJobPromise.reject(errorData);
61858 }
61859 });
61860 return cacheJobPromise.promise;
61861 }
61862 async put(request3, response) {
61863 webidl.brandCheck(this, _Cache);
61864 webidl.argumentLengthCheck(arguments, 2, { header: "Cache.put" });
61865 request3 = webidl.converters.RequestInfo(request3);
61866 response = webidl.converters.Response(response);
61867 let innerRequest = null;
61868 if (request3 instanceof Request6) {
61869 innerRequest = request3[kState];
61870 } else {
61871 innerRequest = new Request6(request3)[kState];
61872 }
61873 if (!urlIsHttpHttpsScheme(innerRequest.url) || innerRequest.method !== "GET") {
61874 throw webidl.errors.exception({
61875 header: "Cache.put",
61876 message: "Expected an http/s scheme when method is not GET"
61877 });
61878 }
61879 const innerResponse = response[kState];
61880 if (innerResponse.status === 206) {
61881 throw webidl.errors.exception({
61882 header: "Cache.put",
61883 message: "Got 206 status"
61884 });
61885 }
61886 if (innerResponse.headersList.contains("vary")) {
61887 const fieldValues = getFieldValues(innerResponse.headersList.get("vary"));
61888 for (const fieldValue of fieldValues) {
61889 if (fieldValue === "*") {
61890 throw webidl.errors.exception({
61891 header: "Cache.put",
61892 message: "Got * vary field value"
61893 });
61894 }
61895 }
61896 }
61897 if (innerResponse.body && (isDisturbed(innerResponse.body.stream) || innerResponse.body.stream.locked)) {
61898 throw webidl.errors.exception({
61899 header: "Cache.put",
61900 message: "Response body is locked or disturbed"
61901 });
61902 }
61903 const clonedResponse = cloneResponse(innerResponse);
61904 const bodyReadPromise = createDeferredPromise();
61905 if (innerResponse.body != null) {
61906 const stream4 = innerResponse.body.stream;
61907 const reader = stream4.getReader();
61908 readAllBytes(reader).then(bodyReadPromise.resolve, bodyReadPromise.reject);
61909 } else {
61910 bodyReadPromise.resolve(void 0);
61911 }
61912 const operations = [];
61913 const operation = {

Callers

nothing calls this directly

Calls 11

#batchCacheOperationsMethod · 0.95
urlIsHttpHttpsSchemeFunction · 0.85
isDisturbedFunction · 0.85
cloneResponseFunction · 0.85
createDeferredPromiseFunction · 0.85
readAllBytesFunction · 0.85
containsMethod · 0.80
thenMethod · 0.80
getMethod · 0.45
getReaderMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected