mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 06:58:27 +03:00
Predis to v2.2.2
This commit is contained in:
parent
f6b440adef
commit
84ffe1e552
259 changed files with 2407 additions and 9937 deletions
|
|
@ -3,7 +3,8 @@
|
|||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
@ -19,17 +20,12 @@ use Predis\Protocol\ResponseReaderInterface;
|
|||
/**
|
||||
* Response reader for the standard Redis wire protocol.
|
||||
*
|
||||
* @link http://redis.io/topics/protocol
|
||||
*
|
||||
* @author Daniele Alessandri <suppakilla@gmail.com>
|
||||
* @see http://redis.io/topics/protocol
|
||||
*/
|
||||
class ResponseReader implements ResponseReaderInterface
|
||||
{
|
||||
protected $handlers;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->handlers = $this->getDefaultHandlers();
|
||||
|
|
@ -42,13 +38,13 @@ class ResponseReader implements ResponseReaderInterface
|
|||
*/
|
||||
protected function getDefaultHandlers()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'+' => new Handler\StatusResponse(),
|
||||
'-' => new Handler\ErrorResponse(),
|
||||
':' => new Handler\IntegerResponse(),
|
||||
'$' => new Handler\BulkResponse(),
|
||||
'*' => new Handler\MultiBulkResponse(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,18 +82,16 @@ class ResponseReader implements ResponseReaderInterface
|
|||
$header = $connection->readLine();
|
||||
|
||||
if ($header === '') {
|
||||
$this->onProtocolError($connection, 'Unexpected empty reponse header.');
|
||||
$this->onProtocolError($connection, 'Unexpected empty response header');
|
||||
}
|
||||
|
||||
$prefix = $header[0];
|
||||
|
||||
if (!isset($this->handlers[$prefix])) {
|
||||
$this->onProtocolError($connection, "Unknown response prefix: '$prefix'.");
|
||||
$this->onProtocolError($connection, "Unknown response prefix: '$prefix'");
|
||||
}
|
||||
|
||||
$payload = $this->handlers[$prefix]->handle($connection, substr($header, 1));
|
||||
|
||||
return $payload;
|
||||
return $this->handlers[$prefix]->handle($connection, substr($header, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,7 +104,7 @@ class ResponseReader implements ResponseReaderInterface
|
|||
protected function onProtocolError(CompositeConnectionInterface $connection, $message)
|
||||
{
|
||||
CommunicationException::handle(
|
||||
new ProtocolException($connection, $message)
|
||||
new ProtocolException($connection, "$message [{$connection->getParameters()}]")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue