TLDR Tech / Practical
Go 1.27 HTTP Transport Simplifies Response Body Handling
With Go 1.27, the HTTP Transport automatically manages the draining of unread response bodies up to 256 KiB or 50 milliseconds upon Close, potentially eliminating the need for manual io.Copy(io.Discard, resp.Body) operations. Tests indicate that this handles chunked responses, compressed data, and JSON decoder output within these limits. However, exceptionally slow or unending streams will still prevent connection closure. Developers can still opt for immediate connection termination by using Request.Close, context cancellation, or DisableKeepAlives.
Read the full story