MCPcopy
hub / github.com/di-sukharev/opencommit / writeStream

Function writeStream

out/cli.cjs:55109–55190  ·  view source on GitHub ↗
({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload })

Source from the content-addressed store, hash-verified

55107 h2stream: stream4,
55108 socket: client[kSocket]
55109 });
55110 } else {
55111 assert2(false);
55112 }
55113 }
55114 }
55115 function writeStream({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload }) {
55116 assert2(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
55117 if (client[kHTTPConnVersion] === "h2") {
55118 let onPipeData = function(chunk) {
55119 request3.onBodySent(chunk);
55120 };
55121 const pipe = pipeline(
55122 body,
55123 h2stream,
55124 (err) => {
55125 if (err) {
55126 util4.destroy(body, err);
55127 util4.destroy(h2stream, err);
55128 } else {
55129 request3.onRequestSent();
55130 }
55131 }
55132 );
55133 pipe.on("data", onPipeData);
55134 pipe.once("end", () => {
55135 pipe.removeListener("data", onPipeData);
55136 util4.destroy(pipe);
55137 });
55138 return;
55139 }
55140 let finished = false;
55141 const writer = new AsyncWriter({ socket, request: request3, contentLength, client, expectsPayload, header });
55142 const onData = function(chunk) {
55143 if (finished) {
55144 return;
55145 }
55146 try {
55147 if (!writer.write(chunk) && this.pause) {
55148 this.pause();
55149 }
55150 } catch (err) {
55151 util4.destroy(this, err);
55152 }
55153 };
55154 const onDrain = function() {
55155 if (finished) {
55156 return;
55157 }
55158 if (body.resume) {
55159 body.resume();
55160 }
55161 };
55162 const onAbort = function() {
55163 if (finished) {
55164 return;
55165 }
55166 const err = new RequestAbortedError();

Callers 2

writeFunction · 0.85
writeBodyH2Function · 0.85

Calls 7

pipelineFunction · 0.85
removeListenerMethod · 0.80
resumeMethod · 0.80
destroyMethod · 0.45
onRequestSentMethod · 0.45
onMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…