From b4bb7cbc71558549e8dabb3925a78a37f3f5749d Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Wed, 10 Oct 2018 17:05:32 -0300 Subject: [PATCH] Accepted WebServer Query Arguments not containing an equals sign Fixes several issues and also Alexa queries. Previous behavior was to completely ignore the argument (if not contains an equals sign), yet still include it in the argument count. (The use of "key=value" arguments is a convention, not an actual requirement in URLs.) For example, Amazon Echo sends a put-request with content-type "application/x-www-form-urlencoded" set in the headers but sends out json encoded data. _parseArguments fails to parse the arguments (which is correct) but completly discards the data. This change checks if the parser picked something up and if it didn't, it just adds it as plain data to the arguments. --- libraries/ESP8266WebServer/src/Parsing.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/ESP8266WebServer/src/Parsing.cpp b/libraries/ESP8266WebServer/src/Parsing.cpp index 25bf6acec0..e1188b4004 100644 --- a/libraries/ESP8266WebServer/src/Parsing.cpp +++ b/libraries/ESP8266WebServer/src/Parsing.cpp @@ -337,6 +337,14 @@ void ESP8266WebServer::_parseArguments(String data) { break; pos = next_arg_index + 1; } + if (iarg == 0) { +#ifdef DEBUG_ESP_HTTP_SERVER + DEBUG_OUTPUT.println("add plain data"); +#endif + RequestArgument& arg = _currentArgs[iarg++]; + arg.key = "plain"; + arg.value = data; + } _currentArgCount = iarg; #ifdef DEBUG_ESP_HTTP_SERVER DEBUG_OUTPUT.print("args count: ");