PR review fixes (#384)
This commit is contained in:
committed by
GitHub
parent
f660550f86
commit
d0d05c67ca
@@ -11,7 +11,7 @@ class EspHttpClient {
|
||||
static constexpr auto* TAG = "EspHttpClient";
|
||||
|
||||
std::unique_ptr<esp_http_client_config_t> config = nullptr;
|
||||
esp_http_client_handle_t client;
|
||||
esp_http_client_handle_t client = nullptr;
|
||||
bool isOpen = false;
|
||||
|
||||
public:
|
||||
@@ -87,11 +87,15 @@ public:
|
||||
bool close() {
|
||||
assert(client != nullptr);
|
||||
TT_LOG_I(TAG, "close()");
|
||||
return esp_http_client_close(client) == ESP_OK;
|
||||
if (esp_http_client_close(client) == ESP_OK) {
|
||||
isOpen = false;
|
||||
}
|
||||
return !isOpen;
|
||||
}
|
||||
|
||||
bool cleanup() {
|
||||
assert(client != nullptr);
|
||||
assert(!isOpen);
|
||||
TT_LOG_I(TAG, "cleanup()");
|
||||
const auto result = esp_http_client_cleanup(client);
|
||||
client = nullptr;
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace tt::network::http {
|
||||
|
||||
void download(
|
||||
/**
|
||||
* Download a file from a URL.
|
||||
* The server must send the Content-Length header.
|
||||
* @param url download source URL
|
||||
* @param certFilePath the path to the .pem file
|
||||
* @param downloadFilePath The path to downloadd the file to. The parent directories must exist.
|
||||
* @param onSuccess the success result callback
|
||||
* @param onError the error result callback
|
||||
*/
|
||||
void download(
|
||||
const std::string& url,
|
||||
const std::string& certFilePath,
|
||||
const std::string &downloadFilePath,
|
||||
|
||||
Reference in New Issue
Block a user