Class LoggingHttpClient
java.lang.Object
dev.langchain4j.http.client.log.LoggingHttpClient
- All Implemented Interfaces:
HttpClient
-
Constructor Summary
ConstructorsConstructorDescriptionLoggingHttpClient(HttpClient delegateHttpClient, Boolean logRequests, Boolean logResponses) LoggingHttpClient(HttpClient delegateHttpClient, Boolean logRequests, Boolean logResponses, org.slf4j.Logger logger) -
Method Summary
Modifier and TypeMethodDescriptionexecute(HttpRequest request) Executes a given HTTP request synchronously and returns the response.voidexecute(HttpRequest request, ServerSentEventListener delegateListener) Executes a given HTTP request asynchronously with server-sent events (SSE) handling.voidexecute(HttpRequest request, ServerSentEventParser parser, ServerSentEventListener delegateListener) Executes a given HTTP request asynchronously with server-sent events (SSE) handling.
-
Constructor Details
-
LoggingHttpClient
-
LoggingHttpClient
public LoggingHttpClient(HttpClient delegateHttpClient, Boolean logRequests, Boolean logResponses, org.slf4j.Logger logger)
-
-
Method Details
-
execute
Description copied from interface:HttpClientExecutes a given HTTP request synchronously and returns the response. This method blocks until the entire response is received.- Specified by:
executein interfaceHttpClient- Parameters:
request- the HTTP request to be executed.- Returns:
- a
SuccessfulHttpResponsecontaining the response data for successful HTTP requests (2XX status codes) - Throws:
HttpException- if the server returns a client (4XX) or server (5XX) error response
-
execute
Description copied from interface:HttpClientExecutes a given HTTP request asynchronously with server-sent events (SSE) handling. This method returns immediately while processing continues on a separate thread. Events are processed through the providedServerSentEventListener.The execution flow is as follows:
- The request is initiated asynchronously
- Received SSE data is parsed using the
DefaultServerSentEventParser - Parsed events are delivered to the listener's appropriate methods
- If an error occurs,
ServerSentEventListener.onError(Throwable)is called
If any exception is thrown from the listener's methods, the stream processing will be terminated and no further events will be processed.
- Specified by:
executein interfaceHttpClient- Parameters:
request- the HTTP request to be executed.delegateListener- the listener to receive parsed events and error notifications.
-
execute
public void execute(HttpRequest request, ServerSentEventParser parser, ServerSentEventListener delegateListener) Description copied from interface:HttpClientExecutes a given HTTP request asynchronously with server-sent events (SSE) handling. This method returns immediately while processing continues on a separate thread. Events are processed through the providedServerSentEventListener.The execution flow is as follows:
- The request is initiated asynchronously
- Received SSE data is parsed using the provided parser
- Parsed events are delivered to the listener's appropriate methods
- If an error occurs,
ServerSentEventListener.onError(Throwable)is called
If any exception is thrown from the listener's methods, the stream processing will be terminated and no further events will be processed.
- Specified by:
executein interfaceHttpClient- Parameters:
request- the HTTP request to be executed.parser- the parser to process incoming server-sent events.delegateListener- the listener to receive parsed events and error notifications.
-