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

Class Uint8ArrayBody

components/runtime/src/ts/httpclient.ts:222–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220 }
221
222 export class Uint8ArrayBody implements RequestBody {
223 contentType?: string;
224 remainingData: Uint8Array;
225
226 constructor(data: Uint8Array, contentType?: string) {
227 this.contentType = contentType;
228 this.remainingData = data;
229 }
230
231
232 setHeaders(headers: Record<string, string>) {
233 if (this.contentType) {
234 headers["Content-Type"] = this.contentType;
235 }
236 }
237
238 async read(buf: Uint8Array) {
239 if (this.remainingData.length > 0) {
240 const readValues = this.remainingData.subarray(0, buf.length);
241 buf.set(readValues, 0);
242 this.remainingData = this.remainingData.subarray(readValues.length);
243 return readValues.length;
244 }
245
246 return 0;
247 }
248
249 }
250
251 /**
252 * A response to a http request.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected