arturobernalg opened a new pull request, #423: URL: https://github.com/apache/httpcomponents-client/pull/423
This PR adds a new class called `FaultTolerantResponseHandler` that extends `ContentResponseHandler`. It provides a custom response handler that reads the entity from the response body and transforms it into a `Content` object. This handler is designed to be fault-tolerant, meaning that it can handle responses with null or empty bodies without throwing exceptions. If the response was successful (a 2xx status code), the `Content` object is returned. If no response body exists, `Content.NO_CONTENT` is returned. This implementation extends `ContentResponseHandler` and overrides its methods to handle the response entity and transform it into the actual response object. This is designed to be efficient and use minimal memory. The `FaultTolerantResponseHandler` is intended to be used in scenarios where the response body may be null or empty, but the caller still needs to determine whether the response was successful or not. In addition, this PR also updates the `execute` and `returnContent` methods in the existing codebase to use the new `FaultTolerantResponseHandler`. Specifically, the `execute` method now takes an instance of `FaultTolerantResponseHandler` as an argument, and the `returnContent` method now calls the `handleResponse` method with an instance of `FaultTolerantResponseHandler`. This change will make the code more fault-tolerant and efficient in handling responses with null or empty bodies. This PR is backwards compatible with existing code, and all existing tests pass with these changes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
