Improve this Doc View Source

Class HttpResponseMessageExtensions

Extensions for the HttpResponseMessage class

Inheritance
System.Object
HttpResponseMessageExtensions
Namespace:Dapplo.HttpExtensions
Assembly:Dapplo.HttpExtensions.dll
Syntax
public class HttpResponseMessageExtensions

Methods

| Improve this Doc View Source

GetAsAsync<TResult>(HttpResponseMessage, CancellationToken)

Extension method reading the HttpResponseMessage to a Type object Currently we support Json objects which are annotated with the DataContract/DataMember attributes We might support other object, e.g MemoryStream, Bitmap etc soon

Declaration
public static Task<TResult> GetAsAsync<TResult>(HttpResponseMessage httpResponseMessage, CancellationToken token = null)where TResult : class
Parameters
Type Name Description
System.Net.Http.HttpResponseMessage httpResponseMessage

HttpResponseMessage

System.Threading.CancellationToken token

CancellationToken

Returns
Type Description
System.Threading.Tasks.Task<TResult>

the deserialized object of type T or default(T)

| Improve this Doc View Source

HandleErrorAsync(HttpResponseMessage, CancellationToken)

Simplified error handling, this makes sure the uri and response are logged

Declaration
public static Task<string> HandleErrorAsync(HttpResponseMessage httpResponseMessage, CancellationToken token = null)
Parameters
Type Name Description
System.Net.Http.HttpResponseMessage httpResponseMessage

HttpResponseMessage

System.Threading.CancellationToken token

CancellationToken

Returns
Type Description
System.Threading.Tasks.Task<System.String>

string with the error content if HttpBehaviour.ThrowErrorOnNonSuccess = false