From 3b89eaf6bd368677867324f164bff20305d6f6e5 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 10 May 2026 22:21:51 -0400 Subject: [PATCH] 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 Auto-Submit: Roland Shoemaker Reviewed-by: Neal Patel LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com Reviewed-by: Daniel McCarney Reviewed-by: Filippo Valsorda --- conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conn.go b/conn.go index b239dab..3bcca8b 100644 --- a/conn.go +++ b/conn.go @@ -854,7 +854,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.