mirror of https://github.com/arendst/Tasmota.git
Update command WebSend
* Change command WebSend Host header field from IP address to hostname (#4331) * Add to command WebSend option to send a direct path when command starts with a slash (#4329)
This commit is contained in:
parent
406907cbe2
commit
d3f5c8978b
|
@ -2,6 +2,7 @@
|
||||||
* Fix wifi connection errors using wifi disconnect and ESP.reset instead of ESP.restart
|
* Fix wifi connection errors using wifi disconnect and ESP.reset instead of ESP.restart
|
||||||
* Fix Sonoff Pow R2 and Sonoff S31 Serial interface hang caused by Sonoff Basic R2 driver delay implementation (and possibly core bug)
|
* Fix Sonoff Pow R2 and Sonoff S31 Serial interface hang caused by Sonoff Basic R2 driver delay implementation (and possibly core bug)
|
||||||
* Change command WebSend Host header field from IP address to hostname (#4331)
|
* Change command WebSend Host header field from IP address to hostname (#4331)
|
||||||
|
* Add to command WebSend option to send a direct path when command starts with a slash (#4329)
|
||||||
*
|
*
|
||||||
* 6.3.0.6 20181110
|
* 6.3.0.6 20181110
|
||||||
* Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40%
|
* Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40%
|
||||||
|
|
|
@ -1895,9 +1895,11 @@ String UrlEncode(const String& text)
|
||||||
|
|
||||||
int WebSend(char *buffer)
|
int WebSend(char *buffer)
|
||||||
{
|
{
|
||||||
// http://192.168.178.86:80/cm?user=admin&password=joker&cmnd=POWER1 ON
|
/* [sonoff] POWER1 ON --> Sends http://sonoff/cm?cmnd=POWER1 ON
|
||||||
// http://192.168.178.86:80/cm?cmnd=POWER1 ON
|
* [192.168.178.86:80,admin:joker] POWER1 ON --> Sends http://hostname:80/cm?user=admin&password=joker&cmnd=POWER1 ON
|
||||||
// [192.168.178.86:80,admin:joker] POWER1 ON
|
* [sonoff] /any/link/starting/with/a/slash.php?log=123 --> Sends http://sonoff/any/link/starting/with/a/slash.php?log=123
|
||||||
|
* [sonoff,admin:joker] /any/link/starting/with/a/slash.php?log=123 --> Sends http://sonoff/any/link/starting/with/a/slash.php?log=123
|
||||||
|
*/
|
||||||
|
|
||||||
char *host;
|
char *host;
|
||||||
char *port;
|
char *port;
|
||||||
|
@ -1923,6 +1925,9 @@ int WebSend(char *buffer)
|
||||||
if (port) { nport = atoi(port); }
|
if (port) { nport = atoi(port); }
|
||||||
|
|
||||||
String nuri = "";
|
String nuri = "";
|
||||||
|
command = LTrim(command);
|
||||||
|
if (command[0] != '/') {
|
||||||
|
nuri = "/cm?";
|
||||||
if (user && password) {
|
if (user && password) {
|
||||||
nuri += F("user=");
|
nuri += F("user=");
|
||||||
nuri += user;
|
nuri += user;
|
||||||
|
@ -1931,7 +1936,8 @@ int WebSend(char *buffer)
|
||||||
nuri += F("&");
|
nuri += F("&");
|
||||||
}
|
}
|
||||||
nuri += F("cmnd=");
|
nuri += F("cmnd=");
|
||||||
nuri += LTrim(command);
|
}
|
||||||
|
nuri += command; // command = POWER1 ON or /any/link/starting/with/a/slash.php?log=123
|
||||||
String uri = UrlEncode(nuri);
|
String uri = UrlEncode(nuri);
|
||||||
|
|
||||||
IPAddress host_ip;
|
IPAddress host_ip;
|
||||||
|
@ -1947,16 +1953,16 @@ int WebSend(char *buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connected) {
|
if (connected) {
|
||||||
String url = F("GET /cm?");
|
String url = F("GET ");
|
||||||
url += uri;
|
url += uri;
|
||||||
url += F(" HTTP/1.1\r\n Host: ");
|
url += F(" HTTP/1.1\r\nHost: ");
|
||||||
// url += IPAddress(host_ip).toString();
|
// url += IPAddress(host_ip).toString();
|
||||||
url += host; // https://tools.ietf.org/html/rfc7230#section-5.4 (#4331)
|
url += host; // https://tools.ietf.org/html/rfc7230#section-5.4 (#4331)
|
||||||
if (port) {
|
if (port) {
|
||||||
url += F(" \r\n Port: ");
|
url += F(":");
|
||||||
url += port;
|
url += port;
|
||||||
}
|
}
|
||||||
url += F(" \r\n Connection: close\r\n\r\n");
|
url += F("\r\nConnection: close\r\n\r\n");
|
||||||
|
|
||||||
//snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Url |%s|"), url.c_str());
|
//snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Url |%s|"), url.c_str());
|
||||||
//AddLog(LOG_LEVEL_DEBUG);
|
//AddLog(LOG_LEVEL_DEBUG);
|
||||||
|
|
Loading…
Reference in New Issue