@@ -19,6 +19,7 @@ package redis
1919
2020import (
2121 "bytes"
22+ "errors"
2223 "time"
2324
2425 "github.com/elastic/beats/v7/libbeat/common"
@@ -350,7 +351,7 @@ func (p *parser) parseString(buf *streambuf.Buffer) (common.NetString, bool, boo
350351
351352 content , err := buf .CollectWithSuffix (int (length ), []byte ("\r \n " ))
352353 if err != nil {
353- if err != streambuf .ErrNoMoreBytes {
354+ if ! errors . Is ( err , streambuf .ErrNoMoreBytes ) {
354355 return common.NetString {}, false , false
355356 }
356357 return common.NetString {}, true , false
@@ -425,8 +426,12 @@ func (p *parser) parseArray(depth int, buf *streambuf.Buffer) (common.NetString,
425426
426427 // handle top-level request command
427428 var oneWordCommand , twoWordsCommand bool
429+ var twoWordMethod []byte
428430 oneWordCommand = isRedisCommand (content [0 ])
429- twoWordsCommand = count > 1 && isRedisCommand (bytes .Join (content [0 :2 ], []byte (" " )))
431+ if ! oneWordCommand && count > 1 {
432+ twoWordMethod = bytes .Join (content [0 :2 ], []byte (" " ))
433+ twoWordsCommand = isRedisCommand (twoWordMethod )
434+ }
430435
431436 if depth == 0 && (oneWordCommand || twoWordsCommand ) {
432437 p .message .isRequest = true
@@ -436,7 +441,7 @@ func (p *parser) parseArray(depth int, buf *streambuf.Buffer) (common.NetString,
436441 p .message .path = content [1 ]
437442 }
438443 } else if twoWordsCommand {
439- p .message .method = bytes . Join ( content [ 0 : 2 ], [] byte ( " " ))
444+ p .message .method = twoWordMethod
440445 if len (content ) > 2 {
441446 p .message .path = content [2 ]
442447 }
0 commit comments