HTTP Protocol Guide

This guide explains how to think about realistic API transaction tests in LoadStrike. Use it when HTTP is part of the business workflow you want to validate.

What this page helps you do

What this page helps you do

Decide when plain HTTP steps are enough and when a tracked HTTP endpoint definition is the better fit.

Who this is for

Teams testing API-driven workflows where HTTP is the source, the destination, or both.

Prerequisites

  • An HTTP-based workflow to model
  • Clarity on whether the request itself or the downstream completion is the thing you care about

By the end

A clear protocol choice and an HTTP setup that matches the transaction you are trying to measure.

Choose this path when

Use this guide when HTTP belongs inside the transaction story and you need to decide between a normal step and a tracked endpoint definition.

Visual guide

Decision diagram showing plain HTTP steps, tracked HTTP endpoints, and browser flows.
Choose plain HTTP steps for direct request timing, tracked endpoints for correlated multi-system workflows, and browser flows when the path starts in the UI.

Guide

What the HTTP guide covers

This guide is about using ordinary HTTP client calls inside LoadStrike scenarios and steps, plus when to use the cross-platform HTTP endpoint definition for tracked workflows.

When plain step-based HTTP is enough

Use a normal HTTP client inside LoadStrikeStep when the important thing is the request latency, status code, and failure behavior of that one step.

When to switch to tracked HTTP endpoints

Use HttpEndpointDefinition when the HTTP call is the source or destination side of a correlated multi-system workflow and you want LoadStrike to manage tracking extraction and matching.

What to return from the step

Map successful HTTP outcomes to LoadStrikeResponse.Ok and failed outcomes to LoadStrikeResponse.Fail using the actual HTTP status code string. That keeps reports and sink exports readable for the team.

Protocol setup samples

Use these samples to compare plain HTTP steps with tracked endpoint definitions before you decide how HTTP belongs in the transaction.

If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.

HTTP Step

using LoadStrike;

var httpClient = new HttpClient
{
    BaseAddress = new Uri("https://api.example.com")
};

var scenario = LoadStrikeScenario.Create("read-order", async context =>
{
    var orderId = $"ord-{context.InvocationNumber}";

    var step = await LoadStrikeStep.Run<string>("GET /orders/{id}", context, async () =>
    {
        using var response = await httpClient.GetAsync($"/orders/{orderId}");

        return response.IsSuccessStatusCode
            ? LoadStrikeResponse.Ok<string>(statusCode: ((int)response.StatusCode).ToString())
            : LoadStrikeResponse.Fail<string>(
                statusCode: ((int)response.StatusCode).ToString(),
                message: "Order lookup failed");
    });

    return step.AsReply();
})
.WithLoadSimulations(
    LoadStrikeSimulation.Inject(10, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20))
);

LoadStrikeRunner.RegisterScenarios(scenario)
    .WithRunnerKey("rkl_your_local_runner_key")
    .Run();

HTTP protocol choices a beginner should make

Shared HTTP client inside a step

Use one shared HTTP client, session, or dispatcher for ordinary request-response testing when the step itself is the thing you want to measure. Avoid constructing a fresh transport object per request under load.

Status code mapping

Return the actual HTTP status code string in LoadStrikeResponse so reports show familiar values such as 200, 404, or 500.

Request body and headers

Build the same request shape the real client would send so latency and downstream behavior stay representative.

Transport cleanup

Dispose or close the shared HTTP transport when the run finishes so sockets, pools, and background resources are released cleanly.

HttpEndpointDefinition

Use the endpoint definition only when the HTTP call is part of a tracked cross-platform workflow.