From 280cb30c52e72304bf9507aefa04de1dc6bdd211 Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Thu, 28 Mar 2024 18:07:52 -0300 Subject: [PATCH] ORDS consts --- .../Connectors/Oracle/ORDS/Api/HandleInterface.php | 8 ++++++++ .../Connectors/Oracle/ORDS/Model/Handler/Curl.php | 8 ++++---- .../Databases/Connectors/Oracle/ORDS/Model/Query.php | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/system/database/Databases/Connectors/Oracle/ORDS/Api/HandleInterface.php b/system/database/Databases/Connectors/Oracle/ORDS/Api/HandleInterface.php index 8875cce..4cbd9ce 100644 --- a/system/database/Databases/Connectors/Oracle/ORDS/Api/HandleInterface.php +++ b/system/database/Databases/Connectors/Oracle/ORDS/Api/HandleInterface.php @@ -10,6 +10,14 @@ namespace Phacil\Framework\Databases\Connectors\Oracle\ORDS\Api; interface HandleInterface { + const HTTP_METHOD = 'POST'; + + const ENDPOINT_SUFFIX = '/_/sql'; + + const CONTENT_TYPE = 'application/sql'; + + const CURL_DEFAULT_TIMEOUT = 30; + public function __construct(\Phacil\Framework\Databases\Connectors\Oracle\ORDS\Connector $conector); public function setOption($option, $value); diff --git a/system/database/Databases/Connectors/Oracle/ORDS/Model/Handler/Curl.php b/system/database/Databases/Connectors/Oracle/ORDS/Model/Handler/Curl.php index 09a56aa..acad650 100644 --- a/system/database/Databases/Connectors/Oracle/ORDS/Model/Handler/Curl.php +++ b/system/database/Databases/Connectors/Oracle/ORDS/Model/Handler/Curl.php @@ -39,16 +39,16 @@ class Curl implements HandleInterface { $generatedAuth = base64_encode($this->conector->getUser().":".$this->conector->getPass()); $this->setOption(CURLOPT_PORT, $this->conector->getPort()); - $this->setOption(CURLOPT_URL, $this->conector->getHost()."/_/sql"); + $this->setOption(CURLOPT_URL, $this->conector->getHost().self::ENDPOINT_SUFFIX); $this->setOption(CURLOPT_RETURNTRANSFER, true); $this->setOption(CURLOPT_MAXREDIRS, 10); - $this->setOption(CURLOPT_TIMEOUT, 30); + $this->setOption(CURLOPT_TIMEOUT, self::CURL_DEFAULT_TIMEOUT); $this->setOption(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - $this->setOption(CURLOPT_CUSTOMREQUEST, 'POST'); + $this->setOption(CURLOPT_CUSTOMREQUEST, self::HTTP_METHOD); $this->setOption(CURLOPT_HTTPHEADER, [ "Accept: */*", sprintf("Authorization: Basic %s", $generatedAuth), - "Content-Type: application/sql" + sprintf("Content-Type: %s", self::CONTENT_TYPE) ]); } diff --git a/system/database/Databases/Connectors/Oracle/ORDS/Model/Query.php b/system/database/Databases/Connectors/Oracle/ORDS/Model/Query.php index 669853d..88926db 100644 --- a/system/database/Databases/Connectors/Oracle/ORDS/Model/Query.php +++ b/system/database/Databases/Connectors/Oracle/ORDS/Model/Query.php @@ -156,7 +156,6 @@ class Query implements QueryApi { unset($this->handle); } - //$this->handle = \Phacil\Framework\Registry::getInstance()->create(HandleInterface::class); } /** @inheritdoc */