Proposal Details

Currently, if an HTTP response body is closed before fully read (fully means till EOF), the underlying HTTP connection won't be reused. But in the current implementation, body is first read into bufio buffer by bufio reader, then from buffer by body Reader. So even if the body is closed before fully read, as long as the entire body has been read into buffer, after discard buffer, the connection can be reused.

This will be useful when go client only read body if status is 200 while server sends HTTP body in a non 200 status response.

I filed a PR #75303 , reviewer suggests opening an issue and discuss it first, so here it is.

Comment From: gopherbot

Change https://go.dev/cl/701555 mentions this issue: net/http: reuse connection if entire unread body is in buffer

Comment From: adonovan

@neild