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

Function onSocketClose

github-actions/saucelabs/set-saucelabs-env.js:17641–17671  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17639 failWebsocketConnection(ws, "Received network error or non-101 status code.");
17640 return;
17641 }
17642 if (protocols.length !== 0 && !response.headersList.get("Sec-WebSocket-Protocol")) {
17643 failWebsocketConnection(ws, "Server did not respond with sent protocols.");
17644 return;
17645 }
17646 if (((_a = response.headersList.get("Upgrade")) == null ? void 0 : _a.toLowerCase()) !== "websocket") {
17647 failWebsocketConnection(ws, 'Server did not set Upgrade header to "websocket".');
17648 return;
17649 }
17650 if (((_b = response.headersList.get("Connection")) == null ? void 0 : _b.toLowerCase()) !== "upgrade") {
17651 failWebsocketConnection(ws, 'Server did not set Connection header to "upgrade".');
17652 return;
17653 }
17654 const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
17655 const digest = crypto2.createHash("sha1").update(keyValue + uid).digest("base64");
17656 if (secWSAccept !== digest) {
17657 failWebsocketConnection(ws, "Incorrect hash received in Sec-WebSocket-Accept header.");
17658 return;
17659 }
17660 const secExtension = response.headersList.get("Sec-WebSocket-Extensions");
17661 let extensions;
17662 if (secExtension !== null) {
17663 extensions = parseExtensions(secExtension);
17664 if (!extensions.has("permessage-deflate")) {
17665 failWebsocketConnection(ws, "Sec-WebSocket-Extensions header does not match.");
17666 return;
17667 }
17668 }
17669 const secProtocol = response.headersList.get("Sec-WebSocket-Protocol");
17670 if (secProtocol !== null) {
17671 const requestProtocols = getDecodeSplit("sec-websocket-protocol", request.headersList);
17672 if (!requestProtocols.includes(secProtocol)) {
17673 failWebsocketConnection(ws, "Protocol was not set in the opening handshake.");
17674 return;

Callers

nothing calls this directly

Calls 2

fireEventFunction · 0.70
offMethod · 0.45

Tested by

no test coverage detected