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

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