bool fetch_response()

in src/dcap_provider.cpp [1089:1132]


bool fetch_response(
    std::string base_url,
    std::unique_ptr<curl_easy>& curl,
    std::map<std::string, std::string> header_value,
    quote3_error_t &retval,
    unsigned long dwFlags = 0x00800000)
{
    bool fetch_response = false;
    try
    {
        curl = curl_easy::create(base_url, nullptr, dwFlags);
        log(SGX_QL_LOG_INFO,
            "Fetching certificate from: '%s'.",
            base_url.c_str());
        curl->set_headers(header_value);
        curl->perform();
        fetch_response = true;
    }
    catch (const std::bad_alloc&)
    {
        log_message(SGX_QL_LOG_ERROR, "Out of memory thrown");
        retval = SGX_QL_ERROR_OUT_OF_MEMORY;
    }
    catch (const std::runtime_error& error)
    {
        log(SGX_QL_LOG_WARNING,
            "Runtime exception thrown, error: %s",
            error.what());
    }
    catch (const curl_easy::error& error)
    {
        log(SGX_QL_LOG_ERROR,
            "error thrown, error code: %x: %s",
            error.code,
            error.what());
    }
    catch (const std::exception& error)
    {
        log(SGX_QL_LOG_ERROR,
            "Unknown exception thrown, error: %s",
            error.what());
    }
    return fetch_response;
}