Class StubHttpRequestSnapshot

Namespace
XBullet.EasyTesting.Snapshots
Assembly
XBullet.EasyTesting.Snapshots.Http.dll

A stable representation of one captured outbound HTTP request.

public sealed record StubHttpRequestSnapshot : IEquatable<StubHttpRequestSnapshot>
Inheritance
StubHttpRequestSnapshot
Implements
Inherited Members

Constructors

StubHttpRequestSnapshot(string, string?, IReadOnlyDictionary<string, string[]>?, object?)

A stable representation of one captured outbound HTTP request.

public StubHttpRequestSnapshot(string Method, string? Url, IReadOnlyDictionary<string, string[]>? Headers, object? Body)

Parameters

Method string

The HTTP method text captured from the request.

Url string

The relative path, query, and fragment after configured scrubbing, or null when the request had no URI.

Headers IReadOnlyDictionary<string, string[]>

The sorted, copied header snapshot, or null when headers were excluded. Ignored headers are absent and redacted values are represented by {Redacted}.

Body object

A cloned JsonElement for valid JSON content, the original text for other non-empty content, or null when the body is absent, empty, or excluded.

Properties

Body

A cloned JsonElement for valid JSON content, the original text for other non-empty content, or null when the body is absent, empty, or excluded.

public object? Body { get; init; }

Property Value

object

Headers

The sorted, copied header snapshot, or null when headers were excluded. Ignored headers are absent and redacted values are represented by {Redacted}.

public IReadOnlyDictionary<string, string[]>? Headers { get; init; }

Property Value

IReadOnlyDictionary<string, string[]>

Method

The HTTP method text captured from the request.

public string Method { get; init; }

Property Value

string

Url

The relative path, query, and fragment after configured scrubbing, or null when the request had no URI.

public string? Url { get; init; }

Property Value

string

Methods

FromRequest(StubHttpRequest, StubHttpRequestSnapshotOptions?)

Creates a deterministic snapshot model from a captured request.

public static StubHttpRequestSnapshot FromRequest(StubHttpRequest request, StubHttpRequestSnapshotOptions? options = null)

Parameters

request StubHttpRequest

The non-null captured request to read. The method does not own, retain, or mutate it.

options StubHttpRequestSnapshotOptions

Inclusion, redaction, and scrubbing settings to read, or null to use a new default options instance. The method does not retain, own, or mutate supplied options; configured path scrubbers run synchronously before it returns.

Returns

StubHttpRequestSnapshot

A new stable request snapshot that owns its copied headers and normalized body value.