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

Function connectH1

github-actions/browserstack/set-browserstack-env.js:6445–6564  ·  view source on GitHub ↗
(client, socket)

Source from the content-addressed store, hash-verified

6443 const request = client[kQueue][client[kRunningIdx]];
6444 assert(request);
6445 assert(this.timeoutType === TIMEOUT_BODY);
6446 if (this.timeout) {
6447 if (this.timeout.refresh) {
6448 this.timeout.refresh();
6449 }
6450 }
6451 assert(statusCode >= 200);
6452 if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) {
6453 util.destroy(socket, new ResponseExceededMaxSizeError());
6454 return -1;
6455 }
6456 this.bytesRead += buf.length;
6457 if (request.onData(buf) === false) {
6458 return constants3.ERROR.PAUSED;
6459 }
6460 }
6461 onMessageComplete() {
6462 const { client, socket, statusCode, upgrade, headers, contentLength, bytesRead, shouldKeepAlive } = this;
6463 if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
6464 return -1;
6465 }
6466 if (upgrade) {
6467 return;
6468 }
6469 assert(statusCode >= 100);
6470 assert((this.headers.length & 1) === 0);
6471 const request = client[kQueue][client[kRunningIdx]];
6472 assert(request);
6473 this.statusCode = null;
6474 this.statusText = "";
6475 this.bytesRead = 0;
6476 this.contentLength = "";
6477 this.keepAlive = "";
6478 this.connection = "";
6479 this.headers = [];
6480 this.headersSize = 0;
6481 if (statusCode < 200) {
6482 return;
6483 }
6484 if (request.method !== "HEAD" && contentLength && bytesRead !== parseInt(contentLength, 10)) {
6485 util.destroy(socket, new ResponseContentLengthMismatchError());
6486 return -1;
6487 }
6488 request.onComplete(headers);
6489 client[kQueue][client[kRunningIdx]++] = null;
6490 socket[kSocketUsed] = true;
6491 if (socket[kWriting]) {
6492 assert(client[kRunning] === 0);
6493 util.destroy(socket, new InformationalError("reset"));
6494 return constants3.ERROR.PAUSED;
6495 } else if (!shouldKeepAlive) {
6496 util.destroy(socket, new InformationalError("reset"));
6497 return constants3.ERROR.PAUSED;
6498 } else if (socket[kReset] && client[kRunning] === 0) {
6499 util.destroy(socket, new InformationalError("reset"));
6500 return constants3.ERROR.PAUSED;
6501 } else if (client[kPipelining] == null || client[kPipelining] === 1) {
6502 setImmediate(() => client[kResume]());

Callers 1

connectFunction · 0.70

Calls 7

__asyncFunction · 0.70
addListenerFunction · 0.70
finishMethod · 0.45
readMoreMethod · 0.45
destroyMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected