mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-07-29 01:52:51 +00:00
check for "http" before allocating a http-client
This commit is contained in:
@@ -707,7 +707,6 @@ std::string compute(const std::string & expr) {
|
|||||||
std::string cmd = expr_new.substr(f, e - f).c_str();
|
std::string cmd = expr_new.substr(f, e - f).c_str();
|
||||||
JsonDocument doc;
|
JsonDocument doc;
|
||||||
if (DeserializationError::Ok == deserializeJson(doc, cmd)) {
|
if (DeserializationError::Ok == deserializeJson(doc, cmd)) {
|
||||||
HTTPClient * http = new HTTPClient;
|
|
||||||
std::string url, header_s, value_s, method_s, key_s, keys_s;
|
std::string url, header_s, value_s, method_s, key_s, keys_s;
|
||||||
// search keys lower case
|
// search keys lower case
|
||||||
for (JsonPair p : doc.as<JsonObject>()) {
|
for (JsonPair p : doc.as<JsonObject>()) {
|
||||||
@@ -727,6 +726,8 @@ std::string compute(const std::string & expr) {
|
|||||||
keys_s = p.key().c_str();
|
keys_s = p.key().c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (url.substr(0, 4) == "http") { // match http and https
|
||||||
|
HTTPClient * http = new HTTPClient;
|
||||||
if (http->begin(url.c_str())) {
|
if (http->begin(url.c_str())) {
|
||||||
int httpResult = 0;
|
int httpResult = 0;
|
||||||
for (JsonPair p : doc[header_s].as<JsonObject>()) {
|
for (JsonPair p : doc[header_s].as<JsonObject>()) {
|
||||||
@@ -780,6 +781,7 @@ std::string compute(const std::string & expr) {
|
|||||||
}
|
}
|
||||||
delete http;
|
delete http;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
f = expr_new.find_first_of('{', e);
|
f = expr_new.find_first_of('{', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user