VCV Rack API v2
|
Networking functions for HTTP requests, downloads, and URLs. More...
Typedefs | |
typedef std::map< std::string, std::string > | CookieMap |
Enumerations | |
enum | Method { METHOD_GET , METHOD_POST , METHOD_PUT , METHOD_DELETE } |
Functions | |
PRIVATE void | init () |
PRIVATE void | destroy () |
json_t * | requestJson (Method method, const std::string &url, json_t *dataJ=NULL, const CookieMap &cookies={}) |
Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc) Caller must json_decref() if return value is non-NULL. | |
bool | requestDownload (const std::string &url, const std::string &filename, float *progress, const CookieMap &cookies={}) |
Returns true if downloaded successfully. | |
std::string | encodeUrl (const std::string &s) |
URL-encodes a string. | |
std::string | urlPath (const std::string &url) |
Returns the path portion of the URL. | |
Networking functions for HTTP requests, downloads, and URLs.
typedef std::map<std::string, std::string> rack::network::CookieMap |
PRIVATE void rack::network::init | ( | ) |
PRIVATE void rack::network::destroy | ( | ) |
json_t * rack::network::requestJson | ( | Method | method, |
const std::string & | url, | ||
json_t * | dataJ = NULL, | ||
const CookieMap & | cookies = {} ) |
Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc) Caller must json_decref() if return value is non-NULL.
bool rack::network::requestDownload | ( | const std::string & | url, |
const std::string & | filename, | ||
float * | progress, | ||
const CookieMap & | cookies = {} ) |
Returns true if downloaded successfully.
If progress
is non-NULL, the value is updated from 0 to 1 while downloading.
std::string rack::network::encodeUrl | ( | const std::string & | s | ) |
URL-encodes a string.
std::string rack::network::urlPath | ( | const std::string & | url | ) |
Returns the path portion of the URL.
Example:
urlPath("https://example.com/foo/index.html") // Returns "/foo/index.html"