mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
v1.2.7.416
This commit is contained in:
parent
54e2645fcf
commit
3b27abbe9a
434 changed files with 51 additions and 72 deletions
55
rainloop/v/1.2.7.416/app/libraries/Buzz/Client/Curl.php
Normal file
55
rainloop/v/1.2.7.416/app/libraries/Buzz/Client/Curl.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Buzz\Client;
|
||||
|
||||
use Buzz\Message\MessageInterface;
|
||||
use Buzz\Message\RequestInterface;
|
||||
use Buzz\Exception\ClientException;
|
||||
use Buzz\Exception\LogicException;
|
||||
|
||||
class Curl extends AbstractCurl
|
||||
{
|
||||
private $lastCurl;
|
||||
|
||||
public function send(RequestInterface $request, MessageInterface $response, array $options = array())
|
||||
{
|
||||
if (is_resource($this->lastCurl)) {
|
||||
curl_close($this->lastCurl);
|
||||
}
|
||||
|
||||
$this->lastCurl = static::createCurlHandle();
|
||||
$this->prepare($this->lastCurl, $request, $options);
|
||||
|
||||
$data = curl_exec($this->lastCurl);
|
||||
|
||||
if (false === $data) {
|
||||
$errorMsg = curl_error($this->lastCurl);
|
||||
$errorNo = curl_errno($this->lastCurl);
|
||||
|
||||
throw new ClientException($errorMsg, $errorNo);
|
||||
}
|
||||
|
||||
static::populateResponse($this->lastCurl, $data, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Introspects the last cURL request.
|
||||
*
|
||||
* @see curl_getinfo()
|
||||
*/
|
||||
public function getInfo($opt = 0)
|
||||
{
|
||||
if (!is_resource($this->lastCurl)) {
|
||||
throw new LogicException('There is no cURL resource');
|
||||
}
|
||||
|
||||
return curl_getinfo($this->lastCurl, $opt);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (is_resource($this->lastCurl)) {
|
||||
curl_close($this->lastCurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue