From 406907cbe27677b39f86865105e45f6441632cf6 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 12 Nov 2018 11:11:22 +0100 Subject: [PATCH] Revert "Update command WebSend" This reverts commit 59c581721470b654d495bea4caf2110aeb7be056. --- sonoff/_changelog.ino | 1 - sonoff/xdrv_01_webserver.ino | 40 +++++++++++++++--------------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index e661b54fb..ce35adbe0 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -2,7 +2,6 @@ * 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) * 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 * Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40% diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 5b989ce3b..6f99b30a1 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -1895,11 +1895,9 @@ String UrlEncode(const String& text) int WebSend(char *buffer) { - /* [sonoff] POWER1 ON --> Sends http://sonoff/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 - * [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 - */ + // http://192.168.178.86:80/cm?user=admin&password=joker&cmnd=POWER1 ON + // http://192.168.178.86:80/cm?cmnd=POWER1 ON + // [192.168.178.86:80,admin:joker] POWER1 ON char *host; char *port; @@ -1925,19 +1923,15 @@ int WebSend(char *buffer) if (port) { nport = atoi(port); } String nuri = ""; - command = LTrim(command); - if (command[0] != '/') { - nuri = "/cm?"; - if (user && password) { - nuri += F("user="); - nuri += user; - nuri += F("&password="); - nuri += password; - nuri += F("&"); - } - nuri += F("cmnd="); + if (user && password) { + nuri += F("user="); + nuri += user; + nuri += F("&password="); + nuri += password; + nuri += F("&"); } - nuri += command; // command = POWER1 ON or /any/link/starting/with/a/slash.php?log=123 + nuri += F("cmnd="); + nuri += LTrim(command); String uri = UrlEncode(nuri); IPAddress host_ip; @@ -1953,19 +1947,19 @@ int WebSend(char *buffer) } if (connected) { - String url = F("GET "); + String url = F("GET /cm?"); url += uri; - url += F(" HTTP/1.1\r\nHost: "); + url += F(" HTTP/1.1\r\n Host: "); // url += IPAddress(host_ip).toString(); url += host; // https://tools.ietf.org/html/rfc7230#section-5.4 (#4331) if (port) { - url += F(":"); + url += F(" \r\n Port: "); url += port; } - url += F("\r\nConnection: close\r\n\r\n"); + url += F(" \r\n Connection: close\r\n\r\n"); -snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Url |%s|"), url.c_str()); -AddLog(LOG_LEVEL_DEBUG); +//snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Url |%s|"), url.c_str()); +//AddLog(LOG_LEVEL_DEBUG); client.print(url.c_str()); client.flush();