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 socket.write(`${header}content-length: ${contentLength}\r
6882\r
6883`, "latin1");
6884 socket.write(buffer);
6885 socket.uncork();
6886 request.onBodySent(buffer);
6887 request.onRequestSent();
6888 if (!expectsPayload && request.reset !== false) {
6889 socket[kReset] = true;
6890 }
6891 client[kResume]();
6892 } catch (err) {
6893 abort(err);
6894 }
6895 });
6896 }
6897 function writeIterable(abort, body, client, request, socket, contentLength, header, expectsPayload) {
6898 return __async(this, null, function* () {
6899 assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined");
6900 let callback = null;
6901 function onDrain() {
6902 if (callback) {
6903 const cb = callback;
6904 callback = null;
6905 cb();
6906 }
6907 }
6908 const waitForDrain = () => new Promise((resolve2, reject) => {
6909 assert(callback === null);
6910 if (socket[kError]) {
6911 reject(socket[kError]);
6912 } else {
6913 callback = resolve2;
6914 }
6915 });
6916 socket.on("close", onDrain).on("drain", onDrain);
6917 const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header });
6918 try {
6919 try {
6920 for (var iter = __forAwait(body), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
6921 const chunk = temp.value;
6922 if (socket[kError]) {
6923 throw socket[kError];
6924 }
6925 if (!writer.write(chunk)) {
6926 yield waitForDrain();
6927 }
6928 }
6929 } catch (temp) {
6930 error = [temp];
6931 } finally {
6932 try {
6933 more && (temp = iter.return) && (yield temp.call(iter));
6934 } finally {
6935 if (error)

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