Skip to content

Commit

Permalink
[BUGFIX] Debug output if response body is read once stream
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
Kanti authored May 7, 2024
1 parent a8e87ca commit f1f3aa8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Classes/IndexQueue/PageIndexerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
]
);

Expand Down

0 comments on commit f1f3aa8

Please sign in to comment.