]> Cypherpunks repositories - gostls13.git/commit
net/http: make sure Hijack's bufio.Reader includes pre-read background byte
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 13 Jan 2017 21:43:56 +0000 (21:43 +0000)
committerJoe Tsai <thebrokentoaster@gmail.com>
Fri, 13 Jan 2017 23:13:54 +0000 (23:13 +0000)
commitb2a3b54b9520ce869d79ac8bce836a540ba45d09
tree3b58d04ab9939eb0683e4eb8327a7ee0edb9a394
parent593ea3b3606a16da39e38406e22e373eeb944287
net/http: make sure Hijack's bufio.Reader includes pre-read background byte

Previously, if the Hijack called stopped the background read call
which read a byte, that byte was sitting in memory, buffered, ready to
be Read by Hijack's returned bufio.Reader, but it wasn't yet in the
bufio.Reader's buffer itself, so bufio.Reader.Buffered() reported 1
byte fewer.

This matters for callers who wanted to stitch together any buffered
data (with bufio.Reader.Peek(bufio.Reader.Buffered())) with Hijack's
returned net.Conn. Otherwise there was no way for callers to know a
byte was read.

Change-Id: Id7cb0a0a33fe2f33d79250e13dbaa9c0f7abba13
Reviewed-on: https://go-review.googlesource.com/35232
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
src/net/http/serve_test.go
src/net/http/server.go