#pragma once #include "ccm/util/Result.hpp" #include #include namespace ccm { // Shared classification for raw HTTP GET outcomes (transport vs status vs OK). // `CprHttpClient::get` delegates here so doctest can exercise the branches // without touching libcpr or the network stack. [[nodiscard]] inline Result mapHttpGetResponse(bool curlTransportError, std::string_view curlErrorMessage, long httpStatusCode, std::string responseBody, std::string_view requestUrl) { if (curlTransportError) { return Result::err(std::string("HTTP error: ") + std::string(curlErrorMessage)); } if (httpStatusCode < 200 || httpStatusCode >= 300) { return Result::err( "HTTP " + std::to_string(httpStatusCode) + " from " + std::string(requestUrl)); } return Result::ok(std::move(responseBody)); } } // namespace ccm