I'm processing a large API response that comes as GuzzleHttp\Psr7\Response
. While debugging and profiling my script, I'd like to eliminate the varying network and API server response times.
My idea was to simply save a copy of the JSON that the server responds with into a text file, and keep reading it from the local filesystem until I'm done. Since I can't neither inject the JSON into the curl handler, nor serialize()
it, I'd have to save the whole GuzzleHttp\Psr7\Response
. But it contains some streams, which it later tries to read and fails.
I have tried serializing and immediately unserializing just to see if it works (it doesn't):
src/Handler/CurlFactory.php:106
if (!$easy->response || $easy->errno) { return self::finishError($handler, $easy, $factory); } $temporaryCopy = serialize($easy->response); $easy->response = unserialize($temporaryCopy);
src/Handler/CurlHandler.php:40
curl_exec($easy->handle); $temporaryCopy = serialize($easy->handle); $easy->handle = unserialize($temporaryCopy);
The above doesn't work. Before I continue fighting the framework, is there an out-of-the box way to get it done?