Table of Contents

Class HttpDevice

Namespace
adas_core.module.ProxyDevices.Devices
Assembly
adas-core.module.ProxyDevices.dll

Device that can be used to get content via http with digest auth

public class HttpDevice : IProxyDevice
Inheritance
HttpDevice
Implements
Inherited Members
Extension Methods

Methods

Initialize(Dictionary<string, object?>)

Initializes the device with the provided parameters. The parameters are expected to be in a dictionary format, where the key is a string representing the parameter name and the value is an object that can be cast to the appropriate type. The method checks for the presence of required parameters (like "url") and validates them, throwing exceptions if any issues are found. Optional parameters (like "name", "username", "password", and "domain") are also processed if they are present in the dictionary.

public void Initialize(Dictionary<string, object?> deviceParameters)

Parameters

deviceParameters Dictionary<string, object>

A dictionary containing the parameters required to initialize the device.

Exceptions

InvalidOperationException

Thrown when the device is already initialized.

ArgumentNullException

Thrown when a required parameter is missing or invalid.

Process()

Processes a request by sending an HTTP GET request to the specified URI using the HttpClient. If authentication parameters were provided during initialization, they will be used for the request. The method handles potential timeouts by catching TaskCanceledException and rethrowing it as a TimeoutException with a descriptive message. The response from the HTTP request is returned as an HttpResponseMessage.

public Task<HttpResponseMessage> Process()

Returns

Task<HttpResponseMessage>

An HttpResponseMessage representing the response from the HTTP request.

Exceptions

TimeoutException

Thrown when the request times out.

Stream()

Streams content from the specified URI using an HTTP GET request with the option to read response headers immediately. This method is similar to Process(), but it allows for streaming the response content as it is received, which can be useful for large responses or when you want to start processing the data before the entire response is available. Like Process(), it handles potential timeouts by catching TaskCanceledException and rethrowing it as a TimeoutException with a descriptive message.

public Task<HttpResponseMessage> Stream()

Returns

Task<HttpResponseMessage>

An HttpResponseMessage representing the response from the HTTP request.

Exceptions

TimeoutException

Thrown when the request times out.

ToString()

Returns a string representation of the HttpDevice instance, including its name, URI, username, password, and domain. This can be useful for logging or debugging purposes to quickly identify the configuration of the device.

public override string ToString()

Returns

string

A string representation of the HttpDevice instance.