MCPcopy Create free account
hub / github.com/Botloader/botloader / readAll

Method readAll

components/runtime/src/ts/httpclient.ts:271–292  ·  view source on GitHub ↗

* Read the entire response body and return the raw Uint8Array for it.

()

Source from the content-addressed store, hash-verified

269 * Read the entire response body and return the raw Uint8Array for it.
270 */
271 async readAll(): Promise<Uint8Array> {
272 if (!this.body) {
273 throw new Error("no response body")
274 }
275
276 let curBuffer = new Uint8Array();
277 let readBuf = new Uint8Array(1024 * 10);
278
279 while (true) {
280 const n = await this.body.read(readBuf);
281 const newBuffer = new Uint8Array(curBuffer.length + n);
282 newBuffer.set(curBuffer, 0);
283 newBuffer.set(readBuf.slice(0, n), curBuffer.length);
284 curBuffer = newBuffer;
285
286 if (n === 0) {
287 break;
288 }
289 }
290
291 return curBuffer;
292 }
293
294 /**
295 * Read and decode the response body as json

Callers 3

jsonMethod · 0.95
textMethod · 0.95
downloadFromUrlMethod · 0.80

Calls 2

readMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected