Skip to content

Commit eba498a

Browse files
committed
Merge branch 'jk/libcurl-8.7-regression-workaround'
Fix was added to work around a regression in libcURL 8.7.0 (which has already been fixed in their tip of the tree). * jk/libcurl-8.7-regression-workaround: remote-curl: add Transfer-Encoding header only for older curl INSTALL: bump libcurl version to 7.21.3 http: reset POSTFIELDSIZE when clearing curl handle
2 parents 372aabe + 92a209b commit eba498a

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
@@ -1452,6 +1452,7 @@ struct active_request_slot *get_active_slot(void)
14521452
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);
14531453
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
14541454
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
1455+
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);
14551456
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
14561457
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
14571458
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"
@@ -955,7 +956,9 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
955956
/* The request body is large and the size cannot be predicted.
956957
* We must use chunked encoding to send it.
957958
*/
959+
#ifdef GIT_CURL_NEED_TRANSFER_ENCODING_HEADER
958960
headers = curl_slist_append(headers, "Transfer-Encoding: chunked");
961+
#endif
959962
rpc->initial_buffer = 1;
960963
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);
961964
curl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);

0 commit comments

Comments
 (0)