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

Function writeBuffer

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

Source from the content-addressed store, hash-verified

8047 }
8048 __name(writeStream, "writeStream");
8049 function writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload) {
8050 try {
8051 if (!body) {
8052 if (contentLength === 0) {
8053 socket.write(`${header}content-length: 0\r
8054\r
8055`, "latin1");
8056 } else {
8057 assert(contentLength === null, "no body must not have content length");
8058 socket.write(`${header}\r
8059`, "latin1");
8060 }
8061 } else if (util.isBuffer(body)) {
8062 assert(contentLength === body.byteLength, "buffer body must have content length");
8063 socket.cork();
8064 socket.write(`${header}content-length: ${contentLength}\r
8065\r
8066`, "latin1");
8067 socket.write(body);
8068 socket.uncork();
8069 request.onBodySent(body);
8070 if (!expectsPayload && request.reset !== false) {
8071 socket[kReset] = true;
8072 }
8073 }
8074 request.onRequestSent();
8075 client[kResume]();
8076 } catch (err) {
8077 abort(err);
8078 }
8079 }
8080 __name(writeBuffer, "writeBuffer");
8081 async function writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload) {
8082 try {

Callers 3

writeH1Function · 0.70
writeBodyH2Function · 0.70
makeSyncWriteFunction · 0.50

Calls 8

corkMethod · 0.80
uncorkMethod · 0.80
abortFunction · 0.70
onBodySentMethod · 0.65
onRequestSentMethod · 0.65
assertFunction · 0.50
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…