是否可以禁用HTTP Keep-Alive与libcurl
Is it possible to disable HTTP Keep-Alive with libcurl?
我正在为第三方私有API实现HTTP客户端。此API要求不使用HTTP Keep-Alive。libcurl
可以禁用Keep-Alive吗?即使当我设置CURLOPT_FORBID_REUSE
,它仍然发送Connection: Keep-Alive
头和混淆服务器。它甚至发送这个头,如果我手动设置Connection: close
头。在这种情况下,libcurl
发送Connection: Keep-Alive
和Connection: close
HTTP头。有没有人知道如何强迫libcurl
永远不要重用连接,并发送Connection: close
头通知服务器,它不使用连接,或者Connection: Keep-Alive
在libcurl
中硬编码,不能改变?
这可以通过CURLOPT_HTTPHEADER
:
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
struct curl_slist *list = NULL;
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
list = curl_slist_append(list, "Connection: close");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
curl_easy_perform(curl);
curl_slist_free_all(list);
curl_easy_cleanup(curl);
}
}
相关文章:
- 发送一个带有libcurl C++问题的帖子请求:s
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 在 libcurl 连接池中预创建连接
- libcurl 和 DNS ttl 中的内部连接管理
- 如何在 cmake 库中包含 libcurl
- 如何应用 libcurl 的持久连接选项
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 组合字符串不适用于 libCurl,C++
- Poloniex API "Invalid command" c++ libcurl
- libcurl :显示正在运行的上传和下载速率
- c++ libCurl :如何使用libCurl接受过期的证书
- libcurl :C++处理多个异步请求
- 现代C++的libcurl和JSON问题
- 使用 Libcurl 库进行文件下载
- 如何在C++生成器中使用libcurl
- Libcurl c++ "undefined reference to" (Windows/MinGW/g++)
- 如何使用 libcurl 在本地 IP 上获取 HTML?
- 如何将带有 -F 选项的 curl 命令转换为 libcurl
- 是否可以禁用HTTP Keep-Alive与libcurl
- 本地到本地连接的Keep-alive超时(Windows)