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
RequestHttpExchangeRequestSnapshotCaptured request, or null when the response has no associated request.
ResponseHttpExchangeResponseSnapshotCaptured response, or null when a send failure prevented a response.
FailureHttpExchangeFailureSnapshotCaptured 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
Request
Captured request, or null when the response has no associated request.
public HttpExchangeRequestSnapshot? Request { get; init; }
Property Value
Response
Captured response, or null when a send failure prevented a response.
public HttpExchangeResponseSnapshot? Response { get; init; }
Property Value
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
responseHttpResponseMessageThe caller-owned, non-null response to capture. It and its request and content are read but not disposed or modified.
optionsHttpExchangeSnapshotOptionsOptional 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.
cancellationTokenCancellationTokenToken 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.