From 8df0e6664a22c59a8355bc150714492cb13e2d64 Mon Sep 17 00:00:00 2001 From: shin Date: Thu, 30 Sep 2021 13:55:43 +0700 Subject: [PATCH] - Fix Proxy --- Controller/Proxy/Index.php | 3 ++- Helper/EmailMarketing.php | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Controller/Proxy/Index.php b/Controller/Proxy/Index.php index 9387bc0..c890331 100644 --- a/Controller/Proxy/Index.php +++ b/Controller/Proxy/Index.php @@ -77,8 +77,9 @@ public function execute() } $response = $this->helperEmailMarketing->sendRequestProxy($url, $params); - if ($this->_request->getParam('type') === 'raw') { + if (isset($params['type'])) { $result = $this->resultRawFactory->create(); + $result->setHeader('content-type', $params['type']); $result->setContents($response); return $result; diff --git a/Helper/EmailMarketing.php b/Helper/EmailMarketing.php index e11ef93..ea60420 100755 --- a/Helper/EmailMarketing.php +++ b/Helper/EmailMarketing.php @@ -1688,6 +1688,8 @@ public function isTracking($storeId = null) */ public function sendRequestProxy($url, $data) { + $params = $this->_request->getParams(); + $this->initCurl(); if ($this->_request->getMethod() === 'POST') { @@ -1697,9 +1699,9 @@ public function sendRequestProxy($url, $data) $this->_curl->get($url); } - $body = $this->_curl->getBody(); - $bodyData = self::jsonDecode($body); - if ($this->_request->getParam('type') === 'raw') { + $body = $this->_curl->getBody(); + $bodyData = self::jsonDecode($body); + if (isset($params['type'])) { $bodyData = $body; }