getHandle(); \curl_setopt($handle, \CURLOPT_HTTPGET, \true); \curl_setopt($handle, \CURLOPT_HTTPHEADER, $headers); \curl_setopt($handle, \CURLOPT_URL, $url); return \curl_exec($handle); } public function post($url, $headers = [], $body = '') { $headers[] = 'Content-Length: ' . \strlen($body); $handle = $this->getHandle(); \curl_setopt($handle, \CURLOPT_HTTPHEADER, $headers); \curl_setopt($handle, \CURLOPT_POST, \true); \curl_setopt($handle, \CURLOPT_POSTFIELDS, $body); \curl_setopt($handle, \CURLOPT_URL, $url); return \curl_exec($handle); } protected function getHandle() { if (!isset(self::$handle)) self::$handle = $this->getNewHandle(); \curl_setopt(self::$handle, \CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer); \curl_setopt(self::$handle, \CURLOPT_TIMEOUT, $this->timeout); return self::$handle; } protected function getNewHandle() { $handle = \curl_init(); \curl_setopt($handle, \CURLOPT_ENCODING, ''); \curl_setopt($handle, \CURLOPT_FAILONERROR, \true); \curl_setopt($handle, \CURLOPT_FOLLOWLOCATION, \true); \curl_setopt($handle, \CURLOPT_RETURNTRANSFER, \true); return $handle; } }