try textproto
This commit is contained in:
parent
43a6a202dd
commit
883f310881
15
main.go
15
main.go
|
@ -1,17 +1,18 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/elliotchance/phpserialize"
|
"github.com/elliotchance/phpserialize"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
"net/textproto"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -192,11 +193,17 @@ type cachecommand struct {
|
||||||
|
|
||||||
func handleConnection(conn net.Conn, UC MetadataCache, PC MetadataCache) {
|
func handleConnection(conn net.Conn, UC MetadataCache, PC MetadataCache) {
|
||||||
log.Println("handleConnection started")
|
log.Println("handleConnection started")
|
||||||
var buf []byte
|
var buf string
|
||||||
var m *MetadataCache
|
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
|
var c cachecommand
|
||||||
err = json.Unmarshal(buf, &c)
|
err = json.Unmarshal([]byte(buf), &c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("json.Unmarshal: %s returned %s", buf, err.Error())
|
log.Printf("json.Unmarshal: %s returned %s", buf, err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue