Class HttpClientConfigurator
Inherited Members
Namespace: Algorand
Assembly: Algorand.dll
Syntax
public class HttpClientConfigurator
Methods
| Edit this page View SourceConfigureHttpClient(AlgodConfiguration, int, HttpMessageHandler)
Configures and returns an HttpClient instance for interacting with an Algod API.
Declaration
public static HttpClient ConfigureHttpClient(AlgodConfiguration algodConfiguration, int timeout = -1, HttpMessageHandler shim = null)
Parameters
| Type | Name | Description |
|---|---|---|
| AlgodConfiguration | algodConfiguration | The configuration object containing the host, API key, and optional headers for the Algod API. |
| int | timeout | The timeout duration, in milliseconds, for the HTTP client. A value of -1 indicates that the default timeout will be used. |
| HttpMessageHandler | shim | An optional HttpMessageHandler to use for customizing the HTTP client's behavior, such as for testing or adding custom processing logic. If null, the default handler is used. |
Returns
| Type | Description |
|---|---|
| HttpClient | A configured HttpClient instance ready to communicate with the Algod API. |
ConfigureHttpClient(string, string, string, int, HttpMessageHandler)
Configures and returns an HttpClient instance with the specified settings.
Declaration
public static HttpClient ConfigureHttpClient(string host, string token, string tokenHeader = "", int timeout = -1, HttpMessageHandler shim = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | host | The base address for the HTTP client. Must be an absolute URI. |
| string | token | The authentication token to include in the default request headers. |
| string | tokenHeader | The name of the header to use for the authentication token. If not specified, a default value is determined based on the host. |
| int | timeout | The timeout duration, in milliseconds, for HTTP requests. A value of -1 indicates no timeout (infinite). |
| HttpMessageHandler | shim | An optional HttpMessageHandler to use for the HttpClient. If not provided, a default handler is used. |
Returns
| Type | Description |
|---|---|
| HttpClient | A configured HttpClient instance with the specified base address, authentication token, and timeout. |
Remarks
If the tokenHeader is not provided, a default header name is
selected based on the host. Additionally, if the base address does not end with a trailing slash, one is
appended automatically.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |