You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
677B

  1. #pragma once
  2. #include <string>
  3. #include <jansson.h>
  4. namespace rack {
  5. enum RequestMethod {
  6. METHOD_GET,
  7. METHOD_POST,
  8. METHOD_PUT,
  9. METHOD_DELETE,
  10. };
  11. /** Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc)
  12. Caller must json_decref().
  13. */
  14. json_t *requestJson(RequestMethod method, std::string url, json_t *dataJ);
  15. /** Returns true if downloaded successfully */
  16. bool requestDownload(std::string url, std::string filename, float *progress);
  17. /** URL-encodes `s` */
  18. std::string requestEscape(std::string s);
  19. /** Computes the SHA256 of the file at `filename` */
  20. std::string requestSHA256File(std::string filename);
  21. } // namespace rack