Skip to content

Commit e80ea0b

Browse files
Disable CURL diagnostics for old versions (#1589)
Disable timings for CURL versions before 7.61 Relates-To: OCMAM-418 Signed-off-by: Mykhailo Kuchma <ext-mykhailo.kuchma@here.com>
1 parent 5083986 commit e80ea0b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ void SetupDns(CURL* curl_handle, const std::vector<std::string>& dns_servers) {
348348
#endif
349349
}
350350

351-
Diagnostics GetDiagnostics(CURL* handle) {
351+
void WithDiagnostics(NetworkResponse& response, CURL* handle) {
352+
#if CURL_AT_LEAST_VERSION(7, 61, 0)
352353
Diagnostics diagnostics;
353-
354354
static const std::pair<Diagnostics::Timings, CURLINFO> available_timings[] = {
355355
#if CURL_AT_LEAST_VERSION(8, 6, 0)
356356
{Diagnostics::Queue, CURLINFO_QUEUE_TIME_T},
@@ -388,7 +388,10 @@ Diagnostics GetDiagnostics(CURL* handle) {
388388

389389
add_timing(Diagnostics::Total, Diagnostics::MicroSeconds(last_time_point));
390390

391-
return diagnostics;
391+
response.WithDiagnostics(diagnostics);
392+
#else
393+
OLP_SDK_CORE_UNUSED(response, handle);
394+
#endif
392395
}
393396

394397
} // anonymous namespace
@@ -1047,8 +1050,9 @@ void NetworkCurl::CompleteMessage(CURL* curl_handle, CURLcode result) {
10471050
auto response = NetworkResponse()
10481051
.WithRequestId(request_handle->id)
10491052
.WithBytesDownloaded(download_bytes)
1050-
.WithBytesUploaded(upload_bytes)
1051-
.WithDiagnostics(GetDiagnostics(curl_handle));
1053+
.WithBytesUploaded(upload_bytes);
1054+
1055+
WithDiagnostics(response, curl_handle);
10521056

10531057
if (request_handle->is_cancelled) {
10541058
response.WithStatus(static_cast<int>(ErrorCode::CANCELLED_ERROR))
@@ -1243,8 +1247,9 @@ void NetworkCurl::Run() {
12431247
.WithStatus(static_cast<int>(ErrorCode::IO_ERROR))
12441248
.WithError("CURL error")
12451249
.WithBytesDownloaded(download_bytes)
1246-
.WithBytesUploaded(upload_bytes)
1247-
.WithDiagnostics(GetDiagnostics(curl_handle));
1250+
.WithBytesUploaded(upload_bytes);
1251+
1252+
WithDiagnostics(response, curl_handle);
12481253

12491254
callback(response);
12501255
lock.lock();

0 commit comments

Comments
 (0)