Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ void SetupDns(CURL* curl_handle, const std::vector<std::string>& 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<Diagnostics::Timings, CURLINFO> available_timings[] = {
#if CURL_AT_LEAST_VERSION(8, 6, 0)
{Diagnostics::Queue, CURLINFO_QUEUE_TIME_T},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<int>(ErrorCode::CANCELLED_ERROR))
Expand Down Expand Up @@ -1243,8 +1247,9 @@ void NetworkCurl::Run() {
.WithStatus(static_cast<int>(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();
Expand Down
Loading