static int s_aws_nitro_enclaves_kms_client_call_blocking()

in source/kms.c [2534:2566]


static int s_aws_nitro_enclaves_kms_client_call_blocking(
    struct aws_nitro_enclaves_kms_client *client,
    struct aws_byte_cursor target,
    struct aws_string *request,
    struct aws_string **response) {
    *response = NULL;

    struct aws_nitro_enclaves_rest_response *rest_response = aws_nitro_enclaves_rest_client_request_blocking(
        client->rest_client,
        aws_http_method_post,
        aws_byte_cursor_from_c_str("/"),
        target,
        aws_byte_cursor_from_string(request));
    if (rest_response == NULL) {
        return AWS_OP_ERR;
    }

    struct aws_input_stream *request_stream = aws_http_message_get_body_stream(rest_response->response);
    struct aws_byte_buf response_data;
    int64_t length;
    aws_input_stream_get_length(request_stream, &length);

    aws_byte_buf_init(&response_data, client->allocator, length);
    aws_input_stream_read(request_stream, &response_data);
    *response = aws_string_new_from_array(client->allocator, response_data.buffer, response_data.len);
    aws_byte_buf_clean_up(&response_data);

    int status = AWS_OP_SUCCESS;
    aws_http_message_get_response_status(rest_response->response, &status);
    aws_nitro_enclaves_rest_response_destroy(rest_response);

    return status;
}