DefaultHttpClientService
Wisej.AI.Services.DefaultHttpClientService
Last updated
Wisej.AI.Services.DefaultHttpClientService
Last updated
Namespace: Wisej.AI.Services
Assembly: Wisej.AI (3.5.0.0)
Represents a default HTTP client service that provides methods to send HTTP requests and manage default headers.
Initializes a new instance of .
: Gets the instance of used by this service.
This property initializes the if it is not already initialized. A default User-Agent header is added to the client upon initialization. This property is thread-safe and locks on the instance to ensure that the is initialized only once.
: Gets or sets the timeout in milliseconds.
Sends a GET request to the specified URI.
uri
The URI to which the GET request is sent.
This method sends a GET request to the specified uri . The method is asynchronous and returns a task that completes when the HTTP response is received.
Throws:
Sends a POST request to the specified URI with the specified content.
uri
The URI to which the POST request is sent.
content
The HTTP content to be sent with the request.
This method sends a POST request to the specified uri with the provided content . The method is asynchronous and returns a task that completes when the HTTP response is received.
Throws:
key
The key of the header to be removed.
This method removes a header from the HTTP client's request headers based on the specified key . If the header does not exist, this method does nothing.
Sends an HTTP request to the specified URI.
request
The HTTP request message to send.
This method sends an HTTP request using the provided request . The method is asynchronous and returns a task that completes when the HTTP response is received.
Throws:
key
The key of the header to be added.
value
The value of the header to be added.
This method adds a default header to the HTTP client's request headers. If a header with the same key already exists, this method adds another entry to the headers collection.
handler
Represents a service for handling HTTP client operations with customizable handlers and headers.
Returns: . A task that represents the asynchronous operation. The task result contains the HTTP response message.
Thrown if uri is null.
Returns: . A task that represents the asynchronous operation. The task result contains the HTTP response message.
Thrown if uri or content is null.
Removes a default header from the .
Returns: . A task that represents the asynchronous operation. The task result contains the HTTP response message.
Thrown if request is null.
Adds a default header to the .
Sets a new HTTP handler for the .
The to be used by the .
This method replaces the current with a new instance using the specified handler . A default User-Agent header is also added to the new instance.