]> git.mxchange.org Git - friendica-addons.git/blobdiff - s3_storage/vendor/akeeba/s3/src/Response.php
[s3_storage] Bump version of akeeba/s3 to version 2.3.1
[friendica-addons.git] / s3_storage / vendor / akeeba / s3 / src / Response.php
index a8078b29389c3308acb99dbf6600c22a77027713..01810941f34b868571076173a5e7806b627818c7 100644 (file)
@@ -3,18 +3,18 @@
  * Akeeba Engine
  *
  * @package   akeebaengine
- * @copyright Copyright (c)2006-2020 Nicholas K. Dionysopoulos / Akeeba Ltd
+ * @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
  * @license   GNU General Public License version 3, or later
  */
 
-namespace Akeeba\Engine\Postproc\Connector\S3v4;
+namespace Akeeba\S3;
 
-use Akeeba\Engine\Postproc\Connector\S3v4\Exception\PropertyNotFound;
-use Akeeba\Engine\Postproc\Connector\S3v4\Response\Error;
+use Akeeba\S3\Exception\PropertyNotFound;
+use Akeeba\S3\Response\Error;
 use SimpleXMLElement;
 
 // Protection against direct access
-defined('AKEEBAENGINE') or die();
+defined('AKEEBAENGINE') || die();
 
 /**
  * Amazon S3 API response object
@@ -124,7 +124,7 @@ class Response
         *
         * @param   string|SimpleXMLElement|null  $body
         */
-       public function setBody($body): void
+       public function setBody($body, bool $rawResponse = false): void
        {
                $this->body = null;
 
@@ -135,7 +135,7 @@ class Response
 
                $this->body = $body;
 
-               $this->finaliseBody();
+               $this->finaliseBody($rawResponse);
        }
 
        public function resetBody(): void
@@ -153,7 +153,7 @@ class Response
                $this->body .= $data;
        }
 
-       public function finaliseBody(): void
+       public function finaliseBody(bool $rawResponse = false): void
        {
                if (!$this->hasBody())
                {
@@ -165,8 +165,14 @@ class Response
                        $this->headers['type'] = 'text/plain';
                }
 
-               if (is_string($this->body) &&
-                       (($this->headers['type'] == 'application/xml') || (substr($this->body, 0, 5) == '<?xml'))
+               if (
+                       !$rawResponse
+                       && is_string($this->body)
+                       &&
+                       (
+                               ($this->headers['type'] == 'application/xml')
+                               || (substr($this->body, 0, 5) == '<?xml')
+                       )
                )
                {
                        $this->body = simplexml_load_string($this->body);
@@ -332,8 +338,8 @@ class Response
                )
                {
                        $this->error = new Error(
-                               $this->code,
-                               (string) $this->body->Message
+                               500,
+                               (string) $this->body->Code . ':' . (string) $this->body->Message
                        );
 
                        if (isset($this->body->Resource))