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

Function onConnect

github-actions/browserstack/set-browserstack-env.js:296–323  ·  view source on GitHub ↗
(res, socket, head)

Source from the content-addressed store, hash-verified

294 });
295 }
296 function onConnect(res, socket, head) {
297 connectReq.removeAllListeners();
298 socket.removeAllListeners();
299 if (res.statusCode !== 200) {
300 debug2(
301 "tunneling socket could not be established, statusCode=%d",
302 res.statusCode
303 );
304 socket.destroy();
305 var error = new Error("tunneling socket could not be established, statusCode=" + res.statusCode);
306 error.code = "ECONNRESET";
307 options.request.emit("error", error);
308 self.removeSocket(placeholder);
309 return;
310 }
311 if (head.length > 0) {
312 debug2("got illegal response body from proxy");
313 socket.destroy();
314 var error = new Error("got illegal response body from proxy");
315 error.code = "ECONNRESET";
316 options.request.emit("error", error);
317 self.removeSocket(placeholder);
318 return;
319 }
320 debug2("tunneling connection has established");
321 self.sockets[self.sockets.indexOf(placeholder)] = socket;
322 return cb(socket);
323 }
324 function onError(cause) {
325 connectReq.removeAllListeners();
326 debug2(

Callers 1

onUpgradeFunction · 0.70

Calls 5

abortFunction · 0.70
destroyMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected