Something went wrong. Try again.
A fork of https://github.com/crosspoint-reader/crosspoint-reader
Something went wrong. Try again.
1.2 kB · 37 lines
C
at master
1234567891011121314151617181920212223242526272829303132333435363738#pragma once#include <HalStorage.h>
#include <functional>#include <string>
/** * HTTP client utility for fetching content and downloading files. * Wraps NetworkClientSecure and HTTPClient for HTTPS requests. */class HttpDownloader { public: using ProgressCallback = std::function<void(size_t downloaded, size_t total)>;
enum DownloadError { OK = 0, HTTP_ERROR, FILE_ERROR, ABORTED, };
/** * Fetch text content from a URL with optional credentials. */ static bool fetchUrl(const std::string& url, std::string& outContent, const std::string& username = "", const std::string& password = "");
static bool fetchUrl(const std::string& url, Stream& stream, const std::string& username = "", const std::string& password = "");
/** * Download a file to the SD card with optional credentials. */ static DownloadError downloadToFile(const std::string& url, const std::string& destPath, ProgressCallback progress = nullptr, const std::string& username = "", const std::string& password = "");};