From fffad8d165fccde54b664627345515696dae3ea0 Mon Sep 17 00:00:00 2001 From: Ronald Edelschaap Date: Fri, 11 Nov 2016 18:18:16 +0100 Subject: [PATCH 1/2] Update Curl.php Added support for PUT requests --- lib/internal/Magento/Framework/HTTP/Adapter/Curl.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php b/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php index 181783c7b211..2311da9e0e9a 100644 --- a/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php @@ -175,6 +175,9 @@ public function write($method, $url, $http_ver = '1.1', $headers = [], $body = ' if ($method == \Zend_Http_Client::POST) { curl_setopt($this->_getResource(), CURLOPT_POST, true); curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); + } elseif ($method == \Zend_Http_Client::PUT) { + curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, 'PUT'); + curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); } elseif ($method == \Zend_Http_Client::GET) { curl_setopt($this->_getResource(), CURLOPT_HTTPGET, true); } From 2b9a6b35bfe640024bd0ae5152b35914a98f4cb4 Mon Sep 17 00:00:00 2001 From: Ronald Edelschaap Date: Mon, 14 Nov 2016 11:53:58 +0100 Subject: [PATCH 2/2] Update Curl.php We noticed that `CURLOPT_CUSTOMREQUEST` has priority over regular options like `CURLOPT_HTTPGET` and `CURLOPT_POST`. When the `CURLOPT_CUSTOMREQUEST` option has been set to `PUT` for a PUT request, `CURLOPT_HTTPGET` and `CURLOPT_POST` do not overwrite the value of `CURLOPT_CUSTOMREQUEST` and thus `CURLOPT_CUSTOMREQUEST` has to be used again. --- lib/internal/Magento/Framework/HTTP/Adapter/Curl.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php b/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php index 2311da9e0e9a..3d11e62d96f8 100644 --- a/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Adapter/Curl.php @@ -174,12 +174,14 @@ public function write($method, $url, $http_ver = '1.1', $headers = [], $body = ' curl_setopt($this->_getResource(), CURLOPT_RETURNTRANSFER, true); if ($method == \Zend_Http_Client::POST) { curl_setopt($this->_getResource(), CURLOPT_POST, true); + curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); } elseif ($method == \Zend_Http_Client::PUT) { curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); } elseif ($method == \Zend_Http_Client::GET) { curl_setopt($this->_getResource(), CURLOPT_HTTPGET, true); + curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, 'GET'); } if (is_array($headers)) {