Skip to content

Commit 6bf9fbf

Browse files
committed
document response serialize issue in the code
1 parent 605b7c2 commit 6bf9fbf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: src/CachePlugin.php

+4
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
193193
}
194194

195195
if ($this->isCacheable($response) && $this->isCacheableRequest($request)) {
196+
/* The PSR-7 response body is a stream. We can't expect that the response implements Serializable and handles the body.
197+
* Therefore we store the body separately and detach the stream to avoid attempting to serialize a resource.
198+
.* Our implementation still makes the assumption that the response object apart from the body can be serialized and deserialized.
199+
*/
196200
$bodyStream = $response->getBody();
197201
$body = $bodyStream->__toString();
198202
$bodyStream->detach();

0 commit comments

Comments
 (0)