Oct 25, 2026

Go 1.27 reuses more HTTP/1 connections by draining unread response bodies automatically

The net/http Transport now drains small unread bodies in the background, which the Go team measured at almost five times faster for a status-only client.

The Go team explained a change to net/http in Go 1.27 that improves HTTP/1 connection reuse. In their example, 100 calls that read only the status code took about 710 milliseconds on Go 1.26 and about 150 milliseconds on Go 1.27.

The cause is that HTTP/1 sends responses back to back on one connection. If a program closes a response body without reading it to the end, older versions abandoned the connection and paid for a new TCP and TLS handshake on the next request. Programs that stop just short of the end of the body, such as a JSON decoder leaving a trailing newline, hit the same problem. HTTP/2 is not affected.

Many developers wrote their own helper to drain the body before closing. From Go 1.27 the Transport does this itself, asynchronously, for up to 50 ms or 256 KB, and skips it when the response carries a Connection: close header. The post notes that this behaviour may change in later versions.

The Go team now recommends simply closing response bodies when they are no longer needed. Existing drain helpers can be reviewed and likely removed once a project builds with Go 1.27, though measuring against your own servers is sensible.

Sources

Verified Oct 25, 2026 (official source). gonethttpperformance