From f1f3aa842c708de38c2ae3b4151d87ab520908cf Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Tue, 7 May 2024 16:10:46 +0200 Subject: [PATCH] [BUGFIX] Debug output if response body is read once stream # Problem: We had the problem that the requests where cached by staticfilecache. But we could not find any hint about that in the logs. Because the log would only show an empty body. That is because the body was already read in the lines above the log message. And it was a read once stream. (read more about read once streams: https://stackoverflow.com/a/6518288/5440709 ) # Solution: Our solution is to keep the body in a variable so if there is a Problem we can send the body to the log message. --- Classes/IndexQueue/PageIndexerRequest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Classes/IndexQueue/PageIndexerRequest.php b/Classes/IndexQueue/PageIndexerRequest.php index 672938ba97..13af4e0dbe 100644 --- a/Classes/IndexQueue/PageIndexerRequest.php +++ b/Classes/IndexQueue/PageIndexerRequest.php @@ -167,7 +167,8 @@ protected function getUrlAndDecodeResponse(string $url, PageIndexerResponse $res $headers = $this->getHeaders(); $rawResponse = $this->getUrl($url, $headers, $this->timeout); // convert JSON response to response object properties - $decodedResponse = $response->getResultsFromJson($rawResponse->getBody()->getContents()); + $responseString = $rawResponse->getBody()->getContents(); + $decodedResponse = $response->getResultsFromJson($responseString); if ($decodedResponse === null) { $this->logger->error( @@ -177,7 +178,7 @@ protected function getUrlAndDecodeResponse(string $url, PageIndexerResponse $res 'request url' => $url, 'request headers' => $headers, 'response headers' => $rawResponse->getHeaders(), - 'raw response body' => $rawResponse->getBody()->getContents(), + 'raw response body' => $responseString, ] );