MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / write

Function write

out/cli.cjs:54813–54929  ·  view source on GitHub ↗
(client, request3)

Source from the content-addressed store, hash-verified

54811 } else {
54812 client[kQueue].splice(client[kPendingIdx], 1);
54813 }
54814 }
54815 }
54816 function shouldSendContentLength(method) {
54817 return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
54818 }
54819 function write(client, request3) {
54820 if (client[kHTTPConnVersion] === "h2") {
54821 writeH2(client, client[kHTTP2Session], request3);
54822 return;
54823 }
54824 const { body, method, path: path5, host, upgrade, headers, blocking, reset } = request3;
54825 const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
54826 if (body && typeof body.read === "function") {
54827 body.read(0);
54828 }
54829 const bodyLength = util4.bodyLength(body);
54830 let contentLength = bodyLength;
54831 if (contentLength === null) {
54832 contentLength = request3.contentLength;
54833 }
54834 if (contentLength === 0 && !expectsPayload) {
54835 contentLength = null;
54836 }
54837 if (shouldSendContentLength(method) && contentLength > 0 && request3.contentLength !== null && request3.contentLength !== contentLength) {
54838 if (client[kStrictContentLength]) {
54839 errorRequest(client, request3, new RequestContentLengthMismatchError());
54840 return false;
54841 }
54842 process.emitWarning(new RequestContentLengthMismatchError());
54843 }
54844 const socket = client[kSocket];
54845 try {
54846 request3.onConnect((err) => {
54847 if (request3.aborted || request3.completed) {
54848 return;
54849 }
54850 errorRequest(client, request3, err || new RequestAbortedError());
54851 util4.destroy(socket, new InformationalError("aborted"));
54852 });
54853 } catch (err) {
54854 errorRequest(client, request3, err);
54855 }
54856 if (request3.aborted) {
54857 return false;
54858 }
54859 if (method === "HEAD") {
54860 socket[kReset] = true;
54861 }
54862 if (upgrade || method === "CONNECT") {
54863 socket[kReset] = true;
54864 }
54865 if (reset != null) {
54866 socket[kReset] = reset;
54867 }
54868 if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
54869 socket[kReset] = true;
54870 }

Callers 1

_resumeFunction · 0.85

Calls 14

writeH2Function · 0.85
shouldSendContentLengthFunction · 0.85
errorRequestFunction · 0.85
writeIterableFunction · 0.85
writeBlobFunction · 0.85
writeStreamFunction · 0.85
readMethod · 0.45
onConnectMethod · 0.45
destroyMethod · 0.45
writeMethod · 0.45
onRequestSentMethod · 0.45
onBodySentMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…