mirror of https://github.com/arendst/Tasmota.git
Merge pull request #13816 from s-hadinger/webquery_https
Add HTTPS support to `WebQuery` and `WebGetConfig` (ESP32x only)
This commit is contained in:
commit
f79934bd8d
|
@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Command ``IfxPeriod `` to overrule ``Teleperiod`` for Influx messages (#13750)
|
||||
- OTA over HTTPS (ESP32x only)
|
||||
- Berry add ``import re`` regex module
|
||||
- Add HTTPS support to ``WebQuery`` (ESP32x only)
|
||||
|
||||
### Changed
|
||||
- ESP8266 Gratuitous ARP enabled and set to 60 seconds (#13623)
|
||||
|
|
|
@ -3117,8 +3117,12 @@ int WebQuery(char *buffer)
|
|||
// An unlimited number of headers can be sent per request, and a body can be sent for all command types
|
||||
// The body will be ignored if sending a GET command
|
||||
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
HTTPClientLight http;
|
||||
#else // HTTP only
|
||||
WiFiClient http_client;
|
||||
HTTPClient http;
|
||||
#endif
|
||||
|
||||
int status = WEBCMND_WRONG_PARAMETERS;
|
||||
|
||||
|
@ -3127,7 +3131,11 @@ int WebQuery(char *buffer)
|
|||
char *method = strtok_r(temp, " ", &temp);
|
||||
|
||||
if (url && method) {
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
if (http.begin(UrlEncode(url))) {
|
||||
#else // HTTP only
|
||||
if (http.begin(http_client, UrlEncode(url))) {
|
||||
#endif
|
||||
char empty_body[1] = { 0 };
|
||||
char *body = empty_body;
|
||||
if (temp) { // There is a body and/or header
|
||||
|
@ -3204,9 +3212,15 @@ int WebGetConfig(char *buffer)
|
|||
|
||||
DEBUG_CORE_LOG(PSTR("WEB: Config Uri '%s'"), url.c_str());
|
||||
|
||||
|
||||
#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|
|
||||
#else // HTTP only
|
||||
WiFiClient http_client;
|
||||
HTTPClient http;
|
||||
if (http.begin(http_client, UrlEncode(url))) { // UrlEncode(url) = |http://192.168.178.86/cm?cmnd=POWER1%20ON|
|
||||
#endif
|
||||
int http_code = http.GET(); // Start connection and send HTTP header
|
||||
if (http_code > 0) { // http_code will be negative on error
|
||||
status = WEBCMND_DONE;
|
||||
|
|
Loading…
Reference in New Issue