Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json and xml support to the post method in socket client #14169

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/internal/Magento/Framework/HTTP/Client/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected function parseUrl($uri)
* Make POST request
*
* @param string $uri
* @param array $params
* @param array|string $params use string in case of JSON or XML POST request
* @return void
*/
public function post($uri, $params)
Expand Down Expand Up @@ -455,10 +455,12 @@ public function getStatus()

/**
* Make request
*
* @param string $method
* @param string $uri
* @param array $params
* @param array|string $params use string in case of JSON or XML POST request
* @return void
* @throws \Exception
*/
protected function makeRequest($method, $uri, $params = [])
{
Expand All @@ -473,8 +475,8 @@ protected function makeRequest($method, $uri, $params = [])

$appendHeaders = [];
$paramsStr = false;
if ($isPost && count($params)) {
$paramsStr = http_build_query($params);
if ($isPost && $params) {
$paramsStr = is_array($params) ? http_build_query($params) : $params;
$appendHeaders['Content-type'] = 'application/x-www-form-urlencoded';
$appendHeaders['Content-length'] = strlen($paramsStr);
}
Expand Down