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

Function ondata

out/cli.cjs:26125–26174  ·  view source on GitHub ↗
(b7)

Source from the content-addressed store, hash-verified

26123 reject(err);
26124 }
26125 function ondata(b7) {
26126 buffers.push(b7);
26127 buffersLength += b7.length;
26128 const buffered = Buffer.concat(buffers, buffersLength);
26129 const endOfHeaders = buffered.indexOf("\r\n\r\n");
26130 if (endOfHeaders === -1) {
26131 debug5("have not received end of HTTP headers yet...");
26132 read();
26133 return;
26134 }
26135 const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n");
26136 const firstLine = headerParts.shift();
26137 if (!firstLine) {
26138 socket.destroy();
26139 return reject(new Error("No header received from proxy CONNECT response"));
26140 }
26141 const firstLineParts = firstLine.split(" ");
26142 const statusCode = +firstLineParts[1];
26143 const statusText = firstLineParts.slice(2).join(" ");
26144 const headers = {};
26145 for (const header of headerParts) {
26146 if (!header)
26147 continue;
26148 const firstColon = header.indexOf(":");
26149 if (firstColon === -1) {
26150 socket.destroy();
26151 return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
26152 }
26153 const key = header.slice(0, firstColon).toLowerCase();
26154 const value = header.slice(firstColon + 1).trimStart();
26155 const current = headers[key];
26156 if (typeof current === "string") {
26157 headers[key] = [current, value];
26158 } else if (Array.isArray(current)) {
26159 current.push(value);
26160 } else {
26161 headers[key] = value;
26162 }
26163 }
26164 debug5("got proxy server response: %o %o", firstLine, headers);
26165 cleanup();
26166 resolve({
26167 connect: {
26168 statusCode,
26169 statusText,
26170 headers
26171 },
26172 buffered
26173 });
26174 }
26175 socket.on("error", onerror);
26176 socket.on("end", onend);
26177 read();

Callers 1

readFunction · 0.85

Calls 11

debug5Function · 0.85
readFunction · 0.85
rejectFunction · 0.85
concatMethod · 0.80
toLowerCaseMethod · 0.80
cleanupFunction · 0.70
pushMethod · 0.45
toStringMethod · 0.45
sliceMethod · 0.45
shiftMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…