跳到正文
原文
Go Blog· Nicholas Husin and Damien Neil·· 2026-10-14精选AI 评分62

Go 博客详解 HTTP/1 连接复用改进:Go 1.27 自动排空响应体

Better HTTP/1 connection reuse

AI 导读

Go 官方博客介绍 net/http 在 Go 1.27 中改进 HTTP/1 连接复用,Transport 会自动异步排空未读响应体,上限 50 ms 或 256 KB。文中示例对 index.golang.org 发起 100 次请求,Go 1.26 约 710 毫秒,Go 1.27 约 150 毫秒。原因是此前未读完响应体就 Close 会放弃连接,官方建议用户只需照常关闭 Body。

推荐理由

Go 官方解释 HTTP/1 连接复用失败的成因,并给出 1.27 自动排空响应体的方案,可对照排查自身客户端的隐性性能损耗。

来源:Go Blog · go.dev