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
  • Properties
  • HttpClient
  • Timeout
  • Methods
  • GetAsync(uri)
  • PostAsync(uri, content)
  • RemoveDefaultHeader(key)
  • SendAsync(request)
  • SetDefaultHeader(key, value)
  • SetHandler(handler)
  • Implemented By
Export as PDF
  1. Components
  2. API
  3. Services

IHttpClientService

Wisej.AI.Services.IHttpClientService

PreviousQdrantEmbeddingStorageServiceNextDefaultHttpClientService

Last updated 5 days ago

Namespace: Wisej.AI.Services

Assembly: Wisej.AI (3.5.0.0)

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

public interface IHttpClientService
Public Interface IHttpClientService

The interface provides methods for sending HTTP requests and handling responses. It allows setting a custom , adding and removing default headers, and executing various HTTP methods like GET and POST. This interface is intended to be implemented by classes that encapsulate HTTP client logic, enabling easy configuration and request execution.

Properties

HttpClient

: Returns the underlying instance.

Timeout

: Gets or sets the timeout.

Methods

GetAsync(uri)

Sends an asynchronous GET request to the specified URI.

Parameter
Type
Description

uri

The URI to send the request to. This parameter is optional and defaults to an empty string if not provided.


  IHttpClientService clientService = new HttpClientService();
  HttpResponseMessage response = await clientService.GetAsync("https://api.example.com/resource");

Throws:

Sends an asynchronous POST request to the specified URI with the given content.

Parameter
Type
Description

uri

The URI to send the request to. This parameter is optional and defaults to an empty string if not provided.

content

The HTTP content to send with the request. This parameter is optional and defaults to null if not provided.


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

Throws:

Removes a default header from the requests.

Parameter
Type
Description

key

The name of the header to remove. This parameter is optional and defaults to an empty string if not provided.


  IHttpClientService clientService = new HttpClientService();
  clientService.RemoveDefaultHeader("Authorization");

Sends an asynchronous HTTP request to the specified URI.

Parameter
Type
Description

request

The HTTP request message to send.


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

Throws:

Adds a default header to be included in all requests.

Parameter
Type
Description

key

The name of the header to add. This parameter is optional and defaults to an empty string if not provided.

value

The value of the header to add. This parameter is optional and defaults to an empty string if not provided.


  IHttpClientService clientService = new HttpClientService();
  clientService.SetDefaultHeader("Authorization", "Bearer token");

Sets a custom HTTP client handler for the service.

Parameter
Type
Description

handler


  IHttpClientService clientService = new HttpClientService();
  HttpClientHandler handler = new HttpClientHandler
  {
    UseCookies = false
  };
  clientService.SetHandler(handler);

Implemented By

Name
Description

Represents a default HTTP client service that provides methods to send HTTP requests and manage default headers.

Returns: . A task representing the asynchronous operation, containing the HTTP response message.

The method sends an HTTP GET request to the specified URI and returns the response. This is typically used for retrieving data from a web service. Example usage:

Thrown when uri is null.

PostAsync(uri, content)

Returns: . A task representing the asynchronous operation, containing the HTTP response message.

The method sends an HTTP POST request with the specified content to the given URI. It is commonly used to submit data to a web service. Example usage:

Thrown when uri or content is null.

RemoveDefaultHeader(key)

The method removes a previously added header, preventing it from being included in future requests. It is useful for managing dynamic header requirements. Example usage:

SendAsync(request)

Returns: . A task representing the asynchronous operation, containing the HTTP response message.

The method allows sending an HTTP request with custom configurations and headers. It provides flexibility for executing different HTTP methods like PUT, DELETE, etc. Example usage:

Thrown when request is null.

SetDefaultHeader(key, value)

The method allows adding a header that will be included in every HTTP request sent by the client service. This is useful for setting common headers like Authorization tokens or Content-Type. Example usage:

SetHandler(handler)

The to use for requests. This parameter is optional and defaults to null if not provided.

The method allows you to set a custom handler for the HTTP client, which can be used to configure specific behaviors like proxy settings, cookies, or custom authentication mechanisms. Example usage:

Task<HttpResponseMessage>
ArgumentNullException
Task<HttpResponseMessage>
ArgumentNullException
Task<HttpResponseMessage>
ArgumentNullException
GetAsync
PostAsync
RemoveDefaultHeader
SendAsync
SetDefaultHeader
SetHandler
String
String
HttpContent
String
HttpRequestMessage
String
String
HttpClientHandler
HttpClientHandler
DefaultHttpClientService
IHttpClientService
HttpClientHandler
HttpClient
TimeSpan
HttpClient