我正在诊断一个奇怪的网络问题,(我认为)我已经将其范围缩小到行为不当的 HTTP 客户端或服务器以及一些 HTTP1.1 管道和/或 Nagle 的算法交互。我试图在curl 中禁用TCP_NODELAY 作为测试。
Curl 的手册页显示:
--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.
Run Code Online (Sandbox Code Playgroud)
然后它永远不会解释如何显式地将其关闭。我尝试export CURLOPT_TCP_NODELAY=0在环境中进行设置,但curl仍然在其输出中提到:
* TCP_NODELAY set
Run Code Online (Sandbox Code Playgroud)
搜索互联网或 Stackoverflow 也没有给我答案。
那么我该如何关闭它呢?
我应该更好地阅读手册。它说:
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.)
Run Code Online (Sandbox Code Playgroud)
所以我可以禁用TCP_NODELAY:
curl -v --no-tcp-nodelay <url>
Run Code Online (Sandbox Code Playgroud)
并且输出不再包含该TCP_NODELAY set消息。