protected function _createPsr7Request(Request $request, Connection $connection)
{
$req = new Psr7\Request($request->getMethod(), $this->_getActionPath($request), $connection->hasConfig('headers') && is_array($connection->getConfig('headers')) ? $connection->getConfig('headers') : []);
$data = $request->getData();
if (!empty($data) || '0' === $data) {
if ($req->getMethod() == Request::GET) {
$req = $req->withMethod(Request::POST);
}
if ($this->hasParam('postWithRequestBody') && $this->getParam('postWithRequestBody') == true) {
$request->setMethod(Request::POST);
$req = $req->withMethod(Request::POST);
}
$req = $req->withBody(Psr7\stream_for(is_array($data) ? JSON::stringify($data, JSON_UNESCAPED_UNICODE) : $data));
}
return $req;
}