MCPcopy Create free account
hub / github.com/angular/dev-infra / put

Method put

github-actions/browserstack/set-browserstack-env.js:15948–16030  ·  view source on GitHub ↗
(_0, _1)

Source from the content-addressed store, hash-verified

15946 });
15947 }
15948 put(_0, _1) {
15949 return __async(this, arguments, function* (request, response) {
15950 webidl.brandCheck(this, _Cache);
15951 const prefix = "Cache.put";
15952 webidl.argumentLengthCheck(arguments, 2, prefix);
15953 request = webidl.converters.RequestInfo(request, prefix, "request");
15954 response = webidl.converters.Response(response, prefix, "response");
15955 let innerRequest = null;
15956 if (request instanceof Request) {
15957 innerRequest = request[kState];
15958 } else {
15959 innerRequest = new Request(request)[kState];
15960 }
15961 if (!urlIsHttpHttpsScheme(innerRequest.url) || innerRequest.method !== "GET") {
15962 throw webidl.errors.exception({
15963 header: prefix,
15964 message: "Expected an http/s scheme when method is not GET"
15965 });
15966 }
15967 const innerResponse = response[kState];
15968 if (innerResponse.status === 206) {
15969 throw webidl.errors.exception({
15970 header: prefix,
15971 message: "Got 206 status"
15972 });
15973 }
15974 if (innerResponse.headersList.contains("vary")) {
15975 const fieldValues = getFieldValues(innerResponse.headersList.get("vary"));
15976 for (const fieldValue of fieldValues) {
15977 if (fieldValue === "*") {
15978 throw webidl.errors.exception({
15979 header: prefix,
15980 message: "Got * vary field value"
15981 });
15982 }
15983 }
15984 }
15985 if (innerResponse.body && (isDisturbed(innerResponse.body.stream) || innerResponse.body.stream.locked)) {
15986 throw webidl.errors.exception({
15987 header: prefix,
15988 message: "Response body is locked or disturbed"
15989 });
15990 }
15991 const clonedResponse = cloneResponse(innerResponse);
15992 const bodyReadPromise = createDeferredPromise();
15993 if (innerResponse.body != null) {
15994 const stream = innerResponse.body.stream;
15995 const reader = stream.getReader();
15996 readAllBytes(reader).then(bodyReadPromise.resolve, bodyReadPromise.reject);
15997 } else {
15998 bodyReadPromise.resolve(void 0);
15999 }
16000 const operations = [];
16001 const operation = {
16002 type: "put",
16003 // 14.
16004 request: innerRequest,
16005 // 15.

Callers

nothing calls this directly

Calls 11

__asyncFunction · 0.70
urlIsHttpHttpsSchemeFunction · 0.70
getFieldValuesFunction · 0.70
isDisturbedFunction · 0.70
cloneResponseFunction · 0.70
createDeferredPromiseFunction · 0.70
readAllBytesFunction · 0.70
__privateMethodFunction · 0.70
containsMethod · 0.45
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected