Skip to content

Commit e45441d

Browse files
author
okorshenko
committed
MAGETWO-64313: [GitHub] [PR] Fix CURL Json POST #3489 #8373
- Merge Pull Request #8373 from mygento/magento2:develop
2 parents 53b0776 + 4b74924 commit e45441d

File tree

1 file changed

+6
-4
lines changed
  • lib/internal/Magento/Framework/HTTP/Client

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,14 @@ public function get($uri)
232232
*
233233
* @param string $uri
234234
* @param array $params
235+
* @param bool $json
235236
* @return void
236237
*
237238
* @see \Magento\Framework\HTTP\Client#post($uri, $params)
238239
*/
239-
public function post($uri, $params)
240+
public function post($uri, $params, $json = false)
240241
{
241-
$this->makeRequest("POST", $uri, $params);
242+
$this->makeRequest("POST", $uri, $params, $json = false);
242243
}
243244

244245
/**
@@ -338,17 +339,18 @@ public function getStatus()
338339
* @param string $method
339340
* @param string $uri
340341
* @param array $params
342+
* @param bool $json
341343
* @return void
342344
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
343345
* @SuppressWarnings(PHPMD.NPathComplexity)
344346
*/
345-
protected function makeRequest($method, $uri, $params = [])
347+
protected function makeRequest($method, $uri, $params = [], $json = false)
346348
{
347349
$this->_ch = curl_init();
348350
$this->curlOption(CURLOPT_URL, $uri);
349351
if ($method == 'POST') {
350352
$this->curlOption(CURLOPT_POST, 1);
351-
$this->curlOption(CURLOPT_POSTFIELDS, http_build_query($params));
353+
$this->curlOption(CURLOPT_POSTFIELDS, $json ? json_encode($params) : http_build_query($params));
352354
} elseif ($method == "GET") {
353355
$this->curlOption(CURLOPT_HTTPGET, 1);
354356
} else {

0 commit comments

Comments
 (0)