MCPcopy Index your code
hub / github.com/nodejs/node / writeBlob

Function writeBlob

deps/undici/undici.js:8081–8102  ·  view source on GitHub ↗
(abort, body, client, request, socket, contentLength, header, expectsPayload)

Source from the content-addressed store, hash-verified

8079 }
8080 __name(writeBuffer, "writeBuffer");
8081 async function writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload) {
8082 try {
8083 if (contentLength != null && contentLength !== body.size) {
8084 throw new RequestContentLengthMismatchError();
8085 }
8086 const buffer = Buffer.from(await body.arrayBuffer());
8087 socket.cork();
8088 socket.write(`${header}content-length: ${contentLength}\r
8089\r
8090`, "latin1");
8091 socket.write(buffer);
8092 socket.uncork();
8093 request.onBodySent(buffer);
8094 request.onRequestSent();
8095 if (!expectsPayload && request.reset !== false) {
8096 socket[kReset] = true;
8097 }
8098 client[kResume]();
8099 } catch (err) {
8100 abort(err);
8101 }
8102 }
8103 __name(writeBlob, "writeBlob");
8104 async function writeIterable(abort, body, client, request, socket, contentLength, header, expectsPayload) {
8105 assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined");

Callers 2

writeH1Function · 0.70
writeBodyH2Function · 0.70

Calls 9

corkMethod · 0.80
uncorkMethod · 0.80
abortFunction · 0.70
arrayBufferMethod · 0.65
onBodySentMethod · 0.65
onRequestSentMethod · 0.65
fromMethod · 0.45
writeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…