- Issue created by @murz
- Merge request !149Issue #3531702: HTTP mock: Assets for the mocked responses are not stored when Guzzle has custom handlers which throw BadResponseException → (Merged) created by murz
When generating asset files to store the HTTP call responses, if the response returns an error status (4xx and 5xx HTTP error codes), Guzzle throws an exception and stops processing other options from the HTTP Client options, which leads to skipping executing the handler that stores the response to the files.
1. In the mode=store, make an outgoing HTTP call that returns an error, for example 401 error.
2. See that the assets file is not created.
Extend the first handler before the actual HTTP call to execute the next handler with a try-catch construction, and store the response on GuzzleHttp\Exception\BadResponseException.
Active
1.5
Code