如何将向量发布到HTTP端点
How to post vector to a HTTP endpoint
i具有以下数据类型,该数据类型在C
中填充std::vector<uint8_t> bytes;
使用libcurl,如何将其发布到HTTP端点?
尝试了以下代码,但我认为它与我的帖子数据不起作用
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://1.2.3.4:9002/multicastdataclient-message");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, &bytes);
res = curl_easy_perform(curl);
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %sn",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
基于所有注释,以下代码有效!
卷发 *卷发; 夹层res;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://1.2.3.4:9002/message");
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, bytes.size());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, bytes.data());
res = curl_easy_perform(curl);
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %sn",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
else
{
DBG("curl empty !!");
}
相关文章:
- 如何在boost beast http请求中设置http头
- 在多个核心中处理一个HTTP请求
- SFML library: http request
- 使用 Winsock2.h C++向不和谐 API 发送 HTTP 请求时出现问题
- 通过单独的 tcp 流建立 http 连接
- 使用 winsock 接收 http 请求
- 如何在 c++ 中通过 http 发送大型视频文件?
- 对于 http 请求,python 比 c++ 快吗?
- 使用 c++ 的 http 客户端的默认方法
- 如何使用C++和Boost Asio从HTTP发布请求中获取键值
- 如何使用boost/beast从HTTP POST请求中解析和提取有效负载?
- 如何重用 http::beast::flat_buffer 和 http::response?
- 在客户端和备忘录中获取 HTTP 命令
- 在C ++ ASIO中,如何为HTTP或HTTPS创建相同的套接字对象(接口/抽象问题?
- HTTP 响应格式不正确?
- 在 C++/C 中使用 CURL 发出带有数据文件的 GET HTTP 请求
- #include of a HTTP URL in C++
- 如何在 Poco 中将工作 HTTP 代码转换为 HTTPS
- HTTP异常::无法连接到任何解决的端点-CPPRESTSDK
- 如何将向量发布到HTTP端点