|
发表于 2019-11-26 11:15:41
|
显示全部楼层
设置一下要发送的size就行,把要发送的数据放到缓冲区
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, size);
int HTTP_CLIENT::post_binary(const char *url, const void*post_data, int size)
{
CURLcode res;
data.offset = 0;
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, size);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fun);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
cout << curl_easy_strerror(res) << endl;
data.offset = -1;
return -1;
}
return data.offset;
} |
|