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

Function writeBlob

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

Source from the content-addressed store, hash-verified

55189 }
55190 };
55191 body.on("data", onData).on("end", onFinished).on("error", onFinished).on("close", onAbort);
55192 if (body.resume) {
55193 body.resume();
55194 }
55195 socket.on("drain", onDrain).on("error", onFinished);
55196 }
55197 async function writeBlob({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload }) {
55198 assert2(contentLength === body.size, "blob body must have content length");
55199 const isH2 = client[kHTTPConnVersion] === "h2";
55200 try {
55201 if (contentLength != null && contentLength !== body.size) {
55202 throw new RequestContentLengthMismatchError();
55203 }
55204 const buffer = Buffer.from(await body.arrayBuffer());
55205 if (isH2) {
55206 h2stream.cork();
55207 h2stream.write(buffer);
55208 h2stream.uncork();
55209 } else {
55210 socket.cork();
55211 socket.write(`${header}content-length: ${contentLength}\r
55212\r
55213`, "latin1");
55214 socket.write(buffer);
55215 socket.uncork();
55216 }
55217 request3.onBodySent(buffer);
55218 request3.onRequestSent();
55219 if (!expectsPayload) {
55220 socket[kReset] = true;
55221 }
55222 resume2(client);
55223 } catch (err) {

Callers 2

writeFunction · 0.85
writeBodyH2Function · 0.85

Calls 7

resume2Function · 0.85
fromMethod · 0.45
arrayBufferMethod · 0.45
writeMethod · 0.45
onBodySentMethod · 0.45
onRequestSentMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…