Using dontTruncateRequestExceptions()
results in an empty response body
#54207
Labels
dontTruncateRequestExceptions()
results in an empty response body
#54207
Laravel Version
11.37.0
PHP Version
8.3.15
Database Driver & Version
n/a
Description
By default,
truncateRequestExceptionsAt()
is used, which causesRequestException
to callMessage::bodySummary()
. This checks if the bodyisSeekable()
, and then usesrewind()
on the body after extracting the summary. The result is that, after catching the exception,$e->response->getBody()->getContents()
will return the the contents of the body.However, when
dontTruncateRequestExceptions()
is used,RequestException
callsMessage::toString()
instead. This instead castsgetBody()
to a string to get the full contents of the body. The result is that, after catching the exception,$e->response->getBody()->getContents()
will return an empty string.Now I'm not sure if this is something that should be fixed upstream in Guzzle, or left as-is and documented somewhere, but I think it makes sense to report it here first.
Steps To Reproduce
The text was updated successfully, but these errors were encountered: