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.

35 lines
768B

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