Class ZCL_LLM_HTTP_CLIENT_WRAPPER
AI Generated documentation.
Overview
The zcl_llm_http_client_wrapper
is a private constructor HTTP client wrapper class that provides a robust and flexible interface for making HTTP communications. It implements the zif_llm_http_client_wrapper
interface and offers methods for creating, configuring, and managing HTTP client interactions. The class is designed to handle HTTP communication with external providers, with built-in error handling and logging capabilities.
Key public methods include:
get_client()
: Creates a new HTTP client instanceset_header()
: Sets custom HTTP headersset_url()
: Configures the target URLcommunicate()
: Sends HTTP requests and processes responsesclose_client()
: Closes the HTTP client connection
Dependencies
if_http_client
: SAP standard HTTP client interfacezif_llm_call_logger
: Custom logging interfacezcx_llm_validation
: Custom validation exception classzcx_llm_http_error
: Custom HTTP communication error class
Details
The class follows a comprehensive HTTP communication workflow:
graph TD
A[Constructor] --> B{Validate RFC Destination}
B -->|Valid| C[Initialize HTTP Client]
B -->|Invalid| D[Raise Validation Exception]
C --> E[Prepare Request]
E --> F[Set Headers]
F --> G[Send Request]
G --> H[Receive Response]
H --> I[Log Communication]
I --> J[Handle Response/Errors]
Key implementation details:
- Supports dynamic configuration through
client_config
andprovider_config
- Automatically sets default headers like 'Content-Type'
- Implements comprehensive error handling for various HTTP communication scenarios
- Integrates with a call logger to record communication details
- Handles response status code validation
- Automatically resets request to prevent header/path prefix contamination between calls
The class is designed with flexibility and robustness in mind, providing a clean abstraction layer over SAP's standard HTTP client functionality while adding enhanced error handling and logging capabilities.