MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / ckpt_web_request

Function ckpt_web_request

common/script/checkpoint_api.cpp:449–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447}
448
449void ckpt_web_request(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs)
450{
451 const ScriptArgs args(Parser, Param, NumArgs, "web_request");
452 const char* method = args.str(0);
453 const char* url = args.str(1);
454 const char* headers = args.strOr(2, "");
455 const int bodySize = (int)args.byteCount(4);
456 const char* body = bodySize > 0 ? args.str(3) : args.strOr(3, "");
457 char** out = args.outStr(5);
458 int* outSize = args.outInt(6);
459 // respHeaders stays optional: the prototype asks for a valid char**, but a
460 // script that does not care about the response headers may pass NULL.
461 char** respHeaders = args.outStrOrNull(7);
462 *out = nullptr;
463 *outSize = 0;
464 if (respHeaders) {
465 *respHeaders = nullptr;
466 }
467
468 Http::Request req;
469 req.method = method; // GET/POST/PUT/PATCH/DELETE
470 req.url = url;
471 req.headers = headers;
472 req.body = body;
473 req.bodySize = bodySize;
474 req.captureHeaders = respHeaders != nullptr;
475
476 ReturnValue->Val->Integer = webResult("web_request", url, Http::perform(req), out, outSize, respHeaders);
477}
478
479void ckpt_web_upload_file(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs)
480{

Callers

nothing calls this directly

Calls 8

webResultFunction · 0.85
performFunction · 0.85
strMethod · 0.80
strOrMethod · 0.80
byteCountMethod · 0.80
outStrMethod · 0.80
outIntMethod · 0.80
outStrOrNullMethod · 0.80

Tested by

no test coverage detected