Class HttpClientService
The request service implemantation
Inheritance
Inherited Members
Namespace: Geko.HttpClientService
Assembly: Geko.HttpClientService.dll
Syntax
public class HttpClientService
Methods
| Improve this Doc View SourceGetTokenResponse()
Retrieves the TokenResponse from the IdentityServer
Declaration
public async Task<TokenResponse> GetTokenResponse()
Returns
Type | Description |
---|---|
Task<IdentityModel.Client.TokenResponse> | A IdentityModel.Client.TokenResponse |
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 |
Returns
Type | Description |
---|---|
HttpClientService | Returns the current instance of HttpClientService for method chaining. |
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 |
Returns
Type | Description |
---|---|
HttpClientService | Returns the current instance of HttpClientService for method chaining. |
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. |
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. |
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. |
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. |
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 |
Returns
Type | Description |
---|---|
HttpClientService | Returns the current instance of HttpClientService for method chaining. |
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 |
Returns
Type | Description |
---|---|
HttpClientService | Returns the current instance of HttpClientService for method chaining. |
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 |
HttpMethod | httpMethod | The |
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
|
Type Parameters
Name | Description |
---|---|
TRequestBody | The type of the request body. The type used can be one of the following:
|
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
|
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 |
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 |
Returns
Type | Description |
---|---|
HttpClientService | Returns the current instance of HttpClientService for method chaining. |
Type Parameters
Name | Description |
---|---|
TOptions |
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 |
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. |