From f6f7d71fe66dcb2429fb4012b064a054141e9659 Mon Sep 17 00:00:00 2001 From: Indrek Date: Tue, 31 Dec 2024 09:29:29 +0200 Subject: [PATCH] fix: attempt to only remember received content when the header is in correct status --- Storage/src/Connection/Rest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Storage/src/Connection/Rest.php b/Storage/src/Connection/Rest.php index 2f89fe309a2c..b6eb3dbeec8c 100644 --- a/Storage/src/Connection/Rest.php +++ b/Storage/src/Connection/Rest.php @@ -316,7 +316,12 @@ public function downloadObject(array $args = []) &$attempt, ) { // if the exception has a response for us to use - if ($e instanceof RequestException && $e->hasResponse()) { + if ( + $e instanceof RequestException + && $e->hasResponse() + && $e->getResponse()->getStatusCode() >= 200 + && $e->getResponse()->getStatusCode() < 300 + ) { $msg = (string) $e->getResponse()->getBody(); $fetchedStream = Utils::streamFor($msg);