curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Time to disable "Expect: 100-continue" by default?

From: David Chapman <dcchapman_at_acm.org>
Date: Mon, 17 Jul 2017 16:47:41 -0700

On 7/17/2017 3:50 PM, Jeroen Ooms via curl-library wrote:
> On Thu, Jul 6, 2017 at 9:59 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>>
>> Applications that currently disable Expect: header use should of course not be affected by this sort of change. They would just disable it extra much! =)
>
> I've been debugging a problem with a server randomly returning 408 for
> POST requests occasionally, and I finally understand now it is
> happening because of this 1000ms idle time.
>
> What is the proper way to disable the 'Expect' header which will work
> across versions of libcurl? Does this work?
>
> assert(curl_easy_setopt(handle, CURLOPT_EXPECT_100_TIMEOUT_MS, 0L));

I can't comment on use of the Expect header, but I will note that you
should never put code with side effects into an assert() call - it may
in fact be a macro that is compiled out when NDEBUG is set. On my local
Linux machine, /usr/include/assert.h has this (simplified somewhat):

#ifdef NDEBUG
#define assert(expr) ((void) 0)
#endif

As you can see, the expression will not be executed.

Instead you'd want:

CURLcode res;

res = curl_easy_setopt(handle, CURLOPT_EXPECT_100_TIMEOUT_MS, 0L);
assert(res);

-- 
     David Chapman      dcchapman_at_acm.org
     Chapman Consulting -- San Jose, CA
     Software Development Done Right.
     www.chapman-consulting-sj.com
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-07-18