Pipelined client: Reject any pub/sub commnd.

This commit is contained in:
Christoph Heiss 2018-03-04 15:28:09 +01:00
parent 8744756d99
commit 48b94e50d6
2 changed files with 8 additions and 2 deletions

View file

@ -163,7 +163,10 @@ namespace resply {
*/
class Client : public RespCommandSerializer<Result> {
public:
/*! \brief A pipelined redis client. */
/*! \brief A pipelined redis client.
*
* This type of client will reject any {P}{UN}SUBSCIBRE commands.
*/
class Pipeline : public RespCommandSerializer<Pipeline&> {
public:
/*! \brief Constructs a new pipelined client.

View file

@ -288,7 +288,10 @@ std::vector<Result> Client::Pipeline::send()
Client::Pipeline& Client::Pipeline::finish_command(const std::string& command)
{
if (!command.empty()) {
std::string lower;
std::transform(command.begin(), command.end(), lower.begin(), ::tolower);
if (!command.empty() && lower.find("subscribe") == std::string::npos) {
commands_.emplace_back(command + "\r\n");
}