Skip to content

Commit 2b9a6b3

Browse files
authored
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.
1 parent fffad8d commit 2b9a6b3

File tree

1 file changed

+2
-0
lines changed
  • lib/internal/Magento/Framework/HTTP/Adapter

1 file changed

+2
-0
lines changed

lib/internal/Magento/Framework/HTTP/Adapter/Curl.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ public function write($method, $url, $http_ver = '1.1', $headers = [], $body = '
174174
curl_setopt($this->_getResource(), CURLOPT_RETURNTRANSFER, true);
175175
if ($method == \Zend_Http_Client::POST) {
176176
curl_setopt($this->_getResource(), CURLOPT_POST, true);
177+
curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, 'POST');
177178
curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body);
178179
} elseif ($method == \Zend_Http_Client::PUT) {
179180
curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, 'PUT');
180181
curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body);
181182
} elseif ($method == \Zend_Http_Client::GET) {
182183
curl_setopt($this->_getResource(), CURLOPT_HTTPGET, true);
184+
curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, 'GET');
183185
}
184186

185187
if (is_array($headers)) {

0 commit comments

Comments
 (0)