From 8d2bcf15cca182da04b54b12f7c8b25f5076b473 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Fri, 9 Sep 2016 21:43:07 -0700 Subject: [PATCH] do not lcase command --- example/clone.go | 3 ++- redcon.go | 10 +--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/example/clone.go b/example/clone.go index 60bf465..0c76182 100644 --- a/example/clone.go +++ b/example/clone.go @@ -2,6 +2,7 @@ package main import ( "log" + "strings" "sync" "github.com/tidwall/redcon" @@ -16,7 +17,7 @@ func main() { err := redcon.ListenAndServe(addr, func(conn redcon.Conn, commands [][]string) { for _, args := range commands { - switch args[0] { + switch strings.ToLower(args[0]) { default: conn.WriteError("ERR unknown command '" + args[0] + "'") case "ping": diff --git a/redcon.go b/redcon.go index def4c8b..e836dcf 100644 --- a/redcon.go +++ b/redcon.go @@ -276,8 +276,7 @@ func handle( } shandler(c, scmds) } else if bhandler != nil { - // copy the byte commands once, before exposing to the - // client. + // copy the byte commands once, before exposing to client. for i := 0; i < len(cmds); i++ { for j := 0; j < len(cmds[i]); j++ { nb := make([]byte, len(cmds[i][j])) @@ -493,13 +492,6 @@ func (r *reader) ReadCommands() ([][][]byte, error) { } i++ arg := b[i : i+ni2] - if len(args) == 0 { - for j := 0; j < len(arg); j++ { - if arg[j] >= 'A' && arg[j] <= 'Z' { - arg[j] += 32 - } - } - } i += ni2 + 1 args = append(args, arg) break