Skip to content

Commit

Permalink
libcurl 8.7 regression workaround (#4906)
Browse files Browse the repository at this point in the history
As discussed
[here](#4883 (comment)),
we should have a work-around in place before deploying libcurl 8.7.1.
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Apr 10, 2024
2 parents f01a287 + 92a209b commit 5587705
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Issues of note:
not need that functionality, use NO_CURL to build without
it.

Git requires version "7.19.5" or later of "libcurl" to build
Git requires version "7.21.3" or later of "libcurl" to build
without NO_CURL. This version requirement may be bumped in
the future.

Expand Down
9 changes: 9 additions & 0 deletions git-curl-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@
#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
#endif

/**
* 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.
Expand Down
1 change: 1 addition & 0 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ struct active_request_slot *get_active_slot(void)
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
Expand Down
3 changes: 3 additions & 0 deletions remote-curl.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "git-compat-util.h"
#include "git-curl-compat.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
Expand Down Expand Up @@ -955,7 +956,9 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
/* The request body is large and the size cannot be predicted.
* We must use chunked encoding to send it.
*/
#ifdef GIT_CURL_NEED_TRANSFER_ENCODING_HEADER
headers = curl_slist_append(headers, "Transfer-Encoding: chunked");
#endif
rpc->initial_buffer = 1;
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);
curl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);
Expand Down

0 comments on commit 5587705

Please sign in to comment.