6.59DelegatingHandler Use Cases

Updated on Aug 20, 2026~2 min read
  • Pre-request processing: Before the request is sent to the server, the request can be modified or enhanced, such as adding authentication information, setting specific request headers, and so on.
  • Post-response processing: After a response is received from the server but before the end user sees the result, the response can be processed, such as decompression, decryption, caching the response, and so on.
  • Error handling: Handle all exceptions that may occur in HTTP requests in a unified way, providing a consistent error handling mechanism.
  • Logging: Record request and response information for easier debugging and monitoring.

The framework's built-in ProfilerDelegatingHandler is a request analysis tool that implements its functionality by implementing the DelegatingHandler interface. You can click here to view the source code to gain a deeper understanding of its implementation details.