The Go programming language team has updated the `net/http` standard library in version 1.27 to improve how HTTP/1 connections are reused. Previously, if a developer closed an HTTP response body without reading it entirely, the underlying TCP connection might be discarded because the server still had unconsumed data in its buffer. To prevent this, the Go runtime will now automatically attempt to drain the remaining body data asynchronously when a body is closed, up to a conservative time limit.

This change aims to simplify the developer experience by reducing the need for manual boilerplate code. Before this update, developers often had to implement complex logic—such as `drainAsyncAndCloseBodyWithTimer`—to ensure connections weren't leaked or prematurely closed. By handling this internally, Go 1.27 allows for more efficient connection pooling. For example, one user reported that performing 100 requests against a target using HTTP/1 saw a performance improvement from approximately 710 milliseconds in Go 1.26 to 150 milliseconds in Go 1.27, suggesting a significant reduction in the overhead of establishing new connections.

However, this automation introduces specific trade-offs and edge cases. Because the runtime now tries to drain the body, the behavior of `Close()` is no longer a guarantee that the download will stop immediately; instead, the system will wait for a short period (up to 50ms) to clear the buffer. This may affect scenarios where a developer intentionally wants to skip a large body to save bandwidth. Additionally, some users noted that certain tools, like JSON decoders, might still leave trailing newlines that prevent connection reuse if not handled correctly. While the change improves general performance, it requires developers to be aware that the 'Close' operation is now more of a high-level request lifecycle signal than a low-level socket command.