Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable commandline Curl's TCP_NODELAY option?

Tags:

curl

I'm diagnosing a weird networking problem, which (I think) I've narrowed down to misbehaving HTTP clients or servers and some HTTP1.1 pipelining and / or Nagle's algorithm interaction. I'm trying to disable TCP_NODELAY in curl as a test.

Curl's man page says:

--tcp-nodelay
      Turn on the TCP_NODELAY option. See the curl_easy_setopt(3) man page for details about this option.

      Since 7.50.2, curl sets this option by default and you need to explicitly switch it off if you don't want it on.

      Added in 7.11.2.

It then never explains how to explicitly switch it off. I tried setting export CURLOPT_TCP_NODELAY=0 in the environment, but curl still mentions in its output:

* TCP_NODELAY set

Searching the internet or Stackoverflow is also not giving me an answer.

So how can I turn it off?

like image 258
Ferry Boender Avatar asked Oct 26 '25 04:10

Ferry Boender


1 Answers

I should have read the manual a little better. It says:

In  general,  all boolean options are enabled with --option and yet again
disabled with --no-option. That is, you use the exact same option name but
prefix it with "no-". However, in this list we mostly only list and show
the --option version of them. (This concept with --no options was added in
7.19.0.  Previously  most  options  were  toggled  on/off  on repeated use
of the same command line option.)

So I can disable TCP_NODELAY with:

curl -v --no-tcp-nodelay <url>

And the output no longer includes the TCP_NODELAY set message.

like image 104
Ferry Boender Avatar answered Oct 28 '25 03:10

Ferry Boender