Implement client auth parameter
This commit is contained in:
@@ -150,14 +150,23 @@ std::expected<void, std::string> AsyncHttpRequest::createClient(std::string_view
|
|||||||
return std::unexpected(msg);
|
return std::unexpected(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_http_client_config_t config{};
|
esp_http_client_config_t config {
|
||||||
config.url = url.data();
|
.url = url.data(),
|
||||||
config.max_authorization_retries = 1;
|
.method = method,
|
||||||
config.method = method;
|
.timeout_ms = timeout_ms,
|
||||||
config.timeout_ms = timeout_ms;
|
.max_authorization_retries = 1,
|
||||||
config.event_handler = staticHttpEventHandler;
|
.event_handler = staticHttpEventHandler,
|
||||||
config.user_data = this;
|
.user_data = this,
|
||||||
config.is_async = true;
|
.is_async = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (clientAuth)
|
||||||
|
{
|
||||||
|
config.client_key_pem = clientAuth->clientKey.data();
|
||||||
|
config.client_key_len = clientAuth->clientKey.size();
|
||||||
|
config.client_cert_pem = clientAuth->clientCert.data();
|
||||||
|
config.client_cert_len = clientAuth->clientCert.size();
|
||||||
|
}
|
||||||
|
|
||||||
m_client = espcpputils::http_client{&config};
|
m_client = espcpputils::http_client{&config};
|
||||||
|
|
||||||
@@ -264,8 +273,7 @@ std::expected<void, std::string> AsyncHttpRequest::start(std::string_view url,
|
|||||||
std::expected<void, std::string> AsyncHttpRequest::retry(std::optional<std::string_view> url,
|
std::expected<void, std::string> AsyncHttpRequest::retry(std::optional<std::string_view> url,
|
||||||
std::optional<esp_http_client_method_t> method,
|
std::optional<esp_http_client_method_t> method,
|
||||||
const std::map<std::string, std::string> &requestHeaders,
|
const std::map<std::string, std::string> &requestHeaders,
|
||||||
std::string_view requestBody, std::optional<int> timeout_ms,
|
std::string_view requestBody, std::optional<int> timeout_ms)
|
||||||
const std::optional<cpputils::ClientAuth> &clientAuth)
|
|
||||||
{
|
{
|
||||||
if (!m_taskHandle)
|
if (!m_taskHandle)
|
||||||
{
|
{
|
||||||
|
@@ -43,8 +43,7 @@ public:
|
|||||||
std::expected<void, std::string> retry(std::optional<std::string_view> url = std::nullopt,
|
std::expected<void, std::string> retry(std::optional<std::string_view> url = std::nullopt,
|
||||||
std::optional<esp_http_client_method_t> method = std::nullopt,
|
std::optional<esp_http_client_method_t> method = std::nullopt,
|
||||||
const std::map<std::string, std::string> &requestHeaders = {},
|
const std::map<std::string, std::string> &requestHeaders = {},
|
||||||
std::string_view requestBody = {}, std::optional<int> timeout_ms = {},
|
std::string_view requestBody = {}, std::optional<int> timeout_ms = {});
|
||||||
const std::optional<cpputils::ClientAuth> &clientAuth = {});
|
|
||||||
std::expected<void, std::string> abort();
|
std::expected<void, std::string> abort();
|
||||||
|
|
||||||
bool inProgress() const;
|
bool inProgress() const;
|
||||||
|
Reference in New Issue
Block a user