使用boost :: asio发送HTTP GET请求,类似于cURL [英] Sending http GET request using boost::asio, similar to cURL

查看:511
本文介绍了使用boost :: asio发送HTTP GET请求,类似于cURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用某个域的REST API发送http GET请求. 基本上我想做的是替换以下curl请求:

I'm trying to send a http GET request using the REST API of some domain. Basically what I'm trying to do is to replace following curl request:

    curl -k  -H "Content-Type: application/json" -X GET 
--data '{"username":"user@name.co", "password":"test"}' https:/domain.name/api/login/

以及一些使用boost::asio的c ++代码. 我没有在这里找到所有c ++代码的东西,但是一些检查点会很棒.

with some c++ code using boost::asio. I do not what to find all c++ code here , but some checkpoints would be great.

推荐答案

boost::asio不是应用程序级库.因此,您可以与其建立连接,进行SSL握手等.但是您不能通过boost::asio构造HTTP请求,因为它仅用于发送/接收数据.

boost::asio is not an application level library. So you can open a connection with it, do an SSL handshake and so on. But you cannot construct HTTP requests via boost::asio since it's designed to just send/receive data.

但是,您可以尝试使用

But, you can try to experiment with this asio HTTP client example. Probably this can be a good thing to start with.

这篇关于使用boost :: asio发送HTTP GET请求,类似于cURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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