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

Function writeH1

github-actions/browserstack/set-browserstack-env.js:6635–6756  ·  view source on GitHub ↗
(client, request)

Source from the content-addressed store, hash-verified

6633 return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
6634 }
6635 function writeH1(client, request) {
6636 const { method, path: path4, host, upgrade, blocking, reset } = request;
6637 let { body, headers, contentLength } = request;
6638 const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
6639 if (util.isFormDataLike(body)) {
6640 if (!extractBody) {
6641 extractBody = require_body().extractBody;
6642 }
6643 const [bodyStream, contentType] = extractBody(body);
6644 if (request.contentType == null) {
6645 headers.push("content-type", contentType);
6646 }
6647 body = bodyStream.stream;
6648 contentLength = bodyStream.length;
6649 } else if (util.isBlobLike(body) && request.contentType == null && body.type) {
6650 headers.push("content-type", body.type);
6651 }
6652 if (body && typeof body.read === "function") {
6653 body.read(0);
6654 }
6655 const bodyLength = util.bodyLength(body);
6656 contentLength = bodyLength != null ? bodyLength : contentLength;
6657 if (contentLength === null) {
6658 contentLength = request.contentLength;
6659 }
6660 if (contentLength === 0 && !expectsPayload) {
6661 contentLength = null;
6662 }
6663 if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
6664 if (client[kStrictContentLength]) {
6665 util.errorRequest(client, request, new RequestContentLengthMismatchError());
6666 return false;
6667 }
6668 process.emitWarning(new RequestContentLengthMismatchError());
6669 }
6670 const socket = client[kSocket];
6671 clearIdleSocketValidation(socket);
6672 const abort = (err) => {
6673 if (request.aborted || request.completed) {
6674 return;
6675 }
6676 util.errorRequest(client, request, err || new RequestAbortedError());
6677 util.destroy(body);
6678 util.destroy(socket, new InformationalError("aborted"));
6679 };
6680 try {
6681 request.onConnect(abort);
6682 } catch (err) {
6683 util.errorRequest(client, request, err);
6684 }
6685 if (request.aborted) {
6686 return false;
6687 }
6688 if (method === "HEAD") {
6689 socket[kReset] = true;
6690 }
6691 if (upgrade || method === "CONNECT") {
6692 socket[kReset] = true;

Callers 1

writeFunction · 0.70

Calls 10

extractBodyFunction · 0.70
shouldSendContentLengthFunction · 0.70
writeBufferFunction · 0.70
writeIterableFunction · 0.70
writeBlobFunction · 0.70
writeStreamFunction · 0.70
pushMethod · 0.45
onConnectMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected