From 948fc36aa4ed012ac4943237e771b6d187d43ce5 Mon Sep 17 00:00:00 2001 From: kkard2 Date: Wed, 10 Jun 2026 17:27:42 +0200 Subject: fix code (derogatory) --- src/driver.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/driver.cpp') 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); -- cgit v1.3.1