MCPcopy Index your code
hub / github.com/antirez/botlib / makeHTTPGETCallOpt

Function makeHTTPGETCallOpt

botlib.c:301–318  ·  view source on GitHub ↗

Like makeHTTPGETCall(), but the list of options will be concatenated to * the URL as a query string, and URL encoded as needed. * The option list array should contain optnum*2 strings, alternating * option names and values. */

Source from the content-addressed store, hash-verified

299 * The option list array should contain optnum*2 strings, alternating
300 * option names and values. */
301sds makeHTTPGETCallOpt(const char *url, int *resptr, char **optlist, int optnum) {
302 sds fullurl = sdsnew(url);
303 if (optnum) fullurl = sdscatlen(fullurl,"?",1);
304 CURL *curl = curl_easy_init();
305 for (int j = 0; j < optnum; j++) {
306 if (j > 0) fullurl = sdscatlen(fullurl,"&",1);
307 fullurl = sdscat(fullurl,optlist[j*2]);
308 fullurl = sdscatlen(fullurl,"=",1);
309 char *escaped = curl_easy_escape(curl,
310 optlist[j*2+1],strlen(optlist[j*2+1]));
311 fullurl = sdscat(fullurl,escaped);
312 curl_free(escaped);
313 }
314 curl_easy_cleanup(curl);
315 sds body = makeHTTPGETCall(fullurl,resptr);
316 sdsfree(fullurl);
317 return body;
318}
319
320/* Make an HTTP request to the Telegram bot API, where 'req' is the specified
321 * action name. This is a low level API that is used by other bot APIs

Callers 1

makeGETBotRequestFunction · 0.85

Calls 5

sdsnewFunction · 0.85
sdscatlenFunction · 0.85
sdscatFunction · 0.85
makeHTTPGETCallFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected