Oct 27, 2026

Go 1.27 net/http now drains unread HTTP/1 response bodies so connections can be reused

The Go team reports a benchmark that dropped from about 710 ms to 150 ms, and says manual body-draining helpers are no longer needed.

A Go blog post describes a change to net/http in Go 1.27 that affects clients using HTTP/1. Until now, closing a response body that had not been fully read caused the connection to be dropped, so the next request had to pay for a new TCP and TLS handshake.

In the authors example, 100 requests to index.golang.org that only read the status code took about 710 milliseconds on Go 1.26 and about 150 milliseconds on Go 1.27. The post notes that even code which reads a JSON body can hit the problem if a trailing newline is left unread.

Many developers wrote their own helper that reads and discards the body before closing it. Go 1.27 now does this inside net/http.Transport in the background, for up to 50 ms or 256 KB, and skips the work when the server sends Connection: close. HTTP/2 was never affected.

The practical advice from the Go team is to simply close response bodies when finished and remove custom draining code, then measure the result on Go 1.27. The team notes the exact behaviour may change in later releases.

Sources

Verified Oct 27, 2026 (official source). gonethttpperformancedevelopertools