我想了解什么样的服务器响应我的 HTTPClient?这是一个普通的 apache HTTP 服务器吗?
我需要知道如何通过 URL 表单提交 POST,类似于
http://myserver/post?message=text&submit=send
你能给我一些关于学习什么的建议吗?
这是用于微控制器的示例 C++ HTTPClient 代码
HTTPMap map;
HTTPText inText(str, 512);
map.put("Hello", "World");
map.put("test", "1234");
printf("\nTrying to post data...\n");
ret = http.post("http://httpbin.org/post", map, &inText);
if (!ret)
{
printf("Executed POST successfully - read %d characters\n", strlen(str));
printf("Result: %s\n", str);
}
else
{
printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
}
这是它返回的结果
Trying to post data...
Executed POST successfully - read 344 characters
Result: {
"headers": {
"Content-Length": "21",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"Connection": "close"
},
"url": "http://httpbin.org/post",
"data": "",
"origin": "<//my IP>",
"args": {},
"form": {
"Hello": "World",
"test": "1234"
},
"json": null,
"files": {}
}