AIThis post was created with the assistance of artificial intelligence (AI).

TL;DR

Go 1.27 changes Go’s HTTP client behavior so an HTTP/1 connection can sometimes be reused after a response body is closed without being fully read. In the Go blog’s example, 100 status-code requests to index.golang.org took about 150 milliseconds on Go 1.27, compared with about 710 milliseconds on Go 1.26; the result is specific to that test and setup.

The Go project says Go 1.27 improves HTTP/1 connection reuse when an application closes a response body before reading it fully, a common pattern when code needs only a status code or part of a response. In a benchmark reported by the Go blog, 100 requests to index.golang.org took about 150 milliseconds on Go 1.27, compared with about 710 milliseconds on Go 1.26, when HTTP/2 was disabled.

Buying for a business?Offer from Amazon

Get business pricing on monitors, keyboards and dev gear

  • Business-only prices and quantity discounts
  • Tax-exempt purchasing
  • Multiple users, one account, clear invoices
As an affiliate, we earn on qualifying purchases.

The benchmark uses a small Go function that calls http.Get, records the response status, and defers closing the response body without consuming it. The blog reports the timings as measurements from the author’s machine, not a guarantee for all applications or networks. The test explicitly used GODEBUG=http2client=0 to force HTTP/1, and the endpoint supports TLS 1.3.

Under the earlier behavior described in the report, closing an unread HTTP/1 response body meant the client could not safely identify where the next response began in the sequential byte stream. The connection was abandoned, so later requests had to establish new connections. Go 1.27 changes this outcome in some cases: the client can make the connection available for reuse after the body is closed, rather than always discarding it.

The improvement concerns HTTP/1.0 and HTTP/1.1, where responses on a connection are delivered sequentially. It does not describe a change to HTTP/2, which multiplexes separate streams and does not have the same blocking issue from an unread body. The report’s headline performance difference is tied to its particular workload, response size, network conditions and Go versions.

At a glance
announcementWhen: Described in a Go blog post about Go 1.…
The developmentThe Go project reports that Go 1.27 improves HTTP/1 connection reuse when applications close response bodies without reading them to the end.

Fewer HTTP/1 Handshakes for Clients

Connection reuse can matter when an application makes many requests to the same service. Each fresh connection may require a TCP handshake and, for HTTPS, a TLS handshake before the request can be sent. Avoiding repeated setup can reduce latency and connection overhead, especially when network round-trip times are high or responses are small relative to the cost of connecting.

The practical effect is most relevant to code that closes bodies without fully reading them, including callers that only inspect a response code or stop parsing shortly before the end of a response. The Go blog notes that even a trailing newline after a JSON object can remain unread when a decoder stops at the closing brace. For such cases, improved reuse may reduce the need for application code to drain response bodies solely to preserve a connection.

That does not mean every request becomes faster by the same amount. Reuse depends on HTTP version, server behavior, whether the connection remains usable, and the size and framing of the response. The reported near-fivefold difference is evidence of the effect in one test, not a general speedup figure for Go programs.

As an affiliate, we earn on qualifying purchases.

Why Unread Bodies Blocked Reuse

Go’s net/http package supports HTTP/1.0, HTTP/1.1 and HTTP/2. HTTP/1.1 connections are persistent by default unless either side indicates that the connection should close. But HTTP/1 responses share one ordered stream: the client must reach the end of one response body to know where the next response starts. Closing a body before that point historically made the connection unsuitable for another request.

Developers have often handled this by reading or draining the body before closing it. That can preserve reuse, but it may also mean reading data the application does not need. The Go blog describes this as a long-standing sharp edge, including cases where a parser consumes nearly all the response but leaves a final byte unread.

HTTP/2 avoids this specific constraint because it carries requests and responses on multiplexed streams over a connection. The source’s comparison is deliberately focused on HTTP/1: its benchmark disables HTTP/2 so that the effect of the changed reuse behavior is visible.

“On Go 1.27, the same program takes ~150 milliseconds.”

— Go blog

Limits of the Reported Speedup

The source gives one benchmark, performed on the author’s machine against index.golang.org; it does not establish a standard speedup across workloads. The report does not provide enough detail here to calculate how the change performs across different servers, response sizes, TLS configurations, or network distances. Its timing comparison should be treated as an example of the behavior, not a universal forecast.

The description says Go 1.27 can reuse connections in the affected situation, but does not specify in the supplied material every condition under which reuse is possible or how the client handles bodies of different sizes. Applications should not assume that every closed, unread response body will leave a connection reusable. The source also does not quantify any trade-offs, such as extra work involved in the updated behavior.

Check Behavior in Go 1.27

Developers can compare their own HTTP/1 workloads on Go 1.27 with earlier versions, paying attention to whether their code reads response bodies fully and whether HTTP/2 is enabled. The blog’s test disables HTTP/2, so results from applications that negotiate HTTP/2 may not reflect the same change.

For services with many short HTTP/1 requests, the relevant next step is to measure connection reuse and end-to-end latency under their actual traffic and server settings. The supplied report does not give a broader benchmark suite or further rollout details, so the scale of the benefit beyond its example remains to be established by application-level testing.

Key Questions

What changed in Go 1.27?

The Go blog says the HTTP client can reuse an HTTP/1 connection in some cases after the application closes a response body without reading it fully. Previously, that situation could cause the connection to be discarded.

How large was the reported performance difference?

In the blog’s example, 100 requests to index.golang.org took about 150 milliseconds on Go 1.27 and about 710 milliseconds on Go 1.26, with HTTP/2 disabled. These are measurements from the author’s machine, not a general performance promise.

Does the change affect HTTP/2?

The reported issue and improvement concern HTTP/1. HTTP/2 multiplexes streams over one connection, so an unread body on one stream does not block other requests in the same way.

Should applications still close response bodies?

Yes. The example and discussion concern closing the body without fully reading it; they do not suggest leaving response bodies open. The source does not say that every unread body will permit reuse, so applications should not rely on that outcome in every case.

Will all Go programs become nearly five times faster?

No. The near-fivefold difference applies to one reported test with a particular endpoint, request pattern and HTTP/1 setting. Actual results depend on the application, server, network and protocol.

Source: hn

You May Also Like

CVE-2026-119618: Steps To Take For Apache HTTP/2 Security

Apache released HTTP Server 2.4.71 for a critical mod_http2 flaw. Administrators should check HTTP/2 exposure and apply vendor fixes.

We Want You To Build The Next Git Platform On Cloudflare

Cloudflare is inviting developers to build an agent-focused Git platform using its open-beta Artifacts service and Workers.

Rust Style Guide

Google’s Rust Style Guide sets guidance for formatting, APIs and implementation, with other codebases including Android and Chromium considering adoption.

Planning For OpenAI’s GPT-4o, GPT-4.1, And GPT-5-nano API Changes

OpenAI API retirements start with models already shut down on Oct. 23, followed by December and January deadlines. Replacements may change costs and behavior.