如何解决使用 C 从 http 请求中提取 post 值
我正在尝试从中提取 POST 字段数据:
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
变量 request
包含整个消息:
WiFiClient client = server.available();
String request = client.readString();
Serial.println(request);
WifiClient 文档:https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/client-class.html
我尝试将它与 strtok()
像这样拆分,但出现转换错误:
WiFiClient client = server.available();
String request = client.readString();
String req = strtok(request,'\r');
Serial.println(req);
这是错误:
无法将参数 '1' 的 'String' 转换为 'char*' 到 'char*' strtok(char*,const char*)'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。