2
0
mirror of https://github.com/soheilhy/cmux.git synced 2026-08-04 07:00:50 +08:00

Merge pull request #23 from soheilhy/bytes-buffer

Replace TeeReader with a bytes buffer
This commit is contained in:
Soheil Hassas Yeganeh
2016-04-24 14:38:36 -04:00
5 changed files with 71 additions and 187 deletions

View File

@@ -284,7 +284,13 @@ func TestHTTP2(t *testing.T) {
t.Fatal(err)
}
var b [len(http2.ClientPreface)]byte
if _, err := muxedConn.Read(b[:]); err != io.EOF {
var n int
// We have the sniffed buffer first...
if n, err = muxedConn.Read(b[:]); err == io.EOF {
t.Fatal(err)
}
// and then we read from the source.
if _, err = muxedConn.Read(b[n:]); err != io.EOF {
t.Fatal(err)
}
if string(b[:]) != http2.ClientPreface {