MCPcopy Index your code
hub / github.com/TeleBoxOrg/TeleBox_Plugins / request

Method request

scripts/update-template.js:269–302  ·  view source on GitHub ↗

* 执行 HTTPS 请求 * @param {Object} options - 请求选项 * @param {string} data - 请求数据 * @returns {Promise }

(options, data)

Source from the content-addressed store, hash-verified

267 * @returns {Promise<Object>}
268 */
269 static async request(options, data) {
270 return new Promise((resolve, reject) => {
271 const req = https.request(options, (res) => {
272 let responseData = '';
273
274 res.on('data', (chunk) => {
275 responseData += chunk;
276 });
277
278 res.on('end', () => {
279 resolve({
280 statusCode: res.statusCode,
281 headers: res.headers,
282 data: responseData
283 });
284 });
285 });
286
287 req.on('error', (error) => {
288 reject(error);
289 });
290
291 req.on('timeout', () => {
292 req.destroy();
293 reject(new Error('Request timeout'));
294 });
295
296 if (data) {
297 req.write(data);
298 }
299
300 req.end();
301 });
302 }
303}
304
305/**

Callers 3

executeWithRetryMethod · 0.45
testGeminiAPIFunction · 0.45
sendToTelegramFunction · 0.45

Calls 2

writeMethod · 0.80
destroyMethod · 0.45

Tested by

no test coverage detected