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
TThe 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
responseHttpResponseMessageThe original HttpResponseMessage.
Properties
Content
Gets the content of the HTTP response message.
public HttpContent Content { get; }
Property Value
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
IsSuccessStatusCode
Gets a value indicating whether the HTTP response was successful.
public bool IsSuccessStatusCode { get; }
Property Value
ReasonPhrase
Gets the reason phrase that typically is sent by servers together with the status code.
public string? ReasonPhrase { get; }
Property Value
RequestMessage
Gets the request message which led to this response message.
public HttpRequestMessage? RequestMessage { get; }
Property Value
StatusCode
Gets the status code of the HTTP response.
public HttpStatusCode StatusCode { get; }
Property Value
Version
Gets the HTTP message version.
public Version Version { get; }
Property Value
Methods
DeserializeAsync(CancellationToken)
Deserializes the content of the HttpResponseMessage into the DeserializedContent value.
public Task<T> DeserializeAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
disposingboolA 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
responseHttpResponseMessageThe HttpResponseMessage.