gpt4 book ai didi

c++ - 带有 uri::uri 的 cpp-netlib 请求

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:52:24 27 4
gpt4 key购买 nike

我正在使用带有 boost 1.55 的 cpp-netlib 版本 0.11,并想用这些行创建一个请求对象:

#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
}

如果我正确阅读文档(here),设置请求 url 的那一行应该有效,但我只得到

/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对象有一个成员方法来设置urlreq.uri( url ) 有效

关于c++ - 带有 uri::uri 的 cpp-netlib 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26179628/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com