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

Function writeBodyH2

github-actions/browserstack/set-browserstack-env.js:7405–7477  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7403 const onUpgradeError = (error) => {
7404 upgradeResponseFinished = true;
7405 stream.off("response", onResponse);
7406 request.onUpgradeError(error);
7407 };
7408 const onReady = () => {
7409 try {
7410 request.onUpgrade(null, null, stream);
7411 } catch (error) {
7412 stream.off("response", onResponse);
7413 abort(error);
7414 return;
7415 }
7416 if (request.aborted) {
7417 return;
7418 }
7419 stream.off("error", abort);
7420 stream.once(errorMonitor, onUpgradeError);
7421 client[kQueue][client[kRunningIdx]++] = null;
7422 };
7423 stream.once("response", onResponse);
7424 stream.once("error", abort);
7425 ++session[kOpenStreams];
7426 onReady();
7427 stream.once("close", () => {
7428 if (!upgradeResponseFinished && request.completed) {
7429 stream.off("response", onResponse);
7430 stream.off(errorMonitor, onUpgradeError);
7431 request.onUpgradeError(new InformationalError(`HTTP/2: "stream error" received - code ${stream.rstCode}`));
7432 }
7433 session[kOpenStreams] -= 1;
7434 if (session[kOpenStreams] === 0)
7435 session.unref();
7436 });
7437 return true;
7438 }
7439 headers[HTTP2_HEADER_PATH] = path4;
7440 headers[HTTP2_HEADER_SCHEME] = "https";
7441 const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
7442 if (body && typeof body.read === "function") {
7443 body.read(0);
7444 }
7445 let contentLength = util.bodyLength(body);
7446 if (util.isFormDataLike(body)) {
7447 extractBody != null ? extractBody : extractBody = require_body().extractBody;
7448 const [bodyStream, contentType] = extractBody(body);
7449 headers["content-type"] = contentType;
7450 body = bodyStream.stream;
7451 contentLength = bodyStream.length;
7452 }
7453 if (contentLength == null) {
7454 contentLength = request.contentLength;
7455 }
7456 if (contentLength === 0 || !expectsPayload) {
7457 contentLength = null;
7458 }
7459 if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength != null && request.contentLength !== contentLength) {
7460 if (client[kStrictContentLength]) {
7461 util.errorRequest(client, request, new RequestContentLengthMismatchError());
7462 return false;

Callers 1

writeH2Function · 0.70

Calls 5

writeBufferFunction · 0.70
writeIterableFunction · 0.70
writeBlobFunction · 0.70
writeStreamFunction · 0.70
streamMethod · 0.45

Tested by

no test coverage detected