Show / Hide Table of Contents

Class HttpClientService

The request service implemantation

Inheritance
System.Object
HttpClientService
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Geko.HttpClientService
Assembly: Geko.HttpClientService.dll
Syntax
public class HttpClientService

Methods

| Improve this Doc View Source

GetTokenResponse()

Retrieves the TokenResponse from the IdentityServer

Declaration
public async Task<TokenResponse> GetTokenResponse()
Returns
Type Description
Task<IdentityModel.Client.TokenResponse>

A IdentityModel.Client.TokenResponse

| Improve this Doc View Source

HeadersAdd(Dictionary<String, List<String>>)

Adds the headers as the headers for the request.

Declaration
public HttpClientService HeadersAdd(Dictionary<string, List<string>> headers)
Parameters
Type Name Description
Dictionary<System.String, List<System.String>> headers

A with the key representing the name of the header, and the value representing the value of the header.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

HeadersAdd(Dictionary<String, String>)

Adds the headers as the headers for the request.

Declaration
public HttpClientService HeadersAdd(Dictionary<string, string> headers)
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

A where value is a with the key representing the name of the header, and the values representing the values of the header.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

HeadersAdd(String, List<String>)

Adds a header to the request. If a second header with the same name is added, then their values will be aggregated to one .

Declaration
public HttpClientService HeadersAdd(string name, List<string> value)
Parameters
Type Name Description
System.String name

The name of the header.

List<System.String> value

The list of values of the header.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

HeadersAdd(String, String)

Adds a header to the request. If a second header with the same name is added, then their values will be aggregated to one .

Declaration
public HttpClientService HeadersAdd(string name, string value)
Parameters
Type Name Description
System.String name

The name of the header.

System.String value

The value of the header.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

HeadersClear()

Clears all headers from the System.Net.Http.Headers.HttpHeaders collection.

Declaration
public HttpClientService HeadersClear()
Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

HeadersRemove(String)

Removes the name header from the System.Net.Http.Headers.HttpHeaders collection.

Declaration
public HttpClientService HeadersRemove(string name)
Parameters
Type Name Description
System.String name

The header to be removed

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

HeadersSet(Dictionary<String, List<String>>)

Clears all headers and sets new

Declaration
public HttpClientService HeadersSet(Dictionary<string, List<string>> headers)
Parameters
Type Name Description
Dictionary<System.String, List<System.String>> headers

A with the key representing the name of the header, and the value representing the value of the header.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

HeadersSet(Dictionary<String, String>)

Clears all headers and sets new

Declaration
public HttpClientService HeadersSet(Dictionary<string, string> headers)
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

A where value is a with the key representing the name of the header, and the values representing the values of the header.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

| Improve this Doc View Source

SendAsync<TRequestBody, TResponseBody>(Uri, HttpMethod, TRequestBody)

Creates and sends a request to the requestUri using the HTTP verb from httpMethod and the request body from requestBody. If IdentityServerOptions are set (using the SetIdentityServerOptions<TOptions>(TOptions) or one of the overloads), then a valid access token will be fetched by the IIdentityServerService and attached to this request.

Declaration
public async Task<ResponseObject<TResponseBody>> SendAsync<TRequestBody, TResponseBody>(Uri requestUri, HttpMethod httpMethod, TRequestBody requestBody)
Parameters
Type Name Description
Uri requestUri

The of the request.

HttpMethod httpMethod

The of the request.

TRequestBody requestBody

The body of the request (available only in POST, PUT and PATCH).

Returns
Type Description
Task<ResponseObject<TResponseBody>>

A ResponseObject<TResponseBody> containing the body of the response as String in the BodyAsString property, as TResponseBody in the BodyAsType and, as Stream in the BodyAsStream property. The TResponseBody can be of the following:

  • Use to define Encoding and/or ContentType for an HTTP content based on string.
  • Use to provide HTTP content based on a stream.
  • A serializable complex typeAny serializable object to attempt to deserialize the body of the response to it.
  • A simple typeAny other simple type to try convert the body of the response to it.
Type Parameters
Name Description
TRequestBody

The type of the request body. The type used can be one of the following:

  • Use to define Encoding and/or ContentType for an HTTP content based on string.
  • Use to provide HTTP content based on a stream.
  • A serializable complex typeAny serializable object that will be serialized and sent in the body of the request.
  • A simple typeAny other simple type that will be sent in the body of the request.
TResponseBody

The type of the property BodyAsType of the ResponseObject<TResponseBody> object, that will contain the body of the response deserialized or casted to type TResponseBody. The type used can be one of the following:

  • Use to define Encoding and/or ContentType for an HTTP content based on string.
  • Use to provide HTTP content based on a stream.
  • A serializable complex typeAny serializable object to attempt to deserialize the body of the response to it.
  • A simple typeAny other simple type to try convert the body of the response to it.
| Improve this Doc View Source

SetIdentityServerOptions<TOptions>(TOptions)

Sets the IdentityServer4 options by passing an object that inherits from Geko.HttpClientService.Models.ClientCredentialsOptions

Declaration
public HttpClientService SetIdentityServerOptions<TOptions>(TOptions options)
    where TOptions : class, IIdentityServerOptions
Parameters
Type Name Description
TOptions options

The IIdentityServerOptions that contains the options.

Returns
Type Description
HttpClientService
Type Parameters
Name Description
TOptions
| Improve this Doc View Source

SetIdentityServerOptions<TOptions>(Action<TOptions>)

Sets the IdentityServer4 options for retrieving an access token using client credentials by using a delegate.

Declaration
public HttpClientService SetIdentityServerOptions<TOptions>(Action<TOptions> optionsDelegate)
    where TOptions : class, IIdentityServerOptions
Parameters
Type Name Description
Action<TOptions> optionsDelegate

The delegate.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

Type Parameters
Name Description
TOptions
| Improve this Doc View Source

SetIdentityServerOptions<TOptions>(IOptions<TOptions>)

Sets the IdentityServer4 options for retrieving an access token using client credentials.

Declaration
public HttpClientService SetIdentityServerOptions<TOptions>(IOptions<TOptions> options)
    where TOptions : class, IIdentityServerOptions, new()
Parameters
Type Name Description
Microsoft.Extensions.Options.IOptions<TOptions> options

The token service options.

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

Type Parameters
Name Description
TOptions

The type of the options.

| Improve this Doc View Source

SetTimeout(TimeSpan)

Set the timeout of the current HttpClientService

Declaration
public HttpClientService SetTimeout(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The timeout

Returns
Type Description
HttpClientService

Returns the current instance of HttpClientService for method chaining.

Extension Methods

HttpClientServiceDeleteExtensions.DeleteAsync<TResponseBody>(HttpClientService, String)
HttpClientServiceDeleteExtensions.DeleteAsync(HttpClientService, String)
HttpClientServiceGetExtensions.GetAsync<TResponseBody>(HttpClientService, String)
HttpClientServiceGetExtensions.GetAsync(HttpClientService, String)
HttpClientServiceHeadExtensions.HeadAsync<TResponseBody>(HttpClientService, String)
HttpClientServiceHeadExtensions.HeadAsync(HttpClientService, String)
HttpClientServicePatchExtensions.PatchAsync<TRequestBody, TResponseBody>(HttpClientService, String, TRequestBody)
HttpClientServicePatchExtensions.PatchAsync(HttpClientService, String, String)
HttpClientServicePatchExtensions.PatchAsync<TResponseBody>(HttpClientService, String, String)
HttpClientServicePatchExtensions.PatchAsync<TResponseBody>(HttpClientService, String, StringContent)
HttpClientServicePatchExtensions.PatchAsync<TResponseBody>(HttpClientService, String, StreamContent)
HttpClientServicePostExtensions.PostAsync<TRequestBody, TResponseBody>(HttpClientService, String, TRequestBody)
HttpClientServicePostExtensions.PostAsync(HttpClientService, String, String)
HttpClientServicePostExtensions.PostAsync<TResponseBody>(HttpClientService, String, String)
HttpClientServicePostExtensions.PostAsync<TResponseBody>(HttpClientService, String, StringContent)
HttpClientServicePostExtensions.PostAsync<TResponseBody>(HttpClientService, String, StreamContent)
HttpClientServicePutExtensions.PutAsync<TRequestBody, TResponseBody>(HttpClientService, String, TRequestBody)
HttpClientServicePutExtensions.PutAsync(HttpClientService, String, String)
HttpClientServicePutExtensions.PutAsync<TResponseBody>(HttpClientService, String, String)
HttpClientServicePutExtensions.PutAsync<TResponseBody>(HttpClientService, String, StringContent)
HttpClientServicePutExtensions.PutAsync<TResponseBody>(HttpClientService, String, StreamContent)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX