Skip to content

Commit 229ee01

Browse files
Disable CURL diagnostics for old versions
Disable timings for CURL versions before 7.61 Relates-To: OCMAM-418 Signed-off-by: Mykhailo Kuchma <[email protected]>
1 parent 5083986 commit 229ee01

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

Lines changed: 10 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,8 @@ Diagnostics GetDiagnostics(CURL* handle) {
388388

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

391-
return diagnostics;
391+
response.WithDiagnostics(diagnostics);
392+
#endif
392393
}
393394

394395
} // anonymous namespace
@@ -1047,8 +1048,9 @@ void NetworkCurl::CompleteMessage(CURL* curl_handle, CURLcode result) {
10471048
auto response = NetworkResponse()
10481049
.WithRequestId(request_handle->id)
10491050
.WithBytesDownloaded(download_bytes)
1050-
.WithBytesUploaded(upload_bytes)
1051-
.WithDiagnostics(GetDiagnostics(curl_handle));
1051+
.WithBytesUploaded(upload_bytes);
1052+
1053+
WithDiagnostics(response, curl_handle);
10521054

10531055
if (request_handle->is_cancelled) {
10541056
response.WithStatus(static_cast<int>(ErrorCode::CANCELLED_ERROR))
@@ -1243,8 +1245,9 @@ void NetworkCurl::Run() {
12431245
.WithStatus(static_cast<int>(ErrorCode::IO_ERROR))
12441246
.WithError("CURL error")
12451247
.WithBytesDownloaded(download_bytes)
1246-
.WithBytesUploaded(upload_bytes)
1247-
.WithDiagnostics(GetDiagnostics(curl_handle));
1248+
.WithBytesUploaded(upload_bytes);
1249+
1250+
WithDiagnostics(response, curl_handle);
12481251

12491252
callback(response);
12501253
lock.lock();

0 commit comments

Comments
 (0)