gpt4 book ai didi

http - 在 libcurl 中更改 HTTP 请求中的单个 header 字段

转载 作者:可可西里 更新时间:2023-11-01 17:10:55 25 4
gpt4 key购买 nike

我写了一个 HTTP 客户端程序。因为我从另一个进程获取数据并将其添加到请求的 POST 字段中。但是 libcurl 使用内容类型作为 application/x-www-form-urlencoded。但我只想将内容类型更改为 binary,我应该如何只更改 content-type 它而不需要手动更改其他字段,如 content-length,agent ..等等?

              curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, shell_machine); //shell_machine is xxx.xx.xx.xx:8080/xxx
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buf); // buf is my post data
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, post_size); // size of my post data

curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");

res = curl_easy_perform(curl);

最佳答案

CURLOPT_HTTPHEADER是你的 friend 。用法显示在 httpcustomheader.c 中示例。

关于http - 在 libcurl 中更改 HTTP 请求中的单个 header 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15732957/

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