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

Function writeIterable

github-actions/browserstack/set-browserstack-env.js:6883–6932  ·  view source on GitHub ↗
(abort, body, client, request, socket, contentLength, header, expectsPayload)

Source from the content-addressed store, hash-verified

6881 const onFinished = function(err) {
6882 if (finished) {
6883 return;
6884 }
6885 finished = true;
6886 assert(socket.destroyed || socket[kWriting] && client[kRunning] <= 1);
6887 socket.off("drain", onDrain).off("error", onFinished);
6888 body.removeListener("data", onData).removeListener("end", onFinished).removeListener("close", onClose);
6889 if (!err) {
6890 try {
6891 writer.end();
6892 } catch (er) {
6893 err = er;
6894 }
6895 }
6896 writer.destroy(err);
6897 if (err && (err.code !== "UND_ERR_INFO" || err.message !== "reset")) {
6898 util.destroy(body, err);
6899 } else {
6900 util.destroy(body);
6901 }
6902 };
6903 body.on("data", onData).on("end", onFinished).on("error", onFinished).on("close", onClose);
6904 if (body.resume) {
6905 body.resume();
6906 }
6907 socket.on("drain", onDrain).on("error", onFinished);
6908 if ((_a = body.errorEmitted) != null ? _a : body.errored) {
6909 setImmediate(() => onFinished(body.errored));
6910 } else if ((_b = body.endEmitted) != null ? _b : body.readableEnded) {
6911 setImmediate(() => onFinished(null));
6912 }
6913 if ((_c = body.closeEmitted) != null ? _c : body.closed) {
6914 setImmediate(onClose);
6915 }
6916 }
6917 function writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload) {
6918 try {
6919 if (!body) {
6920 if (contentLength === 0) {
6921 socket.write(`${header}content-length: 0\r
6922\r
6923`, "latin1");
6924 } else {
6925 assert(contentLength === null, "no body must not have content length");
6926 socket.write(`${header}\r
6927`, "latin1");
6928 }
6929 } else if (util.isBuffer(body)) {
6930 assert(contentLength === body.byteLength, "buffer body must have content length");
6931 socket.cork();
6932 socket.write(`${header}content-length: ${contentLength}\r
6933\r
6934`, "latin1");
6935 socket.write(body);

Callers 2

writeH1Function · 0.70
writeBodyH2Function · 0.70

Calls 12

__asyncFunction · 0.70
__forAwaitFunction · 0.70
waitForDrainFunction · 0.70
abortFunction · 0.70
onMethod · 0.45
nextMethod · 0.45
writeMethod · 0.45
endMethod · 0.45
destroyMethod · 0.45
offMethod · 0.45
onBodySentMethod · 0.45
onRequestSentMethod · 0.45

Tested by

no test coverage detected