From 883f31088129f982e66626f418b25c03a4132992 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 16 Aug 2021 18:10:28 -0400 Subject: [PATCH] try textproto --- main.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index ee363f3..cdfe52c 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,18 @@ package main import ( + "bufio" "database/sql" "encoding/json" "errors" "flag" "github.com/elliotchance/phpserialize" _ "github.com/go-sql-driver/mysql" - "io/ioutil" "log" "net" "os" "sort" + "net/textproto" "sync" "time" ) @@ -192,11 +193,17 @@ type cachecommand struct { func handleConnection(conn net.Conn, UC MetadataCache, PC MetadataCache) { log.Println("handleConnection started") - var buf []byte + var buf string var m *MetadataCache - buf, err := ioutil.ReadAll(conn) + reader := bufio.NewReader(conn) + tp := textproto.NewReader(reader) + buf,err:=tp.ReadLine() + if err != nil { + log.Printf("tp.ReadLine returned %s\n", err.Error()) + return + } var c cachecommand - err = json.Unmarshal(buf, &c) + err = json.Unmarshal([]byte(buf), &c) if err != nil { log.Printf("json.Unmarshal: %s returned %s", buf, err.Error()) }