Skip to content

Commit 8c06394

Browse files
authored
libcurl 8.7 regression workaround (#4906)
As discussed [here](#4883 (comment)), we should have a work-around in place before deploying libcurl 8.7.1.
2 parents ad0bbff + 92a209b commit 8c06394

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Issues of note:
139139
not need that functionality, use NO_CURL to build without
140140
it.
141141

142-
Git requires version "7.19.5" or later of "libcurl" to build
142+
Git requires version "7.21.3" or later of "libcurl" to build
143143
without NO_CURL. This version requirement may be bumped in
144144
the future.
145145

git-curl-compat.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@
126126
#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
127127
#endif
128128

129+
/**
130+
* Versions before curl 7.66.0 (September 2019) required manually setting the
131+
* transfer-encoding for a streaming POST; after that this is handled
132+
* automatically.
133+
*/
134+
#if LIBCURL_VERSION_NUM < 0x074200
135+
#define GIT_CURL_NEED_TRANSFER_ENCODING_HEADER
136+
#endif
137+
129138
/**
130139
* CURLOPT_PROTOCOLS_STR and CURLOPT_REDIR_PROTOCOLS_STR were added in 7.85.0,
131140
* released in August 2022.

http.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,7 @@ struct active_request_slot *get_active_slot(void)
14881488
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);
14891489
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
14901490
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
1491+
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);
14911492
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
14921493
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
14931494
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);

remote-curl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "git-compat-util.h"
2+
#include "git-curl-compat.h"
23
#include "config.h"
34
#include "environment.h"
45
#include "gettext.h"
@@ -960,7 +961,9 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
960961
/* The request body is large and the size cannot be predicted.
961962
* We must use chunked encoding to send it.
962963
*/
964+
#ifdef GIT_CURL_NEED_TRANSFER_ENCODING_HEADER
963965
headers = curl_slist_append(headers, "Transfer-Encoding: chunked");
966+
#endif
964967
rpc->initial_buffer = 1;
965968
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);
966969
curl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);

0 commit comments

Comments
 (0)