#include "xburner_workflow_guest.h" #include #include static xburner_http_request_action_v1_t g_action; static uint8_t g_request_body[] = {0x0a, 0x04, 'p', 'i', 'n', 'g'}; static uint32_t g_sent; uint32_t get_abi_version(void) { return xburner_get_abi_version_v1(); } int32_t init(uint32_t vu_id, uint32_t seed_hi, uint32_t seed_lo) { (void)vu_id; (void)seed_hi; (void)seed_lo; return 0; } int32_t start_iteration(uint32_t input_ptr, uint32_t input_len) { (void)input_ptr; (void)input_len; g_sent = 0; return 0; } uint64_t next_request(void) { if (g_sent != 0) { return 0; } g_sent = 1; g_action.version = XBURNER_ABI_VERSION; g_action.flags = XBURNER_REQUEST_FLAG_HAS_BODY; g_action.request_id = 1; g_action.body_ptr = (uint32_t)(uintptr_t)g_request_body; g_action.body_len = (uint32_t)sizeof(g_request_body); g_action.timeout_ms = 0; g_action.capture_body_max_bytes = 0; return xburner_pack_ptr_len(&g_action, sizeof(g_action)); } int32_t handle_response(uint32_t meta_ptr, uint32_t meta_len, uint32_t body_ptr, uint32_t body_len) { const xburner_grpc_response_meta_v1_t *meta = (const xburner_grpc_response_meta_v1_t *)(uintptr_t)meta_ptr; const uint8_t *body = (const uint8_t *)(uintptr_t)body_ptr; size_t i; if (meta_len != sizeof(*meta)) { return XBURNER_HANDLE_RESPONSE_FATAL_SCRIPT_ERROR; } if (meta->grpc_status != 0 || meta->transport_code != XBURNER_TRANSPORT_NONE) { return XBURNER_HANDLE_RESPONSE_DONE_FAILED_CHECK; } if (body_len != sizeof(g_request_body)) { return XBURNER_HANDLE_RESPONSE_DONE_FAILED_CHECK; } for (i = 0; i < sizeof(g_request_body); ++i) { if (body[i] != g_request_body[i]) { return XBURNER_HANDLE_RESPONSE_DONE_FAILED_CHECK; } } return XBURNER_HANDLE_RESPONSE_DONE_SUCCESS; }