I have this code for creating a Guzzle client with logging:
$loggerMiddleware = new Logger(function ($level, $message, array $context) { ... }
$handler = new CurlMultiHandler();
$stack = HandlerStack::create($handler);
$stack->push($loggerMiddleware);
$client = new Client(['handler' => $stack]);
Now, when I use the other kind of handler, $handler = new CurlHandler();
, the Logger function gives me a fully details $context
array which has details about the request and repsonse.
The problem is, when I switch to $handler = new CurlMultiHandler();
, the $context
array no longer has a usable Response, $context['response']
is just meaningless when it's the MultiHandler.
How do I write a logger function where I can get the response back for CurlMultiHandler?
Edit: When I'm in this Logger callback with the useless $context['response']
, I notice that I can check $context['reason']
and I see this message:
cURL error 61: Unrecognized content encoding type. libcurl understands deflate, gzip content encodings. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://courierservices.saasc.uk/api/couriers/v1/Test/create-label