【发布时间】:2016-03-01 16:00:05
【问题描述】:
我在 Poco 中编写了一个 HTTP 客户端,它将 POST 请求发送到 HTTPServer 以下是sn-p
Poco::Net::HTTPClientSession s("127.0.0.1", 9090);
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/echo");
std::string body("rs=this is a random request body");
request.setContentLength(body.length());
s.sendRequest(request) << body;
服务器收到请求,但以下是我能找到的唯一获得蒸汽的方法(即 rs=this is a ....)
void SRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& hreq, Poco::Net::HTTPServerResponse& resp){
std::istream &i = hreq.stream();
Poco::StreamCopier::copyStream(i, ss, hreq.getContentLength());
}
所以剩下的获取客户端发送的内容的方法是使用字符串。 有没有更简单/直接的方式来获取内容?
【问题讨论】:
标签: poco-libraries