const std = @import("std"); const config = @import("../config.zig"); const grpc_executor = @import("grpc_executor.zig"); const http_executor = @import("http_executor.zig"); const http_state = @import("http_state.zig"); const plugin = @import("../plugin.zig"); const template = @import("../template.zig"); pub const RequestExecution = http_executor.RequestExecution; pub const TlsContext = http_executor.TlsContext; pub const CookieJar = http_state.CookieJar; pub fn executeConfiguredRequest( allocator: std.mem.Allocator, scenario: *const config.ScenarioConfig, client: *std.http.Client, grpc_client: *grpc_executor.Client, store: *const template.VarStore, tls_context: *TlsContext, cookie_jar: ?*CookieJar, method: config.HttpMethod, path_template: []const u8, header_templates: []const config.HeaderTemplate, body_template: ?[]const u8, body_override: ?[]const u8, connect_timeout_ms: u32, timeout_ms: u32, delay_before_ms: u32, capture_body_max_bytes: u32, ) !RequestExecution { if (scenario.http.transport_plugin != null) { return plugin.executeTransport( allocator, scenario, store, if (cookie_jar) |jar| jar else null, scenario.scenario.target, method, path_template, header_templates, body_template, body_override, connect_timeout_ms, timeout_ms, delay_before_ms, capture_body_max_bytes, ); } return switch (scenario.scenario.protocol) { .http => http_executor.executeRequest( allocator, client, store, tls_context, cookie_jar, scenario.scenario.target, method, path_template, header_templates, body_template, body_override, connect_timeout_ms, timeout_ms, delay_before_ms, capture_body_max_bytes, ), .grpc => grpc_client.executeRequest( allocator, store, tls_context, scenario.scenario.target, path_template, header_templates, body_template, body_override, connect_timeout_ms, timeout_ms, delay_before_ms, capture_body_max_bytes, ), }; }