尝试使用libcurlpp(libcurl的C++包装器)发布表单并获取响应.这一切都有效,但我不知道如何在http事务完成后以编程方式访问curlpp :: Easy对象的响应.Bascially:
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
...
curlpp::Easy foo;
foo.setOpt( new curlpp::options::Url( "http://example.com/" ) );
foo.setOpt( new curlpp::options::Verbose( true ) );
...many other options set...
foo.perform();  // this executes the HTTP transaction
当这段代码运行时,因为Verbose设置为trueI我可以看到响应得到输出到STDOUT.但是如何获得完整的响应而不是将其转储到STDOUT?curlpp :: Easy似乎没有任何方法可以访问响应.
谷歌有很多点击,人们问同样的问题,但没有回复.curlpp邮件列表是一个死区,curlpp网站的API部分已经被打破了一年.
Sté*_*ane 10
这就是我最终做到的方式:
// HTTP response body (not headers) will be sent directly to this stringstream
std::stringstream response;
curlpp::Easy foo;
foo.setOpt( new curlpp::options::Url( "http://www.example.com/" ) );
foo.setOpt( new curlpp::options::UserPwd( "blah:passwd" ) );
foo.setOpt( new curlpp::options::WriteStream( &response ) );
// send our request to the web server
foo.perform();
一旦foo.perform()返回,现在可以在提供的流中使用完整的响应主体WriteStream().
| 归档时间: | 
 | 
| 查看次数: | 2035 次 | 
| 最近记录: |