mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-09-14 14:14:09 +00:00
improve http fallouts, move to its own class
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "WebCommandService.h"
|
||||
|
||||
#include "shuntingYard.h"
|
||||
#include "httpClient.h"
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
@@ -267,7 +268,7 @@ bool WebCommandService::executeCommand(const char * name, const std::string & co
|
||||
auto lower_url = Helpers::toLower(url.c_str());
|
||||
if (lower_url.starts_with("http://") || lower_url.starts_with("https://")) {
|
||||
std::string result;
|
||||
int httpResult = http_request(url, method, value, doc["header"].as<JsonObjectConst>(), result);
|
||||
int httpResult = HttpClient::request(url, method, value, doc["header"].as<JsonObjectConst>(), result);
|
||||
if (httpResult != 200) {
|
||||
EMSESP::logger().warning("Command '%s': URL command failed with http code %d", name, httpResult);
|
||||
return false;
|
||||
|
||||
@@ -20,10 +20,8 @@
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
#include <esp_ota_ops.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP_SSLClient.h>
|
||||
#endif
|
||||
#include "shuntingYard.h"
|
||||
#include "httpClient.h"
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
@@ -427,9 +425,9 @@ bool WebStatusService::refresh_versions_cache() {
|
||||
#else
|
||||
std::string result;
|
||||
JsonDocument doc;
|
||||
auto http_code = http_request(VERSIONS_URL, "GET", "", doc.as<JsonObjectConst>(), result);
|
||||
auto http_code = HttpClient::request(VERSIONS_URL, "GET", "", doc.as<JsonObjectConst>(), result);
|
||||
if (http_code != 200) {
|
||||
EMSESP::logger().warning("refresh_versions_cache() HTTP error code %d", http_code);
|
||||
EMSESP::logger().warning("Unable to retrieve online version information (HTTP error code %d)", http_code);
|
||||
return false;
|
||||
}
|
||||
DeserializationError err = deserializeJson(doc, result);
|
||||
|
||||
Reference in New Issue
Block a user