]> git.ipfire.org Git - thirdparty/git.git/commit - http.c
http: add custom hostname to IP address resolutions
authorChristian Couder <christian.couder@gmail.com>
Mon, 16 May 2022 08:38:51 +0000 (10:38 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 May 2022 16:46:52 +0000 (09:46 -0700)
commit511cfd3bffa685fda0e7c25bfa08082aa0de3a30
tree1945e94bd949f864817da2ad80abc0dc89014da8
parent6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
http: add custom hostname to IP address resolutions

Libcurl has a CURLOPT_RESOLVE easy option that allows
the result of hostname resolution in the following
format to be passed:

[+]HOST:PORT:ADDRESS[,ADDRESS]

This way, redirects and everything operating against the
HOST+PORT will use the provided ADDRESS(s).

The following format is also allowed to stop using
hostname resolutions that have already been passed:

-HOST:PORT

See https://curl.se/libcurl/c/CURLOPT_RESOLVE.html for
more details.

Let's add a corresponding "http.curloptResolve" config
option that takes advantage of CURLOPT_RESOLVE.

Each value configured for the "http.curloptResolve" key
is passed "as is" to libcurl through CURLOPT_RESOLVE, so
it should be in one of the above 2 formats. This keeps
the implementation simple and makes us consistent with
libcurl's CURLOPT_RESOLVE, and with curl's corresponding
`--resolve` command line option.

The implementation uses CURLOPT_RESOLVE only in
get_active_slot() which is called by all the HTTP
request sending functions.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/http.txt
http.c
t/t5551-http-fetch-smart.sh