diff options
Diffstat (limited to 'src/driver.cpp')
| -rw-r--r-- | src/driver.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/driver.cpp b/src/driver.cpp index 2beff5b..a7b235c 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -63,10 +63,25 @@ void wifi_hotspot_start(const char *ssid, const char *password, WifiHandler hand WiFi.softAP(ssid, password); server.onNotFound([=]() { + String uri = server.uri(); + String body; + + // build body string from parsed args if plain isn't available + if (server.hasArg("plain")) { + body = server.arg("plain"); + } else { + for (int i = 0; i < server.args(); i++) { + if (!body.isEmpty()) body += "&"; + body += server.argName(i).c_str(); + body += "="; + body += server.arg(i).c_str(); + } + } + WifiRequest req = { - .uri = server.uri().c_str(), + .uri = uri.c_str(), .method = server.method() == HTTP_GET ? "GET" : "POST", - .body = server.hasArg("plain") ? server.arg("plain").c_str() : nullptr, + .body = body.isEmpty() ? nullptr : body.c_str(), }; WifiResponse res = handler(&req); server.send(res.status, res.content_type, res.body); |
