* 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
*
* @param string|SimpleXMLElement|null $body
*/
- public function setBody($body): void
+ public function setBody($body, bool $rawResponse = false): void
{
$this->body = null;
$this->body = $body;
- $this->finaliseBody();
+ $this->finaliseBody($rawResponse);
}
public function resetBody(): void
$this->body .= $data;
}
- public function finaliseBody(): void
+ public function finaliseBody(bool $rawResponse = false): void
{
if (!$this->hasBody())
{
$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);
)
{
$this->error = new Error(
- $this->code,
- (string) $this->body->Message
+ 500,
+ (string) $this->body->Code . ':' . (string) $this->body->Message
);
if (isset($this->body->Resource))