Fixed PeekAll
- added to handleStream for protocol detection
This commit is contained in:
parent
9e2a04c8a7
commit
b122a6091b
|
@ -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)
|
||||
if err != nil {
|
||||
if len(peek) > 0 {
|
||||
return peek, nil
|
||||
}
|
||||
|
||||
var t byte
|
||||
t = b[0]
|
||||
|
||||
peek = append(peek, t)
|
||||
loginfo.Println("len", len(peek))
|
||||
}
|
||||
_, err = w.Peek(1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buf, err = w.Peek(w.Buffered())
|
||||
return
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue