通过代理使用 C++/Boost 执行简单的 HTTP 请求?

2022-01-05 00:00:00 http proxy request c++ boost

我是 Boost 的新手,我通过使用库的代理浏览的唯一经验是使用 .NET(这对于这个目的来说非常方便).我现在正在尝试通过 HTTP 代理执行一个简单的 HTTP 请求.

I'm quite a newbie with Boost, and my only experience of surfing though a proxy using a library is using .NET (that is really convenient for that purpose). I'm now trying to perform a simple HTTP request through a HTTP proxy.

有没有直接使用 boost 的简洁方法?

Is there a tidy way to do it using boost directly?

我的代理使用 NTLM 身份验证.

My proxy use a NTLM authentification.

推荐答案

不,Boost 既不提供 HTTP 客户端,也不提供与代理交互的方式.您必须自己实现这些功能.

No, Boost provides neither an HTTP client nor a way to interface with proxies. You would necessarily have to implement those features yourself.

明确地说,是的,可以使用 Boost.Asio 实现 HTTP 客户端.但是实现一个可以通过代理进行可靠通信的客户端要复杂得多,而且除了低级套接字本身之外,Asio 不提供任何支持.它当然不包括执行 NTLM 身份验证的框架,这可能证明很难正确.

To be clear, yes, it is possible to implement an HTTP client using Boost.Asio. But implementing a client that can reliably talk through a proxy is significantly more complex, and Asio does not provide any support for that beyond the low-level socket itself. It certainly does not include the framework for performing NTLM authentication, which may prove difficult to get right.

更复杂的库,如 cURL 提供了这种支持.

More complex libraries like cURL provide that support.

相关文章