php-sdk icon indicating copy to clipboard operation
php-sdk copied to clipboard

Ability to add custom HTTP clients

Open orlandothoeny opened this issue 3 years ago • 6 comments

I need to be able to log HTTP Requests & the corresponding response. This is currently not possible. Only the response is available to callers. The request is hidden.

The approach I wanted to implement:

  1. Extend the CurlHttpClient and override the send() method, basically just wrapping it. Recording the HttpRequest argument and the response of parent::send()
  2. Extend the HttpClientFactory and add my own client in the constructor
  3. Call ApiClient::setHttpClientType('my-custom-client')

This is currently not possible. Since both CurlHttpClient & HttpClientFactory are final classes. I either have to copy-paste the whole library to my own codebase. Or create a patch that applies my changes using something like https://github.com/cweagans/composer-patches. Both are not great.

orlandothoeny avatar Oct 27 '22 10:10 orlandothoeny