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.

31 lines
727B

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