-
Notifications
You must be signed in to change notification settings - Fork 4
/
HttpClient.cpp
49 lines (30 loc) · 982 Bytes
/
HttpClient.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "HttpClient.h"
HttpClient::HttpClient()
{
}
void HttpClient::HttpSendPerformanceData()
{
string url = "http://192.168.1.200:8000/postNodeStatus.php";
Poco::URI uri(url);
string path = uri.getPath();
HTTPClientSession session(uri.getHost(), uri.getPort());
session.setKeepAlive(true);
HTTPRequest req(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1);
req.setContentType("application/x-www-form-urlencoded");
req.setKeepAlive(true);
GenerateJsonData *json = new GenerateJsonData();
Json::Value performance = json->GetPerformanceData();
string databody = performance.toStyledString();
string data = "data=" + databody;
req.setContentLength(data.length());
//ostream &myOstream = session.sendRequest(req);
//myOstream <<data;
/*HTTPResponse rep(HTTPResponse::HTTPStatus::HTTP_OK);
istream &myIstream = session.receiveResponse(rep);
cout<<myIstream.rdbuf() << endl;
*/
cout << "send ok" << endl;
}
HttpClient::~HttpClient()
{
}