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

Function ckpt_web_request

common/script/checkpoint_api.cpp:522–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520}
521
522void ckpt_web_request(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs)
523{
524 const ScriptArgs args(Parser, Param, NumArgs, "web_request");
525 const char* method = args.str(0);
526 const char* url = args.str(1);
527 const char* headers = args.strOr(2, "");
528 const int bodySize = (int)args.byteCount(4);
529 const char* body = bodySize > 0 ? args.str(3) : args.strOr(3, "");
530 char** out = args.outStr(5);
531 int* outSize = args.outInt(6);
532 // respHeaders stays optional: the prototype asks for a valid char**, but a
533 // script that does not care about the response headers may pass NULL.
534 char** respHeaders = args.outStrOrNull(7);
535 *out = nullptr;
536 *outSize = 0;
537 if (respHeaders) {
538 *respHeaders = nullptr;
539 }
540
541 Http::Request req;
542 req.method = method; // GET/POST/PUT/PATCH/DELETE
543 req.url = url;
544 req.headers = headers;
545 req.body = body;
546 req.bodySize = bodySize;
547 req.captureHeaders = respHeaders != nullptr;
548
549 ReturnValue->Val->Integer = webResult("web_request", url, Http::perform(req), out, outSize, respHeaders);
550}
551
552void ckpt_web_upload_file(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs)
553{

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