Table of Contents

Class HttpRequestMessageBuilder<TResponse>

Namespace
CSF.Screenplay.WebApis
Assembly
CSF.Screenplay.WebApis.dll

An object which can create an HttpRequestMessage for use with an HTTP client, which is expected to expose a response of a particular type.

public record HttpRequestMessageBuilder<TResponse> : HttpRequestMessageBuilder, IHasName, IFormattableValue, IEquatable<HttpRequestMessageBuilder>, IEquatable<HttpRequestMessageBuilder<TResponse>>

Type Parameters

TResponse

The type of the response expected from the endpoint to which this request would be sent.

Inheritance
HttpRequestMessageBuilder<TResponse>
Implements
Inherited Members

Remarks

Please note that this type differs in form depending upon the .NET version under which it is consumed. If consuming this type from logic which targets .NET Standard 2.0 or .NET Framework 4.6.2 then this type is a class. In that scenario its properties are mutable and the developer should take care to ensure that they do not mutate/alter its state inadvertently. Developers should ensure that they manually copy the state from the current instance into a new instance instead of modifying an existing instance. In these target frameworks, a Clone method has been provided to assist with this.

When consuming this from .NET 5 or higher, this type is instead a record and is immutable by design. All properties are init-only. Additionally, in .NET 5+, some additional properties are available, supporting features of HttpRequestMessage which are unavailable in lower .NET versions. When using .NET 5, developers may use nondestructive mutation with the with keyword/expression to create a copy of the current instance but with some differences.

This difference between this type and its non-generic counterpart is that this type includes generic information about the expected response type. This can aid subsequent type-safety in consuming logic.