Fixed PeekAll

- added to handleStream for protocol detection
This commit is contained in:
Henry Camacho 2017-02-26 12:40:10 -06:00
parent 9e2a04c8a7
commit b122a6091b
2 changed files with 7 additions and 20 deletions

View File

@ -53,19 +53,11 @@ func (w *WedgeConn) Buffered() int {
func (w *WedgeConn) PeekAll() (buf []byte, err error) {
loginfo.Println("PeekAll")
var peek []byte
for {
b, err := w.reader.Peek(1)
_, err = w.Peek(1)
if err != nil {
if len(peek) > 0 {
return peek, nil
return nil, err
}
var t byte
t = b[0]
peek = append(peek, t)
loginfo.Println("len", len(peek))
}
}
buf, err = w.Peek(w.Buffered())
return
}

View File

@ -167,12 +167,7 @@ func handleStream(ctx context.Context, wConn *WedgeConn) {
loginfo.Println("handle Stream")
loginfo.Println("conn", wConn, wConn.LocalAddr().String(), wConn.RemoteAddr().String())
//peek for one byte to get the readers to converge
//look at buffer
//get the realrequest
peek, err := wConn.Peek(1)
loginfo.Println(hex.Dump(peek[0:]))
peek, err = wConn.Peek(wConn.Buffered())
peek, err := wConn.PeekAll()
loginfo.Println(hex.Dump(peek[0:]))
if err != nil {