4

I am using CURLOPT_POST to send an https message. During running, my application stuck at:

Expect: 100-continue

Done waiting for 100-continue

Raedwald
  • 46,613
  • 43
  • 151
  • 237
Mini Rai
  • 51
  • 1
  • 1
  • 4
  • Even [the authors of libcurl think this behaviour of libcurl is not good](https://curl.haxx.se/mail/lib-2017-07/0013.html). – Raedwald Oct 30 '18 at 15:45
  • Possible duplicate of [libcurl delays for 1 second before uploading data, command-line curl does not](https://stackoverflow.com/questions/17383089/libcurl-delays-for-1-second-before-uploading-data-command-line-curl-does-not) – Raedwald Oct 30 '18 at 16:00

1 Answers1

8

From George's Log -- When curl sends 100-continue, you can set the Expect header to the empty string:

curl -X POST -H "Expect:" http://mywebsite.com/an/endpoint -F data=@myfile

Explanation

In particular you can set an empty "Expect:" header in your put / post request. i found some sample code in the post-callback tutorial for curl that contains the following snippet with a DISABLE_EXPECT "sneeze" guard:

#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

i keep an slist of headers to use for put / post requests. adding the equivalent of the above to that list works as advertised:

// Disable Expect: 100-continue
vc->slist = curl_slist_append(vc->slist, "Expect:");
...
curl_easy_setopt(vc->curl, CURLOPT_HTTPHEADER, vc->slist);
gmelodie
  • 411
  • 4
  • 18
jmer
  • 371
  • 2
  • 12