http: centralize the accounting of libcurl dependencies
As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.
However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.
So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.
More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.
By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-13 22:51:28 +08:00
|
|
|
#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.
|
|
|
|
*
|
2021-09-13 22:51:29 +08:00
|
|
|
* 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.
|
|
|
|
*
|
http: centralize the accounting of libcurl dependencies
As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.
However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.
So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.
More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.
By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-13 22:51:28 +08:00
|
|
|
* Keep any symbols in date order of when their support was
|
|
|
|
* introduced, oldest first, in the official version of cURL library.
|
|
|
|
*/
|
|
|
|
|
2021-09-13 22:51:29 +08:00
|
|
|
/**
|
|
|
|
* CURL_SOCKOPT_OK was added in 7.21.5, released in April 2011.
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM < 0x071505
|
|
|
|
#define CURL_SOCKOPT_OK 0
|
|
|
|
#endif
|
|
|
|
|
http: centralize the accounting of libcurl dependencies
As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.
However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.
So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.
More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.
By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-13 22:51:28 +08:00
|
|
|
/**
|
|
|
|
* CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012.
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x071900
|
|
|
|
#define GITCURL_HAVE_CURLOPT_TCP_KEEPALIVE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURLOPT_LOGIN_OPTIONS was added in 7.34.0, released in December
|
|
|
|
* 2013.
|
|
|
|
*
|
|
|
|
* If we start requiring 7.34.0 we might also be able to remove the
|
|
|
|
* code conditional on USE_CURL_FOR_IMAP_SEND in imap-send.c, see
|
|
|
|
* 1e16b255b95 (git-imap-send: use libcurl for implementation,
|
|
|
|
* 2014-11-09) and the check it added for "072200" in the Makefile.
|
|
|
|
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072200
|
|
|
|
#define GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURL_SSLVERSION_TLSv1_[012] was added in 7.34.0, released in
|
|
|
|
* December 2013.
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072200
|
|
|
|
#define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURLOPT_PINNEDPUBLICKEY was added in 7.39.0, released in November
|
2021-09-24 18:08:20 +08:00
|
|
|
* 2014. CURLE_SSL_PINNEDPUBKEYNOTMATCH was added in that same version.
|
http: centralize the accounting of libcurl dependencies
As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.
However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.
So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.
More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.
By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-13 22:51:28 +08:00
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072c00
|
|
|
|
#define GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY 1
|
2021-09-24 18:08:20 +08:00
|
|
|
#define GIT_CURL_HAVE_CURLE_SSL_PINNEDPUBKEYNOTMATCH 1
|
http: centralize the accounting of libcurl dependencies
As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.
However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.
So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.
More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.
By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-13 22:51:28 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURL_HTTP_VERSION_2 was added in 7.43.0, released in June 2015.
|
|
|
|
*
|
|
|
|
* The CURL_HTTP_VERSION_2 alias (but not CURL_HTTP_VERSION_2_0) has
|
|
|
|
* always been a macro, not an enum field (checked on curl version
|
|
|
|
* 7.78.0)
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072b00
|
|
|
|
#define GIT_CURL_HAVE_CURL_HTTP_VERSION_2 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURLSSLOPT_NO_REVOKE was added in 7.44.0, released in August 2015.
|
|
|
|
*
|
|
|
|
* The CURLSSLOPT_NO_REVOKE is, has always been a macro, not an enum
|
|
|
|
* field (checked on curl version 7.78.0)
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072c00
|
|
|
|
#define GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURLOPT_PROXY_CAINFO was added in 7.52.0, released in August 2017.
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400
|
|
|
|
#define GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURLOPT_PROXY_{KEYPASSWD,SSLCERT,SSLKEY} was added in 7.52.0,
|
|
|
|
* released in August 2017.
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400
|
|
|
|
#define GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURL_SSLVERSION_TLSv1_3 was added in 7.53.0, released in February
|
|
|
|
* 2017.
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400
|
|
|
|
#define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_3 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CURLSSLSET_{NO_BACKENDS,OK,TOO_LATE,UNKNOWN_BACKEND} were added in
|
|
|
|
* 7.56.0, released in September 2017.
|
|
|
|
*/
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800
|
|
|
|
#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
|
|
|
|
#endif
|
|
|
|
|
2024-04-06 04:04:51 +08:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
http: support CURLOPT_PROTOCOLS_STR
The CURLOPT_PROTOCOLS (and matching CURLOPT_REDIR_PROTOCOLS) flag was
deprecated in curl 7.85.0, and using it generate compiler warnings as of
curl 7.87.0. The path forward is to use CURLOPT_PROTOCOLS_STR, but we
can't just do so unilaterally, as it was only introduced less than a
year ago in 7.85.0.
Until that version becomes ubiquitous, we have to either disable the
deprecation warning or conditionally use the "STR" variant on newer
versions of libcurl. This patch switches to the new variant, which is
nice for two reasons:
- we don't have to worry that silencing curl's deprecation warnings
might cause us to miss other more useful ones
- we'd eventually want to move to the new variant anyway, so this gets
us set up (albeit with some extra ugly boilerplate for the
conditional)
There are a lot of ways to split up the two cases. One way would be to
abstract the storage type (strbuf versus a long), how to append
(strbuf_addstr vs bitwise OR), how to initialize, which CURLOPT to use,
and so on. But the resulting code looks pretty magical:
GIT_CURL_PROTOCOL_TYPE allowed = GIT_CURL_PROTOCOL_TYPE_INIT;
if (...http is allowed...)
GIT_CURL_PROTOCOL_APPEND(&allowed, "http", CURLOPT_HTTP);
and you end up with more "#define GIT_CURL_PROTOCOL_TYPE" macros than
actual code.
On the other end of the spectrum, we could just implement two separate
functions, one that handles a string list and one that handles bits. But
then we end up repeating our list of protocols (http, https, ftp, ftp).
This patch takes the middle ground. The run-time code is always there to
handle both types, and we just choose which one to feed to curl.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-01-17 11:04:48 +08:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
http: centralize the accounting of libcurl dependencies
As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.
However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.
So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.
More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.
By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-13 22:51:28 +08:00
|
|
|
#endif
|