Fix DNS lookup for `upload`

Fix DNS lookup for ``upload`` from ota server using http regression from v12.3.1.1
This commit is contained in:
Theo Arends 2023-01-13 17:06:16 +01:00
parent 3bddbdc5c0
commit ce5e1df673
2 changed files with 17 additions and 3 deletions

View File

@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file.
- Orno WE517 modbus serial config 8E1 setting (#17545)
- No IP address shown when in AP mode regression from v12.3.1.1 (#17599)
- Rename ``tasmota4M.bin`` to ``tasmota-4M.bin`` to solve use of ``tasmota-minimal.bin`` (#17674)
- DNS lookup for ``upload`` from ota server using http regression from v12.3.1.1
### Removed

View File

@ -39,6 +39,7 @@
#include <base64.h>
#include "HttpClientLight.h"
#include "ESP8266WiFi.h"
#ifdef USE_WEBCLIENT_HTTPS
#include "WiFiClientSecureLightBearSSL.h"
@ -1158,9 +1159,21 @@ bool HTTPClientLight::connect(void)
return false;
}
#endif
if(!_client->connect(_host.c_str(), _port, _connectTimeout)) {
log_d("failed connect to %s:%u", _host.c_str(), _port);
return false;
if (_protocol == "https") {
if(!_client->connect(_host.c_str(), _port, _connectTimeout)) {
log_d("failed connect to %s:%u", _host.c_str(), _port);
return false;
}
} else {
IPAddress remote_addr;
// Add include "ESP8266WiFi.h" for this to work
if (!WiFi.hostByName(_host.c_str(), remote_addr)) {
return false;
}
if(!_client->connect(remote_addr, _port, _connectTimeout)) {
log_d("failed connect to %s:%u", _host.c_str(), _port);
return false;
}
}
// set Timeout for WiFiClient and for Stream::readBytesUntil() and Stream::readStringUntil()