[SendToHttps] Fix crash and actually working + connect timeout

This commit is contained in:
TD-er
2026-06-24 23:01:11 +02:00
parent 911638e832
commit 6c630a7266
3 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -625,7 +625,7 @@ int HTTPClientLight::sendRequest(const char * type, uint8_t * payload, size_t si
// connect to server
if(!connect()) {
if (_secure) {
if (_secure && _transportTraits) {
int32_t ret = _transportTraits->getLastError(*_client);
if (ret) {
return returnError(-1000 - ret); // BearSSL error 46 transformed to -1046
+1
View File
@@ -244,6 +244,7 @@ build_flags = -DESP32_STAGE
-DNO_GLOBAL_WIFIPROV
; -Wsuggest-override
-mstrict-align
-DUSE_WEBCLIENT_HTTPS
lib_ignore = BLE
Zigbee
+8 -5
View File
@@ -1617,7 +1617,7 @@ int http_authenticate(const String& logIdentifier,
http.setRedirectLimit(2);
}
# if FEATURE_TLS
http.setTimeout(timeout);
http.setConnectTimeout(10000);
#else
# ifdef MUSTFIX_CLIENT_TIMEOUT_IN_SECONDS
@@ -1643,6 +1643,7 @@ int http_authenticate(const String& logIdentifier,
# if defined(CORE_POST_2_6_0) || defined(ESP32)
# if FEATURE_TLS
const String fullURL = joinURL(user, pass, host, port, uri, protocol);
addLog(LOG_LEVEL_INFO, concat(F("SendToHTTP full URL: "), fullURL));
if (fullURL.startsWith(F("https")))
http.begin(fullURL, nullptr); // HTTPS
else
@@ -1676,12 +1677,14 @@ int http_authenticate(const String& logIdentifier,
// }
}
}
String tmp = HttpMethod;
const char* httpMethod_cstr = &tmp[0];
// start connection and send HTTP header (and body)
if (equals(HttpMethod, F("HEAD")) || equals(HttpMethod, F("GET"))) {
httpCode = http.sendRequest(HttpMethod.c_str());
httpCode = http.sendRequest(httpMethod_cstr);
} else {
httpCode = http.sendRequest(HttpMethod.c_str(), postStr);
httpCode = http.sendRequest(httpMethod_cstr, postStr);
}
// Check to see if we need to try digest auth
@@ -1723,9 +1726,9 @@ int http_authenticate(const String& logIdentifier,
// start connection and send HTTP header (and body)
if (equals(HttpMethod, F("HEAD")) || equals(HttpMethod, F("GET"))) {
httpCode = http.sendRequest(HttpMethod.c_str());
httpCode = http.sendRequest(httpMethod_cstr);
} else {
httpCode = http.sendRequest(HttpMethod.c_str(), postStr);
httpCode = http.sendRequest(httpMethod_cstr, postStr);
}
}
}