Fix ESP32 WebQuery and WebGetConfig

This commit is contained in:
Theo Arends 2023-04-03 14:55:47 +02:00
parent d9353cf1e3
commit 6b2efa16dc

View File

@ -3239,8 +3239,7 @@ int WebSend(char *buffer)
return status;
}
int WebQuery(char *buffer)
{
int WebQuery(char *buffer) {
// http://192.168.1.1/path GET -> Sends HTTP GET http://192.168.1.1/path
// http://192.168.1.1/path POST {"some":"message"} -> Sends HTTP POST to http://192.168.1.1/path with body {"some":"message"}
// http://192.168.1.1/path PUT [Autorization: Bearer abcdxyz] potato -> Sends HTTP PUT to http://192.168.1.1/path with authorization header and body "potato"
@ -3266,6 +3265,7 @@ int WebQuery(char *buffer)
if (url && method) {
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
if (http.begin(UrlEncode(url))) {
http.setConnectTimeout(USE_BERRY_WEBCLIENT_TIMEOUT);
#else // HTTP only
if (http.begin(http_client, UrlEncode(url))) {
#endif
@ -3343,8 +3343,7 @@ int WebQuery(char *buffer)
}
#ifdef USE_WEBGETCONFIG
int WebGetConfig(char *buffer)
{
int WebGetConfig(char *buffer) {
// http://user:password@server:port/path/%id%.dmp : %id% will be expanded to MAC address
int status = WEBCMND_WRONG_PARAMETERS;
@ -3358,6 +3357,7 @@ int WebGetConfig(char *buffer)
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
HTTPClientLight http;
if (http.begin(UrlEncode(url))) { // UrlEncode(url) = |http://192.168.178.86/cm?cmnd=POWER1%20ON|
http.setConnectTimeout(USE_BERRY_WEBCLIENT_TIMEOUT);
#else // HTTP only
WiFiClient http_client;
HTTPClient http;