curl supports a few options to control when and how often it should
instruct the OS to send TCP keepalives, like KEEPIDLE, KEEPINTVL, and
KEEPCNT. Until this point, there hasn't been a way for users to change
what values are used for these options, forcing them to rely on curl's
defaults.
But we do unconditionally enable TCP keepalives without giving users an
ability to tweak any fine-grained parameters. Ordinarily this isn't a
problem, particularly for users that have fast-enough connections,
and/or are talking to a server that has generous or nonexistent
thresholds for killing a connection it hasn't heard from in a while.
But it can present a problem when one or both of those assumptions fail.
For instance, I can reliably get an in-progress clone to be killed from
the remote end when cloning from some forges while using trickle to
limit my clone's bandwidth.
For those users and others who wish to more finely tune the OS's
keepalive behavior, expose configuration and environment variables which
allow setting curl's KEEPIDLE, KEEPINTVL, and KEEPCNT options.
Note that while KEEPIDLE and KEEPINTVL were added in curl 7.25.0,
KEEPCNT was added much more recently in curl 8.9.0. Per f7c094060c
(git-curl-compat: remove check for curl 7.25.0, 2024-10-23), both
KEEPIDLE and KEEPINTVL are set unconditionally. But since we may be
compiled with a curl that isn't as new as 8.9.0, only set KEEPCNT when
we have CURLOPT_TCP_KEEPCNT to begin with.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Acked-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
56 lines
1.7 KiB
C
56 lines
1.7 KiB
C
#ifndef GIT_CURL_COMPAT_H
|
|
#define GIT_CURL_COMPAT_H
|
|
#include <curl/curl.h>
|
|
|
|
/**
|
|
* This header centralizes the declaration of our libcurl dependencies
|
|
* to make it easy to discover the oldest versions we support, and to
|
|
* inform decisions about removing support for older libcurl in the
|
|
* future.
|
|
*
|
|
* The oldest supported version of curl is documented in the "INSTALL"
|
|
* document.
|
|
*
|
|
* The source of truth for what versions have which symbols is
|
|
* https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions;
|
|
* the release dates are taken from curl.git (at
|
|
* https://github.com/curl/curl/).
|
|
*
|
|
* For each X symbol we need from curl we define our own
|
|
* GIT_CURL_HAVE_X. If multiple similar symbols with the same prefix
|
|
* were defined in the same version we pick one and check for that name.
|
|
*
|
|
* We may also define a missing CURL_* symbol to its known value, if
|
|
* doing so is sufficient to add support for it to older versions that
|
|
* don't have it.
|
|
*
|
|
* Keep any symbols in date order of when their support was
|
|
* introduced, oldest first, in the official version of cURL library.
|
|
*/
|
|
|
|
/**
|
|
* Versions before curl 7.66.0 (September 2019) required manually setting the
|
|
* transfer-encoding for a streaming POST; after that this is handled
|
|
* automatically.
|
|
*/
|
|
#if LIBCURL_VERSION_NUM < 0x074200
|
|
#define GIT_CURL_NEED_TRANSFER_ENCODING_HEADER
|
|
#endif
|
|
|
|
/**
|
|
* CURLOPT_PROTOCOLS_STR and CURLOPT_REDIR_PROTOCOLS_STR were added in 7.85.0,
|
|
* released in August 2022.
|
|
*/
|
|
#if LIBCURL_VERSION_NUM >= 0x075500
|
|
#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1
|
|
#endif
|
|
|
|
/**
|
|
* CURLOPT_TCP_KEEPCNT was added in 8.9.0, released in July, 2024.
|
|
*/
|
|
#if LIBCURL_VERSION_NUM >= 0x080900
|
|
#define GIT_CURL_HAVE_CURLOPT_TCP_KEEPCNT
|
|
#endif
|
|
|
|
#endif
|