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.

32 lines
724B

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