I'm trying to extract POST fields data from this:
POST / HTTP/1.1
Host: 192.168.4.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 54
Origin: http://192.168.4.1
Connection: keep-alive
Referer: http://192.168.4.1/
Upgrade-Insecure-Requests: 1
readHere=ok&ssidName=Itziks+Home&ssidPassword=123456789
The variable request
hold the whole message:
WiFiClient client = server.available();
String request = client.readString();
Serial.println(request);
WifiClient documentation: https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/client-class.html
I've tried to split it with strtok()
like this and I get an convert error:
WiFiClient client = server.available();
String request = client.readString();
String req = strtok(request,'\r');
Serial.println(req);
And this is the error:
cannot convert 'String' to 'char*' for argument '1' to 'char* strtok(char*, const char*)'
I can't really think of a practical way to doing this. Thank for the help.