MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / serveRedisCommandTestConn

Function serveRedisCommandTestConn

internal/home/client_test.go:388–407  ·  view source on GitHub ↗
(conn net.Conn, log *redisCommandLog, handler func([]string) string)

Source from the content-addressed store, hash-verified

386}
387
388func serveRedisCommandTestConn(conn net.Conn, log *redisCommandLog, handler func([]string) string) {
389 defer func() {
390 _ = conn.Close()
391 }()
392 reader := bufio.NewReader(conn)
393 for {
394 args, errRead := readRedisCommand(reader)
395 if errRead != nil {
396 return
397 }
398 log.Append(args)
399 response := "+OK\r\n"
400 if handler != nil {
401 response = handler(args)
402 }
403 if _, errWrite := io.WriteString(conn, response); errWrite != nil {
404 return
405 }
406 }
407}
408
409func readRedisCommand(reader *bufio.Reader) ([]string, error) {
410 line, errRead := reader.ReadString('\n')

Callers 1

Calls 5

readRedisCommandFunction · 0.85
handlerFunction · 0.85
WriteStringMethod · 0.80
CloseMethod · 0.65
AppendMethod · 0.65

Tested by

no test coverage detected