crypto/tls: increase readFromUntil buffer size

CL 739980 switched from using a special reader to directly using the
buffer backing memory to read into, but inadvertantly reduced the size
of the buffer that we read into in some circumstances, which could
result in more smaller reads.

Switch back to reading into the largest buffer that we can.

Change-Id: Ic59fe54af6fc671c28a398288bbe603a58cac7e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/769400
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Neal Patel <nealpatel@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
This commit is contained in:
Roland Shoemaker 2026-04-21 10:19:38 -07:00 committed by Gopher Robot
parent 91c0f6acd8
commit 82fd4c4967

View file

@ -816,7 +816,7 @@ func (c *Conn) readFromUntil(r io.Reader, n int) error {
// for how much to read ahead.
c.rawInput.Grow(needs + bytes.MinRead)
for {
buf := c.rawInput.AvailableBuffer()[:needs+bytes.MinRead]
buf := c.rawInput.AvailableBuffer()[:c.rawInput.Available()]
n, err := r.Read(buf)
// This write is just to update the internal state of the
// rawInput bytes.Buffer. It cannot fail.