LogoLogo
HomeNewsSupportVideos
  • Welcome
  • Wisej.NET
  • Concepts
    • Getting Started
    • General Concepts
    • Architecture
    • Extensibility
    • AI Providers
    • Vector Databases
    • Usage Metrics
    • Logging & Error Handling
  • Markup
  • Components
    • API
      • SmartAdapter
        • SmartAudioTTSAdapter
        • SmartAudioWhisperAdapter
        • SmartCalendarAdapter
        • SmartChartAdapter
        • SmartChartJS3Adapter
        • SmartChatBoxAdapter
        • SmartComboBoxAdapter
        • SmartCopilotAdapter
        • SmartDataEntryAdapter
        • SmartDocumentAdapter
        • SmartFullCalendarAdapter
        • SmartObjectAdapter
        • SmartPictureBoxAdapter
        • SmartQueryAdapter
        • SmartRealtimeAdapter
        • SmartReportAdapter
        • SmartTextBoxAdapter
        • SmartAdapter.ExtendsAttribute
        • SmartAdapter.FieldNameAttribute
        • SmartAdapter.FieldPromptAttribute
        • SmartAdapter.FieldRectangleAttribute
        • SmartAdapter.WorksWithAttribute
      • SmartEndpoint
        • AmazonBedrockEndpoint
        • AnthropicEndpoint
        • AzureAIEndpoint
        • CerebrasEndpoint
        • DeepSeekEndpoint
        • GoogleAIEndpoint
        • GroqCloudEndpoint
        • GroqCloudEndpointWhisper
        • HuggingFaceEndpoint
        • HuggingFaceJavaScriptEndpoint
        • LocalAIEndpoint
        • LocalAIEndpointImageGen
        • LocalAIEndpointTTS
        • LocalAIEndpointWhisper
        • NvidiaAIEndpoint
        • OllamaEndpoint
        • OpenAIEndpoint
        • OpenAIEndpointDallE
        • OpenAIEndpointRealtime
        • OpenAIEndpointTTS
        • OpenAIEndpointWhisper
        • SambaNovaEndpoint
        • SmartHttpEndpoint
        • TogetherAIEndpoint
        • XAIEndpoint
        • SmartEndpoint.Metrics
        • SmartEndpoint.Response
      • SmartExtensions
      • SmartHub
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartObject
      • SmartPrompt
        • SmartAgentPrompt
        • SmartParallelPrompt
        • SmartPrompt.Parameter
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartRealtimeSession
      • SmartSession
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.Message
        • SmartSession.MessageCollection
        • SmartSession.MessageRole
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
        • SmartSession.TrimmingStrategy
      • SmartTool
        • SmartTool.IToolProvider
        • SmartTool.ToolAttribute
        • SmartTool.ToolContext
      • Markup
        • MarkupExtensions
      • Controls
        • UVLightOverlay
      • Embeddings
        • EmbeddedDocument
        • Embedding
        • Matches
        • Metadata
      • Helpers
        • ApiKeys
        • Markdown
        • TextTokenizer
      • Services
        • DefaultSessionTrimmingService
        • IDocumentConversionService
          • DefaultDocumentConversionService
        • IEmbeddingGenerationService
          • DefaultEmbeddingGenerationService
          • HuggingFaceEmbeddingGenerationService
        • IEmbeddingStorageService
          • AzureAISearchEmbeddingStorageService
          • ChromaEmbeddingStorageService
          • FileSystemEmbeddingStorageService
          • MemoryEmbeddingStorageService
          • PineconeEmbeddingStorageService
          • QdrantEmbeddingStorageService
        • IHttpClientService
          • DefaultHttpClientService
        • ILoggerService
          • DefaultLoggerService
        • IOCRService
          • DefaultOCRService
        • IRerankingService
          • DefaultRerankingService
          • LocalAIRerankingService
          • PineconeRerankingService
        • ISessionTrimmingService
          • DefaultSessionTrimmingService
        • ITextSplitterService
          • RecursiveCharacterTextSplitterService
          • TextSplitterServiceBase
        • ITokenizerService
          • DefaultTokenizerService
        • IWebSearchService
          • BingWebSearchService
          • BraveWebSearchService
          • GoogleWebSearchService
      • Tools
        • ArxivTools
        • ChartJS3Tools
        • DatabaseTools
        • DataTableFilterTools
        • DocumentSearchTools
        • DocumentTools
        • FullCalendarTools
        • IToolsContainer
        • MathTools
        • ToolsContainer
        • UtilityTools
        • WebSearchTools
    • Built-in Services
      • IOCRService
      • ILoggerService
      • ITextSplitterService
      • ITokenizerService
      • IHttpClientService
      • IWebSearchService
      • IRerankingService
      • ISessionTrimmingService
      • IDocumentConversionService
      • IEmbeddingStorageService
      • IEmbeddingGenerationService
    • Built-in SmartTools
      • ToolsContainer
      • MathTools
      • UtilityTools
      • DatabaseTools
      • DocumentTools
      • DocumentSearchTools
      • WebSearchTools
      • ChartJS3Tools
      • FullCalendarTools
    • Built-in SmartAdapters
      • SmartAdapter
      • SmartAudioTTSAdapter
      • SmartAudioWhisperAdapter
      • SmartCalendarAdapter
      • SmartChartAdapter
      • SmartChartJS3Adapter
      • SmartChatBoxAdapter
      • SmartComboBoxAdapter
      • SmartCopilotAdapter
      • SmartDataEntryAdapter
      • SmartDocumentAdapter
      • SmartFullCalendarAdapter
      • SmartObjectAdapter
      • SmartPictureBoxAdapter
      • SmartQueryAdapter
      • SmartRealtimeAdapter
      • SmartReportAdapter
      • SmartTextBoxAdapter
    • Configure Services
    • Using SmartHub
    • Using SmartTools
    • Using SmartPrompt
    • Using SmartSession
    • Using SmartRealTimeAdapter
    • UVLightOverlay Control
Powered by GitBook
On this page
  • Constructors
  • DefaultHttpClientService()
  • Properties
  • HttpClient
  • Timeout
  • Methods
  • GetAsync(uri)
  • PostAsync(uri, content)
  • RemoveDefaultHeader(key)
  • SendAsync(request)
  • SetDefaultHeader(key, value)
  • SetHandler(handler)
  • Implements
Export as PDF
  1. Components
  2. API
  3. Services
  4. IHttpClientService

DefaultHttpClientService

Wisej.AI.Services.DefaultHttpClientService

PreviousIHttpClientServiceNextILoggerService

Last updated 5 days ago

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.

public class DefaultHttpClientService : IHttpClientService
Public Class DefaultHttpClientService
    Inherits IHttpClientService

Constructors

DefaultHttpClientService()

Initializes a new instance of .

Properties

HttpClient

: 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.

Timeout

: Gets or sets the timeout in milliseconds.

Methods

Sends a GET request to the specified URI.

Parameter
Type
Description

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.


var clientService = new DefaultHttpClientService();
var response = await clientService.GetAsync("https://api.example.com/resource");

Throws:

Sends a POST request to the specified URI with the specified content.

Parameter
Type
Description

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.


var clientService = new DefaultHttpClientService();
var content = new StringContent("{ \"name\": \"value\" }", Encoding.UTF8, "application/json");
var response = await clientService.PostAsync("https://api.example.com/resource", content);

Throws:

Parameter
Type
Description

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.


var clientService = new DefaultHttpClientService();
clientService.RemoveDefaultHeader("Authorization");

Sends an HTTP request to the specified URI.

Parameter
Type
Description

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.


var clientService = new DefaultHttpClientService();
var request = new HttpRequestMessage(HttpMethod.Put, "https://api.example.com/resource");
var response = await clientService.SendAsync(request);

Throws:

Parameter
Type
Description

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.


var clientService = new DefaultHttpClientService();
clientService.SetDefaultHeader("Authorization", "Bearer token");
Parameter
Type
Description

handler


var clientService = new DefaultHttpClientService();
var handler = new HttpClientHandler
{
// Configure handler properties
};
clientService.SetHandler(handler);

Implements

Name
Description

Represents a service for handling HTTP client operations with customizable handlers and headers.

GetAsync(uri)

Returns: . A task that represents the asynchronous operation. The task result contains the HTTP response message.

Thrown if uri is null.

PostAsync(uri, content)

Returns: . A task that represents the asynchronous operation. The task result contains the HTTP response message.

Thrown if uri or content is null.

RemoveDefaultHeader(key)

Removes a default header from the .

SendAsync(request)

Returns: . A task that represents the asynchronous operation. The task result contains the HTTP response message.

Thrown if request is null.

SetDefaultHeader(key, value)

Adds a default header to the .

SetHandler(handler)

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.

Task<HttpResponseMessage>
ArgumentNullException
Task<HttpResponseMessage>
ArgumentNullException
Task<HttpResponseMessage>
ArgumentNullException
HttpClient
HttpClient
HttpClient
HttpClient
String
String
HttpContent
String
HttpRequestMessage
String
String
HttpClientHandler
IHttpClientService
HttpClientHandler
HttpClient
DefaultHttpClientService
HttpClient
TimeSpan
HttpClient
HttpClient
HttpClient