Skip to content

Commit

Permalink
Merge topic 'curl-http2'
Browse files Browse the repository at this point in the history
7486f46 curl: Avoid using HTTP/2 with curl 8.7.x due to bug in error codes

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !9728
  • Loading branch information
bradking authored and kwrobot committed Aug 15, 2024
2 parents 41da7a4 + 7486f46 commit 0460e71
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Source/CTest/cmCTestCurl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cmCTestCurl::cmCTestCurl(cmCTest* ctest)
cmCurlInitOnce();
// In windows, this will init the winsock stuff
::curl_global_init(CURL_GLOBAL_ALL);
this->Curl = curl_easy_init();
this->Curl = cm_curl_easy_init();
}

cmCTestCurl::~cmCTestCurl()
Expand Down
2 changes: 1 addition & 1 deletion Source/CTest/cmCTestSubmitHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
cmCTestCurlOpts curlOpts(this->CTest);
for (std::string const& file : files) {
/* get a curl handle */
curl = curl_easy_init();
curl = cm_curl_easy_init();
if (curl) {
cmCurlSetCAInfo(curl);
if (curlOpts.TLSVersionOpt) {
Expand Down
12 changes: 12 additions & 0 deletions Source/cmCurl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,15 @@ std::string cmCurlFixFileURL(std::string url)

return url;
}

::CURL* cm_curl_easy_init()
{
::CURL* curl = curl_easy_init();
if (curl_version_info_data* cv = curl_version_info(CURLVERSION_FIRST)) {
// curl 8.7.x returns incorrect HTTP/2 error codes.
if (cv->version_num >= 0x080700 && cv->version_num < 0x080800) {
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
}
}
return curl;
}
2 changes: 2 additions & 0 deletions Source/cmCurl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ std::string cmCurlSetCAInfo(::CURL* curl, const std::string& cafile = {});
std::string cmCurlSetNETRCOption(::CURL* curl, const std::string& netrc_level,
const std::string& netrc_file);
std::string cmCurlFixFileURL(std::string url);

::CURL* cm_curl_easy_init();
4 changes: 2 additions & 2 deletions Source/cmFileCommand.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
::CURL* curl;
cmCurlInitOnce();
::curl_global_init(CURL_GLOBAL_DEFAULT);
curl = ::curl_easy_init();
curl = cm_curl_easy_init();
if (!curl) {
status.SetError("DOWNLOAD error initializing curl.");
return false;
Expand Down Expand Up @@ -2542,7 +2542,7 @@ bool HandleUploadCommand(std::vector<std::string> const& args,
::CURL* curl;
cmCurlInitOnce();
::curl_global_init(CURL_GLOBAL_DEFAULT);
curl = ::curl_easy_init();
curl = cm_curl_easy_init();
if (!curl) {
status.SetError("UPLOAD error initializing curl.");
fclose(fin);
Expand Down

0 comments on commit 0460e71

Please sign in to comment.