From dcc6f12c205a72604af0ece19750816a404da1ca Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Wed, 20 Oct 2021 11:43:28 -0700 Subject: [PATCH] force http 1.1 on the libcurl transport adapter (#2978) * force http 1.1 * update wording --- sdk/core/azure-core/CHANGELOG.md | 2 ++ sdk/core/azure-core/src/http/curl/curl.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 7b5898bdf..b5e36ae25 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -10,6 +10,8 @@ ### Bugs Fixed +[2848](https://github.com/Azure/azure-sdk-for-cpp/issues/2848) Update the libcurl transport adapter to work with HTTP/1.1 only. + ### Other Changes ## 1.2.1 (2021-09-02) diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index e2d062b29..4c957995c 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -1407,6 +1407,16 @@ std::unique_ptr CurlConnectionPool::ExtractOrCreateCurlCo } } + // curl-transport adapter supports only HTTP/1.1 + // https://github.com/Azure/azure-sdk-for-cpp/issues/2848 + // The libcurl uses HTTP/2 by default, if it can be negotiated with a server on handshake. + if (!SetLibcurlOption(newHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1, &result)) + { + throw Azure::Core::Http::TransportException( + _detail::DefaultFailedToGetNewConnectionTemplate + host + ". Failed to set libcurl HTTP/1.1" + + ". " + std::string(curl_easy_strerror(result))); + } + auto performResult = curl_easy_perform(newHandle); if (performResult != CURLE_OK) {