Table of Contents

Class HttpResponseMessage<T>

Namespace
MADE.Networking.Http.Responses
Assembly
MADE.Networking.dll

Defines a HTTP response message that includes a deserializing option for the response data.

public class HttpResponseMessage<T> : IDisposable

Type Parameters

T

The type of response expected.

Inheritance
HttpResponseMessage<T>
Implements
Inherited Members
Extension Methods

Constructors

HttpResponseMessage(HttpResponseMessage)

Initializes a new instance of the HttpResponseMessage<T> class with the original HttpResponseMessage.

public HttpResponseMessage(HttpResponseMessage response)

Parameters

response HttpResponseMessage

The original HttpResponseMessage.

Properties

Content

Gets the content of the HTTP response message.

public HttpContent Content { get; }

Property Value

HttpContent

DeserializedContent

Gets the deserialized content of the original HttpResponseMessage as the specified T type.

Note, ensure that DeserializeAsync(CancellationToken) has been called first, otherwise this value will be default.

public T? DeserializedContent { get; }

Property Value

T

Headers

Gets the collection of HTTP response headers.

public HttpResponseHeaders Headers { get; }

Property Value

HttpResponseHeaders

IsSuccessStatusCode

Gets a value indicating whether the HTTP response was successful.

public bool IsSuccessStatusCode { get; }

Property Value

bool

ReasonPhrase

Gets the reason phrase that typically is sent by servers together with the status code.

public string? ReasonPhrase { get; }

Property Value

string

RequestMessage

Gets the request message which led to this response message.

public HttpRequestMessage? RequestMessage { get; }

Property Value

HttpRequestMessage

StatusCode

Gets the status code of the HTTP response.

public HttpStatusCode StatusCode { get; }

Property Value

HttpStatusCode

Version

Gets the HTTP message version.

public Version Version { get; }

Property Value

Version

Methods

DeserializeAsync(CancellationToken)

Deserializes the content of the HttpResponseMessage into the DeserializedContent value.

public Task<T> DeserializeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<T>

A Task representing the result of the asynchronous operation.

Dispose()

Releases the unmanaged resources and disposes of unmanaged resources used by the HttpResponseMessage<T>.

public void Dispose()

Dispose(bool)

Releases the unmanaged resources used by the HttpResponseMessage<T> and optionally disposes of the managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

A value indicating whether to release both managed and unmanaged resources.

EnsureSuccessStatusCode()

Throws an exception if the IsSuccessStatusCode property for the HTTP response is false.

public HttpResponseMessage<T> EnsureSuccessStatusCode()

Returns

HttpResponseMessage<T>

The HTTP response message if the call is successful.

Operators

implicit operator HttpResponseMessage<T>(HttpResponseMessage)

Allows conversion of a HttpResponseMessage to the HttpResponseMessage<T> without direct casting.

public static implicit operator HttpResponseMessage<T>(HttpResponseMessage response)

Parameters

response HttpResponseMessage

The HttpResponseMessage.

Returns

HttpResponseMessage<T>

The HttpResponseMessage<T>.