Class HttpExchangeSnapshot

Namespace
XBullet.EasyTesting.Snapshots
Assembly
XBullet.EasyTesting.Snapshots.Core.dll

A stable representation of an HTTP request/response exchange.

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

Constructors

HttpExchangeSnapshot(HttpExchangeRequestSnapshot?, HttpExchangeResponseSnapshot?, HttpExchangeFailureSnapshot?)

A stable representation of an HTTP request/response exchange.

public HttpExchangeSnapshot(HttpExchangeRequestSnapshot? Request, HttpExchangeResponseSnapshot? Response, HttpExchangeFailureSnapshot? Failure)

Parameters

Request HttpExchangeRequestSnapshot

Captured request, or null when the response has no associated request.

Response HttpExchangeResponseSnapshot

Captured response, or null when a send failure prevented a response.

Failure HttpExchangeFailureSnapshot

Captured send failure, or null when the exchange produced a response.

Properties

Failure

Captured send failure, or null when the exchange produced a response.

public HttpExchangeFailureSnapshot? Failure { get; init; }

Property Value

HttpExchangeFailureSnapshot

Request

Captured request, or null when the response has no associated request.

public HttpExchangeRequestSnapshot? Request { get; init; }

Property Value

HttpExchangeRequestSnapshot

Response

Captured response, or null when a send failure prevented a response.

public HttpExchangeResponseSnapshot? Response { get; init; }

Property Value

HttpExchangeResponseSnapshot

Methods

FromResponseAsync(HttpResponseMessage, HttpExchangeSnapshotOptions?, CancellationToken)

Creates a deterministic exchange snapshot from an HTTP response.

public static Task<HttpExchangeSnapshot> FromResponseAsync(HttpResponseMessage response, HttpExchangeSnapshotOptions? options = null, CancellationToken cancellationToken = default)

Parameters

response HttpResponseMessage

The caller-owned, non-null response to capture. It and its request and content are read but not disposed or modified.

options HttpExchangeSnapshotOptions

Optional capture and redaction options. null uses options attached by an HttpExchangeRecorder when present, otherwise the effective global or default options. Different options are not accepted for a recorded response.

cancellationToken CancellationToken

Token that cancels direct response-content reading. The default token does not cancel the operation.

Returns

Task<HttpExchangeSnapshot>

A task whose result is a new deterministic snapshot, or the stable snapshot associated with a recorded response.