我正在使用 CURLOPT_POST 发送 https 消息。在运行过程中,我的应用程序卡在:
期望:100-继续
完成等待 100-继续
我今天早些时候刚遇到这个问题。我发现以下页面也讨论了它并建议如何禁用:
George's Log——当 curl 发送 100-continue
特别是您可以在放置/发布请求中设置一个空的“期望:”标头。我在 curl 的回调后教程中找到了一些示例代码,其中包含以下带有 DISABLE_EXPECT “打喷嚏”防护的代码段:
#ifdef DISABLE_EXPECT
/*
Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue"
header. You can disable this header with CURLOPT_HTTPHEADER as usual.
NOTE: if you want chunked transfer too, you need to combine these two
since you can only set one list of headers with CURLOPT_HTTPHEADER. */
/* A less good option would be to enforce HTTP 1.0, but that might also
have other implications. */
{
struct curl_slist *chunk = NULL;
chunk = curl_slist_append(chunk, "Expect:");
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
/* use curl_slist_free_all() after the *perform() call to free this
list again */
}
#endif
Run Code Online (Sandbox Code Playgroud)
我保留了一个用于放置/发布请求的标头列表。将上述内容添加到该列表中的效果如广告所示:
// Disable Expect: 100-continue
vc->slist = curl_slist_append(vc->slist, "Expect:");
...
curl_easy_setopt(vc->curl, CURLOPT_HTTPHEADER, vc->slist);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8269 次 |
| 最近记录: |