From e96e7ca8d06e08a13189cbe6d55c51e4d302a50c Mon Sep 17 00:00:00 2001 From: Mykhailo Kuchma Date: Mon, 10 Feb 2025 13:42:36 +0100 Subject: [PATCH] Disable CURL diagnostics for old versions Disable timings for CURL versions before 7.61 Relates-To: OCMAM-418 Signed-off-by: Mykhailo Kuchma --- .../src/http/curl/NetworkCurl.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp index 9d28247cf..09add1d0c 100644 --- a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp +++ b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp @@ -348,9 +348,9 @@ void SetupDns(CURL* curl_handle, const std::vector& dns_servers) { #endif } -Diagnostics GetDiagnostics(CURL* handle) { +void WithDiagnostics(NetworkResponse& response, CURL* handle) { +#if CURL_AT_LEAST_VERSION(7, 61, 0) Diagnostics diagnostics; - static const std::pair available_timings[] = { #if CURL_AT_LEAST_VERSION(8, 6, 0) {Diagnostics::Queue, CURLINFO_QUEUE_TIME_T}, @@ -388,7 +388,10 @@ Diagnostics GetDiagnostics(CURL* handle) { add_timing(Diagnostics::Total, Diagnostics::MicroSeconds(last_time_point)); - return diagnostics; + response.WithDiagnostics(diagnostics); +#else + OLP_SDK_CORE_UNUSED(response, handle); +#endif } } // anonymous namespace @@ -1047,8 +1050,9 @@ void NetworkCurl::CompleteMessage(CURL* curl_handle, CURLcode result) { auto response = NetworkResponse() .WithRequestId(request_handle->id) .WithBytesDownloaded(download_bytes) - .WithBytesUploaded(upload_bytes) - .WithDiagnostics(GetDiagnostics(curl_handle)); + .WithBytesUploaded(upload_bytes); + + WithDiagnostics(response, curl_handle); if (request_handle->is_cancelled) { response.WithStatus(static_cast(ErrorCode::CANCELLED_ERROR)) @@ -1243,8 +1247,9 @@ void NetworkCurl::Run() { .WithStatus(static_cast(ErrorCode::IO_ERROR)) .WithError("CURL error") .WithBytesDownloaded(download_bytes) - .WithBytesUploaded(upload_bytes) - .WithDiagnostics(GetDiagnostics(curl_handle)); + .WithBytesUploaded(upload_bytes); + + WithDiagnostics(response, curl_handle); callback(response); lock.lock();