带有uri :: uri的cpp-netlib请求 [英] cpp-netlib request with uri::uri

查看:128
本文介绍了带有uri :: uri的cpp-netlib请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将cpp-netlib版本0.11与Boost 1.55配合使用,并希望使用以下几行创建一个请求对象:

I'm using the cpp-netlib version 0.11 with boost 1.55 and want to create a request object with these lines:

#include <iostream>

#include <boost/network/protocol/http/client.hpp>
#include <boost/network/uri.hpp>
#include <boost/network/uri/uri_io.hpp>

using namespace boost::network;
typedef http::basic_client< http::tags::http_default_8bit_tcp_resolve ,1,1> httpClient;

int main() {
   uri::uri url = std::string("http://www.abcs.de/");

   httpClient::request req;
   req << header("Content-Type", "application/x-www-form-urlencoded");

   req << url; // THIS LINE DOESN'T COMPILE
}

如果我正确阅读了文档(此处),则该行设置请求网址应该可以,但是我只能得到

If I read the documentation (here) right, that line to set the request url should work, but I only get

/usr/local/include/boost/network/protocol/http/request.hpp: In instantiation of ‘boost::network::http::basic_request<Tag>& boost::network::http::operator<<(boost::network::http::basic_request<Tag>&, const Directive&) [with Tag = boost::network::http::tags::http_default_8bit_tcp_resolve; Directive = boost::network::uri::uri]’:
src/receiver.h:33:11:   required from here
/usr/local/include/boost/network/protocol/http/request.hpp:71:26: error: no match for call to ‘(const boost::network::uri::uri) (boost::network::http::basic_request<boost::network::http::tags::http_default_8bit_tcp_resolve>&)’
         directive(message);

推荐答案

到httpClient :: request对象具有用于设置url的成员方法 req.uri( url )有效

To httpClient::request object has a member method to set the url req.uri( url ) works

这篇关于带有uri :: uri的cpp-netlib请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆