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

Method send

components/runtime/src/ts/httpclient.ts:161–183  ·  view source on GitHub ↗

* Send this request with a optional body. * * Note: if you dont consume the response body you should call `Response.body.close()` * (this is done automatically after 30 seconds if you don't, but if you're sending a lot of requests its better to do it yourself) *

(body?: RequestBody)

Source from the content-addressed store, hash-verified

159 * @returns A promise that resolbes with the response
160 */
161 async send(body?: RequestBody): Promise<Response> {
162 let reqBodyRid: number | undefined = undefined;
163 if (body) {
164 this.headers = this.headers ?? {}
165 body.setHeaders(this.headers);
166
167 let [senderRid, receiverRid] = OpWrappers.http.createRequestStream();
168 this.writeBody(body, senderRid).finally(() => Deno.core.tryClose(senderRid));
169 reqBodyRid = receiverRid
170 }
171
172 let resp = await OpWrappers.http.requestSend({
173 headers: this.headers ?? {},
174 method: this.method,
175 path: this.path,
176 scriptId: this.scriptId ?? 0,
177 bodyResourceId: reqBodyRid,
178 });
179
180 let respBody = new NativeReader(resp.bodyResourceId);
181
182 return new Response(resp.statusCode, resp.headers, respBody);
183 }
184
185 then(okay: (val: Response) => any, rejected: (err: any) => unknown) {
186 return this.send().then(okay).catch(rejected);

Callers 15

thenMethod · 0.95
sendJsonMethod · 0.95
sendTextMethod · 0.95
add_worker_to_poolMethod · 0.45
broker_clientFunction · 0.45
runMethod · 0.45
handle_broker_messageMethod · 0.45
handle_guild_commandMethod · 0.45
handle_session_eventsMethod · 0.45
send_loaded_scriptMethod · 0.45
runFunction · 0.45

Calls 2

writeBodyMethod · 0.95
setHeadersMethod · 0.65

Tested by

no test coverage detected