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

Function writeH1

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

Source from the content-addressed store, hash-verified

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

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