我正在使用CURLOPT_POST发送https消息。在运行期间,我的应用程序停留在:
期待:100-continue
等待100-continue
答案 0 :(得分:2)
我刚刚在今天早些时候遇到了这个问题。我发现下面的页面也对此进行了讨论,并建议如何禁用它:
George's Log -- When curl sends 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
我保留一个头列表以用于放置/发布请求。将上述内容的等效项添加到该列表中,即可如广告所示:
// Disable Expect: 100-continue
vc->slist = curl_slist_append(vc->slist, "Expect:");
...
curl_easy_setopt(vc->curl, CURLOPT_HTTPHEADER, vc->slist);