Improve this Doc View Source

Class HttpRequestMessageExtensions

Extensions for the HttpRequestMessage class

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

Methods

| Improve this Doc View Source

AddRequestHeader(HttpRequestMessage, String, String)

Add default request header without validation

Declaration
public static HttpRequestMessage AddRequestHeader(HttpRequestMessage httpRequestMessage, string name, string value)
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.String name

Header name

System.String value

Header value

Returns
Type Description
System.Net.Http.HttpRequestMessage

HttpRequestMessage for fluent usage

| Improve this Doc View Source

SendAsync(HttpRequestMessage, HttpClient, CancellationToken)

Send the supplied HttpRequestMessage, ignoring the response 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 SendAsync(HttpRequestMessage httpRequestMessage, HttpClient httpClient, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.Net.Http.HttpClient httpClient

HttpClient

System.Threading.CancellationToken cancellationToken

CancellationToken

Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

SendAsync<TResponse>(HttpRequestMessage, HttpClient, CancellationToken)

Send the supplied HttpRequestMessage, and get a response back 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<TResponse> SendAsync<TResponse>(HttpRequestMessage httpRequestMessage, HttpClient httpClient, CancellationToken cancellationToken = null)where TResponse : class
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.Net.Http.HttpClient httpClient

HttpClient

System.Threading.CancellationToken cancellationToken

CancellationToken

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

the deserialized object of type T or default(T)

| Improve this Doc View Source

SendAsync<TResponse>(HttpRequestMessage, CancellationToken)

Send the supplied HttpRequestMessage, and get a response back 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<TResponse> SendAsync<TResponse>(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken = null)where TResponse : class
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.Threading.CancellationToken cancellationToken

CancellationToken

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

the deserialized object of type T or default(T)

| Improve this Doc View Source

SetAuthorization(HttpRequestMessage, String, String)

Simplest way to set the authorization header

Declaration
public static HttpRequestMessage SetAuthorization(HttpRequestMessage httpRequestMessage, string scheme, string parameter)
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.String scheme

The authorization scheme, e.g. Bearer or Basic

System.String parameter

the value to the scheme

Returns
Type Description
System.Net.Http.HttpRequestMessage

HttpRequestMessage for fluent usage

| Improve this Doc View Source

SetBasicAuthorization(HttpRequestMessage, String, String)

Set Basic Authentication for the HttpRequestMessage

Declaration
public static HttpRequestMessage SetBasicAuthorization(HttpRequestMessage httpRequestMessage, string user, string password)
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.String user

username

System.String password

password

Returns
Type Description
System.Net.Http.HttpRequestMessage

HttpRequestMessage for fluent usage

| Improve this Doc View Source

SetBasicAuthorization(HttpRequestMessage, Uri)

Use the UserInfo from the Uri to set the basic authorization information

Declaration
public static HttpRequestMessage SetBasicAuthorization(HttpRequestMessage httpRequestMessage, Uri uri)
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.Uri uri

Uri with UserInfo

Returns
Type Description
System.Net.Http.HttpRequestMessage

HttpRequestMessage for fluent usage

| Improve this Doc View Source

SetBearer(HttpRequestMessage, String)

Set Bearer "Authentication" for the HttpRequestMessage

Declaration
public static HttpRequestMessage SetBearer(HttpRequestMessage httpRequestMessage, string bearer)
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage httpRequestMessage

HttpRequestMessage

System.String bearer

Bearer for the authorization

Returns
Type Description
System.Net.Http.HttpRequestMessage

HttpRequestMessage for fluent usage